CVE-2026-52846: Caddy StripHTML Template Function Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-vcc4-2c75-vc9v
CVSS 4.2
CWE-116
Published
Advisory Summary

CVE-2026-52846 is a MODERATE (CVSS 4.2) striphtml template function bypass vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Caddy libraries in the Go ecosystem. The issue involves striphtml template function bypass. Remediation is available by upgrading affected packages to version 2.11.4.

CVE-2026-52846 at a Glance

CVE Identifier CVE-2026-52846
GHSA Identifier GHSA-vcc4-2c75-vc9v
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Caddy
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-52846

To remediate this vulnerability, upgrade all affected Caddy dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/caddyserver/caddy/v2 fixed: 2.11.4
Upgrade github.com/caddyserver/caddy/v2 to 2.11.4
github.com/caddyserver/caddy fixed: Latest secure release
Upgrade github.com/caddyserver/caddy to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/caddyserver/caddy/v2

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-52846, inspect your project dependencies for Caddy:

inspect dependencies for github.com/caddyserver/caddy/v2

Analyze the terminal output to locate any version of Caddy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.11.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Caddy, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary 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. --- ### Details The vulnerability originates from `funcStripHTML` in: [caddy/caddy/caddyhttp/templates/tplcontext.go](https://github.com/caddyserver/caddy/blob/77e9ce7404c4a76853e101a9f5687a929ee56654/modules/caddyhttp/templates/tplcontext.go) ```go func (TemplateContext) funcStripHTML(s string) string { var buf bytes.Buffer var inTag, inQuotes bool var tagStart int for i, ch := range s { if inTag { if ch == '>' && !inQuotes { inTag = false } else if ch == '<' && !inQuotes { // false start buf.WriteString(s[tagStart:i]) tagStart = i } else if ch == '"' { inQuotes = !inQuotes } continue } if ch == '<' { inTag = true tagStart = i continue } buf.WriteRune(ch) } if inTag { // false start buf.WriteString(s[tagStart:]) } return buf.String() } ``` ### POC Caddyfile setup ``` :8080 { root * ./site file_server templates } ``` Template file (index.html) ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>StripHTML Bypass Test</title> </head> <body> <p>{{ stripHTML "<<>img src=x onerror=alert('XSS')>" }}</p> </body> </html> ``` The 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. Tested in v2.11.3 ### Impact Malformed HTML can bypass stripHTML, potentially allowing arbitrary HTML or JavaScript to be rendered if the output is used unsafely, leading to client-side XSS. ### AI Disclosure AI assisted in writing the report description; however, the discovery of the issue has been done manually.

CVE-2026-52846 Affected Caddy Versions

2 component(s)
Fixed Versions:
2.11.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/caddyserver/caddy/v2
Go
< 2.11.4
2.11.4
github.com/caddyserver/caddy
Go
≤ 1.0.5

References

Frequently Asked Questions

What is CVE-2026-52846?
CVE-2026-52846 is a security vulnerability in Caddy involving stripHTML template function bypass under CWE-116: Improper Encoding or Escaping of Output.
Which Caddy versions are affected?
Affected versions include releases prior to 2.11.4 across affected packages: github.com/caddyserver/caddy/v2, github.com/caddyserver/caddy.
What version fixes CVE-2026-52846?
Upgrading to 2.11.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/caddyserver/caddy/v2 affected?
Yes, github.com/caddyserver/caddy/v2 is affected in releases prior to 2.11.4. Upgrade your dependency to 2.11.4 or later.
Is github.com/caddyserver/caddy affected?
Yes, github.com/caddyserver/caddy is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2026-52846?
CVE-2026-52846 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2026-52846?
CVE-2026-52846 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check Go dependencies for CVE-2026-52846?
Run the dependency tree command: 'inspect dependencies for github.com/caddyserver/caddy/v2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vcc4-2c75-vc9v",
  "modified" : "2026-06-16T21:28:55Z",
  "published" : "2026-06-16T21:28:55Z",
  "aliases" : [ "CVE-2026-52846" ],
  "summary" : "Caddy: stripHTML template function bypass",
  "details" : "### 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/caddyserver/caddy/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.11.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.11.3"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/caddyserver/caddy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.0.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/caddyserver/caddy/security/advisories/GHSA-vcc4-2c75-vc9v"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/caddyserver/caddy"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T21:28:55Z",
    "nvd_published_at" : null
  }
}