Claude skill HTTP request smuggling via CL.TE and TE.CL desync — SA-SKL-DESYNC1
Most MCP skill deployments sit behind a reverse proxy — Caddy, nginx, or a CDN — that forwards requests to a Node.js backend over a persistent HTTP/1.1 connection. HTTP request smuggling exploits the disagreement between how the proxy and the backend parse the boundary between consecutive HTTP requests on that shared connection. SA-SKL-DESYNC1 covers four desync patterns: CL.TE (Caddy trusts Content-Length, Node trusts Transfer-Encoding), TE.CL (nginx trusts TE, Node trusts CL), H2-to-H1 downgrade desync, and cache poisoning via smuggled GET requests.
How request smuggling affects MCP skill deployments
HTTP/1.1 defines two ways to delimit a request body: Content-Length (fixed byte count) and Transfer-Encoding: chunked (variable-length chunks terminated by a zero-length chunk). RFC 7230 says that if both headers are present, Transfer-Encoding takes precedence. But when the frontend proxy and the backend application disagree about which header to use — either because one of them doesn't implement the RFC correctly, or because a malformed header exploits parser differences — a single TCP-level request is parsed as two HTTP requests at the backend layer.
The smuggled request is then prepended to the next legitimate user's request on the same backend connection. The backend processes both requests as if they arrived from the same connection: the attacker's smuggled prefix can redirect the victim's request to an internal endpoint, modify their session, bypass authentication checks, or poison a shared response cache.
DESYNC1-001 — Caddy + Node CL.TE desync
In a CL.TE desync, the frontend proxy (Caddy) uses Content-Length to determine where the request ends, while the backend (Node.js HTTP parser) uses Transfer-Encoding: chunked. The attacker crafts a request where the Content-Length value covers the main request body plus a hidden "prefix" block that starts with chunked encoding syntax. Caddy forwards the entire body as one request. Node.js parses the chunked encoding and sees two requests: the main request and the hidden prefix. The prefix is queued as the start of the next connection-reuse request. When the next legitimate user's request arrives on the same backend connection, Node prepends the attacker's prefix to it, potentially overwriting the victim's URL path, headers, or body content.
The Caddy fix is to enable allow_h2c: false and configure the reverse proxy to normalize the Transfer-Encoding header before proxying, rejecting requests that contain both Content-Length and Transfer-Encoding: chunked. The Node.js fix is to configure the HTTP server to reject ambiguous requests at the parser level using the insecureHTTPParser: false option (the default since Node.js 15) and to never accept both headers simultaneously.
# VULNERABLE Caddyfile — no Transfer-Encoding normalization; CL.TE desync possible
{
admin off
}
skillaudit.dev {
reverse_proxy localhost:3000 # forwards both CL and TE headers to Node backend
# Missing: header normalization to strip ambiguous TE/CL combinations
}
# FIXED Caddyfile — strip Transfer-Encoding before proxying; use HTTP/2 only on frontend
{
admin off
}
skillaudit.dev {
reverse_proxy localhost:3000 {
# Normalize headers: remove TE header before proxying to Node backend
# Node backend then uses only Content-Length — no desync possible
header_up -Transfer-Encoding
# Force HTTP/1.1 to backend to prevent H2 downgrade desync
transport http {
versions 1.1
}
}
# Reject requests with both Content-Length and Transfer-Encoding
@desync_attempt {
header Content-Length *
header Transfer-Encoding chunked
}
respond @desync_attempt 400
}
// FIXED Node.js — insecureHTTPParser:false (default) + explicit CL/TE conflict rejection
import http from 'http';
import express from 'express';
const app = express();
// Middleware: reject requests that contain both Content-Length and Transfer-Encoding
// This should never reach Node if Caddy strips TE, but belt-and-suspenders
app.use((req, res, next) => {
if (req.headers['transfer-encoding'] && req.headers['content-length']) {
res.status(400).json({ error: 'Ambiguous Content-Length + Transfer-Encoding headers' });
return;
}
next();
});
const server = http.createServer(
{ insecureHTTPParser: false }, // reject non-compliant HTTP/1.1 (default since Node 15)
app
);
DESYNC1-002 — nginx TE.CL desync
In a TE.CL desync, nginx uses Transfer-Encoding: chunked to determine where the request ends, while the Node.js backend uses Content-Length. The attacker crafts a chunked body where the final chunk size visible to nginx is small, but the Content-Length tells Node to expect more bytes. Node waits for the remaining bytes, which arrive as the start of the next legitimate user's request on the same connection. Node prepends them to the victim's request, treating the victim's HTTP method and URL as the continuation of the attacker's body.
The nginx fix is to pass through HTTP/1.1 connection headers correctly. Setting proxy_http_version 1.1 and clearing the Connection header removes hop-by-hop Transfer-Encoding` from the proxied request, forcing nginx and Node to renegotiate chunked encoding handling on each proxied connection rather than reusing a conflicted state.
# VULNERABLE nginx config — HTTP/1.0 proxy default + no TE normalization
server {
listen 443 ssl;
location / {
proxy_pass http://localhost:3000;
# Default: proxy_http_version 1.0 — sends Connection:close, loses TE handling
# Actually allows TE.CL desync via chunked body misparse
}
}
# FIXED nginx config — HTTP/1.1 keep-alive to backend + Connection header cleared
server {
listen 443 ssl;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Connection ""; # clear hop-by-hop Connection header
# nginx now consistently uses HTTP/1.1 semantics for TE handling
# and does not reuse backend connections with conflicting TE/CL state
# Also reject requests with both headers at nginx level
if ($http_transfer_encoding ~* "chunked") {
set $has_te 1;
}
if ($http_content_length ~* "[0-9]") {
set $has_cl 1;
}
# Note: nginx if-in-location has limitations; use lua or map block for production
}
}
DESYNC1-003 — H2 downgrade desync via pseudo-header injection
When a CDN or load balancer accepts HTTP/2 from clients and downgrades to HTTP/1.1 for the backend, it must translate HTTP/2 pseudo-headers (:method, :path, :scheme, :authority) into HTTP/1.1 header lines. If the proxy does not validate pseudo-header values for newline or carriage return characters, an attacker can inject \r\n into a pseudo-header value, causing the backend HTTP parser to see the injected bytes as a new header line or a new request. The :path pseudo-header is the most common vector — a value like /api/scan\r\nX-Admin-Override: true injects an extra header into the downgraded HTTP/1.1 request at the backend.
# Attacker HTTP/2 request (conceptual — sent via curl --http2 or h2c client): # :method = POST # :path = /api/scan\r\nX-Admin-Override: true # :scheme = https # :authority = skillaudit.dev # Content-Type: application/json # (body) # # Downgraded to HTTP/1.1 at proxy layer: # POST /api/scan # X-Admin-Override: true ← injected via CRLF in :path # Host: skillaudit.dev # Content-Type: application/json # FIX: validate and reject HTTP/2 pseudo-header values containing CR, LF, or NUL # In Caddy 2.7+ this is automatic — pseudo-headers are sanitized before downgrade # In nginx: validate at Lua layer or use ngx_http_lua_module for CRLF rejection
// Node.js application-layer fix — reject requests where headers contain suspicious values
import express from 'express';
const app = express();
// Belt-and-suspenders: reject any header value containing CRLF sequences
// These should be blocked at the proxy layer, but add defense-in-depth here
app.use((req, res, next) => {
for (const [name, value] of Object.entries(req.headers)) {
const v = Array.isArray(value) ? value.join(',') : (value || '');
if (/[\r\n\0]/.test(v)) {
res.status(400).json({ error: 'Invalid header value' });
return;
}
}
next();
});
DESYNC1-004 — Cache poisoning via smuggled GET request
When request smuggling is possible, the attacker can structure the smuggled prefix as a complete GET request to a high-value cached path. If a CDN sits in front of the application and the backend processes the smuggled GET before the next victim's request, the CDN may cache the response to the smuggled URL under the attacker-specified cache key. Subsequent users requesting that URL receive the poisoned cached response — potentially a redirect to a phishing site, a modified page with injected script, or an HTTP 302 to an attacker-controlled domain — until the CDN cache TTL expires.
The primary mitigation is to fix the upstream desync that enables the smuggled request. As a secondary measure, vary all CDN cache entries on the Host header and monitor for unexpected cache entries via X-Cache-Status response headers. For MCP skill audit result pages specifically, never cache responses that include session-specific data — use Cache-Control: private, no-store for all authenticated endpoints.
// Node.js: set cache headers defensively on all authenticated routes
import express from 'express';
const app = express();
// All authenticated routes: no caching anywhere
app.use('/api/', (req, res, next) => {
res.set('Cache-Control', 'private, no-store');
res.set('Pragma', 'no-cache');
next();
});
// Public cached routes: add Vary to prevent cross-origin cache poisoning
app.use('/seo/', (req, res, next) => {
res.set('Cache-Control', 'public, max-age=3600');
res.set('Vary', 'Accept-Encoding, Origin'); // ensures CDN keys include Origin
next();
});
Related patterns: HTTP request smuggling in MCP skill deployments often exploits the same proxy layer that processes WebSocket upgrades — see SA-SKL-CORS10: WebSocket and SSE CORS security for the complementary streaming transport attack surface. For cache-layer attacks that don't require smuggling — including CDN cache key manipulation and stale-while-revalidate timing — see SA-SKL-CACHING3: Cache-Control misconfiguration.
| Finding | Severity | Vulnerable pattern | Fix |
|---|---|---|---|
DESYNC1-001 | Critical | Caddy proxies both CL and TE headers to Node; CL.TE body desync | Caddy: header_up -Transfer-Encoding; Node: reject CL+TE simultaneously; insecureHTTPParser:false |
DESYNC1-002 | Critical | nginx HTTP/1.0 proxy; TE.CL body desync on shared backend connection | proxy_http_version 1.1; proxy_set_header Connection ""; |
DESYNC1-003 | High | H2-to-H1 downgrade; CRLF in :path pseudo-header injects extra headers | Caddy 2.7+ auto-sanitizes; nginx: Lua layer CRLF validation; Node: reject CR/LF/NUL in header values |
DESYNC1-004 | High | Smuggled GET poisons CDN cache for high-value path | Fix upstream desync; Cache-Control: private, no-store on auth routes; Vary: Origin on public |