CVE-2026-52846: Caddy stripHTML XSS Bypass (CWE-116)
Caddy's stripHTML template function, designed to remove HTML tags from user input, has a flaw that allows certain malformed HTML patterns to bypass its filtering logic. Specifically, malformed tags like <<>img src=x onerror=alert()> can slip through, potentially leaving executable scripts in the output if that output is later rendered as HTML in a browser. This creates a client-side XSS vulnerability when applications use stripHTML to sanitize untrusted content but then display the result unsafely. The flaw affects Caddy versions prior to 2.11.4.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 4.2 MEDIUM · CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N
- Weaknesses (CWE)
- CWE-116
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-06-23 / 2026-06-29
NVD description (verbatim)
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.
2 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The stripHTML function in Caddy fails to properly handle edge-case HTML constructs, particularly malformed opening tags with nested angle brackets. The bypass technique exploits a gap in the tag-matching logic where non-standard sequences are not fully consumed before content is returned. When an attacker controls input to stripHTML and the output is subsequently rendered in an HTML context (e.g., within a Caddy template that outputs to a web page without further escaping), the malformed tag can evade removal, preserving event handler attributes that execute in the victim's browser. This is classified as an Improper Input Validation (CWE-116) issue. The vulnerability was patched in version 2.11.4 with improved tag-stripping logic that correctly handles malformed constructs.
Business impact
For organizations using Caddy as a web server or gateway, the risk is moderate but depends heavily on deployment context. If Caddy is used in a configuration where the stripHTML function processes user-supplied data that is later served to end users, an attacker could inject XSS payloads that steal session tokens, redirect users, or perform actions on their behalf. The impact is primarily on confidentiality and integrity of client-side data; availability is not affected. Organizations relying on stripHTML for security should treat this as a trust boundary breach and prioritize patching. Those who do not use stripHTML or who handle HTML sanitization at a separate layer face lower risk.
Affected systems
Caddy versions prior to 2.11.4 are vulnerable. This includes all 2.11.x releases up to and including 2.11.3, as well as earlier major versions (2.10, 2.9, etc.). Caddy is typically deployed as a reverse proxy, API gateway, or file server, often in cloud-native and containerized environments. Organizations using Caddy in production should verify their running version and apply the 2.11.4 update. Custom Caddy builds or distributions bundled with other software should be evaluated against their vendor's release timelines.
Exploitability
Exploitation requires two conditions: (1) the attacker must be able to supply input that is processed by stripHTML, and (2) the resulting output must be rendered as HTML to an end user without additional escaping. The attack vector is network-based and requires user interaction (a victim must view the malicious content in a browser), reflected in the CVSS score of 4.2 (Medium). Complexity is rated as High because the attacker must craft a specific malformed HTML pattern and ensure it reaches an unsafe rendering context. This is not a trivial one-click exploit; it requires understanding the application's use of stripHTML and its output sanitization practices. No public exploit code has been disclosed as of the advisory date.
Remediation
Upgrade Caddy to version 2.11.4 or later. Operators should audit their Caddy configuration and template files to identify any reliance on stripHTML as a primary security control. If stripHTML is used to sanitize untrusted user input before rendering, ensure output is additionally escaped or use a dedicated, well-tested HTML sanitization library (e.g., bluemonday for Go, or similar). Consider implementing Content Security Policy (CSP) headers as a defense-in-depth measure to mitigate client-side injection risks.
Patch guidance
Update Caddy to version 2.11.4 or later. This is available from the official Caddy project releases. If using Caddy through a package manager (apt, yum, Homebrew, etc.), check for available updates and apply them. If running Caddy in a container, update the base image or Caddy binary and redeploy. Verify the upgrade by running `caddy version` and confirming the output shows 2.11.4 or higher. After patching, restart Caddy to activate the fixed binary.
Detection guidance
Look for stripHTML function calls in Caddy configuration files (Caddyfiles) and custom Caddy plugins or Go code. Monitor for any template blocks that use stripHTML and then output the result to HTML contexts without escaping. If you cannot easily identify stripHTML usage, test your Caddy instance with a payload like <<>img src=x onerror=alert(test)> through user input fields and inspect the response to see if the malformed tag is removed. Additionally, review web server logs for unusual HTML patterns in query strings or POST bodies. Security scanning tools that test for XSS may trigger on this vulnerability if your application accepts the malformed payload.
Why prioritize this
This vulnerability should be prioritized based on your use of stripHTML and your application's trust boundary design. If Caddy is internet-facing and accepts untrusted user input that is processed by stripHTML and rendered to other users, this is a clear XSS vector and should be patched immediately. If stripHTML is used only internally or as a secondary defense layer behind a dedicated sanitizer, the risk is lower. The CVSS score of 4.2 reflects the requirement for user interaction and limited scope, but the actual risk in your environment depends on whether the two exploitation conditions are met. Review quickly; patch within one release cycle if affected.
Risk score, explained
The CVSS 3.1 score of 4.2 (Medium severity) reflects: Network-based attack vector (AV:N); High complexity because a specific malformed HTML construct must reach an unsafe rendering context (AC:H); no privilege required (PR:N); user interaction needed—the victim must view the page with the injected content (UI:R); unchanged scope (S:U); limited confidentiality and integrity impact on the client's session or data (C:L, I:L); and no availability impact (A:N). The score appropriately downgrades from High because the vulnerability requires two implementation decisions (use of stripHTML + unsafe output) and user interaction. In a real-world XSS scenario, the user impact could be severe, but the CVSS baseline assumes a less-critical context.
Frequently asked questions
Do I need to patch if I don't use stripHTML in my Caddy configuration?
No. This vulnerability only affects deployments that explicitly call the stripHTML template function. If your Caddyfile and templates do not include stripHTML, you are not directly vulnerable. However, if you use third-party Caddy plugins or modules, verify they do not rely on stripHTML for sanitization.
Can this vulnerability be exploited without user interaction?
No. The vulnerability requires a victim to view the malicious content in a browser. The attacker cannot execute code on the server or bypass authentication. An attacker must craft the malformed HTML, ensure it is stored or reflected through stripHTML, and then trick a user into viewing it—typically via a phishing link or stored XSS if user input is persisted.
Is there a workaround if I cannot patch immediately?
Yes, apply defense-in-depth: (1) use an additional HTML sanitization library in your application layer, (2) implement strict Content Security Policy headers to block inline script execution, and (3) use HTTP-only and Secure flags on session cookies. However, these are not substitutes for patching. Schedule the upgrade to 2.11.4 as soon as possible.
Does this affect Caddy's default TLS configuration or reverse proxy features?
No. This vulnerability is specific to the stripHTML template function. Caddy's TLS defaults, reverse proxy logic, and other core features are not affected. The vulnerability only manifests if stripHTML is used in your templates or plugins.
This analysis is based on the official CVE-2026-52846 advisory and the Caddy project's security release notes. Patch version numbers and affected product versions reflect the vendor's guidance as of the publish date. Organizations should verify their specific Caddy deployment version and consult the official Caddy security advisory for the latest patching instructions. Security controls and risk profiles vary by deployment; this summary provides a general framework and should be adapted to your environment. No exploit code or weaponized proof-of-concept is provided or encouraged. Testing should be conducted only in isolated or authorized environments. Source: NVD (public-domain), retrieved 2026-07-29. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-44311MEDIUMFabric.js XSS Vulnerability in SVG Serialization
- CVE-2026-49472MEDIUMFreeSWITCH XML Parser Denial of Service (MEDIUM)
- CVE-2026-54287MEDIUMHono HTTP Cookie Header Corruption in AWS Lambda Deployments
- CVE-2026-12044HIGHSQL Injection in pgAdmin 4 Description Fields
- CVE-2026-12047LOWHTML Injection in pgAdmin 4 Cloud Deployment Wizard
- CVE-2026-42558HIGHXibo Stored XSS and Iframe Sandbox Escape in Data Connector
- CVE-2026-44913HIGHApache NiFi CaptureChangeMySQL SQL Injection Vulnerability
- CVE-2026-45011HIGHApostropheCMS 4.29.0 Stored XSS in Image Widget – Security Analysis