← Blog

Claude MCP skill request smuggling and cache poisoning in registry reverse proxy — SA-SKL-RATELIMIT13

MCP skill registries sit behind a reverse proxy stack — typically Nginx in front of an Express application, with a CDN layer above. Each hop in this stack parses HTTP headers slightly differently, creating ambiguities that attackers can exploit to bypass rate limits, smuggle requests, poison shared caches, and inject headers into proxied backend requests. SA-SKL-RATELIMIT13 covers four reverse-proxy-specific attack patterns that surface when the proxy and application disagree on how to interpret the same HTTP message.

By SkillAudit  |  12 Nov 2026
SA-SKL-RATELIMIT13 findings at a glance
HIGHRATELIMIT13-001 — Express behind Nginx uses X-Forwarded-For header for per-IP rate limiting with trust proxy: true — attacker spoofs X-Forwarded-For: 1.2.3.4 to present any IP; rate limit counter keyed on the spoofed IP is effectively unlimited for the attacker
CRITICALRATELIMIT13-002 — HTTP/1.1 request smuggling via ambiguous Content-Length and Transfer-Encoding headers — Nginx uses Content-Length to delimit the request body, Express uses Transfer-Encoding: chunked; attacker prepends a partial second request inside the body of the first; second request is processed as a new authenticated request from a different user
HIGHRATELIMIT13-003 — CDN cache poisoning via unkeyed Host header — registry search API response cached by CDN without Vary: Host; attacker requests GET /api/skills/search?q=test with Host: attacker.com; response cached and served to legitimate users whose browser uses Host: skillaudit.dev
CRITICALRATELIMIT13-004 — Nginx proxy_pass to upstream with user-controlled path — skillId parameter containing CRLF (\r\n) characters injects additional HTTP headers into the proxied backend request; attacker overrides Authorization or X-User-Id headers in the upstream request

RATELIMIT13-001 — X-Forwarded-For header spoofing bypasses rate limiting

When Express is configured with app.set('trust proxy', true) (or trust proxy: 1), it uses the last IP in the X-Forwarded-For header as req.ip. If an attacker can send their own X-Forwarded-For header to Nginx (not stripped by Nginx), the XFF chain becomes attacker-spoofed-ip, real-attacker-ip, nginx-ip. With trust proxy: true (unlimited depth), Express uses the leftmost IP in the XFF chain — the attacker-controlled attacker-spoofed-ip — as req.ip. The rate-limit counter is keyed on this spoofed IP, giving the attacker unlimited quota by rotating the spoofed value.

// VULNERABLE — RATELIMIT13-001
// Express trust proxy: true reads XFF without depth limit.
// Nginx does not strip incoming X-Forwarded-For from client.
// Rate limiter keys on req.ip which is the attacker-controlled leftmost XFF value.

// Attacker request:
// GET /api/audits HTTP/1.1
// X-Forwarded-For: 192.168.1.1  ← attacker injects their chosen "IP"
// Host: skillaudit.dev

// Nginx adds real IP: X-Forwarded-For: 192.168.1.1, 203.0.113.100
// Express with trust proxy: true reads leftmost → req.ip = 192.168.1.1
// Rate limit counter increments for 192.168.1.1 (attacker rotates this)

app.set('trust proxy', true);  // VULNERABLE: unlimited trust depth

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100,
  keyGenerator: (req) => req.ip,  // req.ip is spoofable via XFF
});

app.use('/api/', limiter);
// FIXED — RATELIMIT13-001
// Fix 1: Set trust proxy to the number of trusted proxy hops (1 for single Nginx layer).
// Fix 2: Configure Nginx to overwrite (not append) X-Forwarded-For with the real client IP.
// Fix 3: Use the rightmost IP in the XFF chain (the hop closest to the server) as rate limit key.

// Nginx config fix:
// proxy_set_header X-Real-IP $remote_addr;
// proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
// — but crucially, use real_ip_recursive on; with the known proxy IP range to strip spoofed IPs

// Express fix:
app.set('trust proxy', 1);  // FIX: trust exactly 1 hop (Nginx) — req.ip = Nginx's view of client IP

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100,
  // FIX: express-rate-limit v7+ with trust proxy: 1 sets req.ip correctly
  // Additionally, rate-limit on X-Real-IP (set by Nginx from $remote_addr, not XFF)
  keyGenerator: (req) => req.headers['x-real-ip'] || req.socket.remoteAddress,
  skip: (req) => false,  // never skip rate limiting
});

app.use('/api/', limiter);

Trust proxy depth matters: trust proxy: true trusts the entire XFF chain with no depth limit — an attacker who can inject any header can forge any IP. trust proxy: 1 trusts only the last hop (the Nginx IP), so the IP Express sees is the one Nginx observed, not anything the client sent. For multi-layer proxy setups (CDN → Nginx → Express), set trust proxy: 2.

RATELIMIT13-002 — HTTP/1.1 TE-CL request smuggling

HTTP/1.1 supports two ways to delimit request bodies: Content-Length (fixed byte count) and Transfer-Encoding: chunked (variable-length chunks). The HTTP/1.1 spec says that if both headers are present, Transfer-Encoding takes precedence. But Nginx and Express may prioritize differently. If Nginx uses Content-Length to decide where one request ends and the next begins, while Express uses Transfer-Encoding: chunked, an attacker can craft a single TCP request that Nginx treats as one request but Express treats as two — the second "request" arrives to Express prepopulated with the attacker's chosen headers and URL, as if it were sent by the previous user sharing the connection pool.

// VULNERABLE — RATELIMIT13-002 (concept illustration)
// Nginx uses Content-Length to delimit; Express uses Transfer-Encoding.
// Attacker sends one TCP request that Nginx thinks is one request,
// but Express processes as two — the "smuggled" prefix poisons the next user's request.

// Attacker HTTP/1.1 request (raw):
// POST /api/skills HTTP/1.1
// Host: skillaudit.dev
// Content-Length: 85           ← Nginx uses this: reads 85 bytes = body below
// Transfer-Encoding: chunked   ← Express uses this: reads chunks
//
// 51                           ← chunk size: 81 bytes (0x51)
// POST /api/admin/users HTTP/1.1
// X-Ignore: x
// 0
//                              ← Nginx thinks request ended after 85 bytes
//                              ← Express has processed a "prefix" of a second request
//                              ← Next legitimate user's request is appended to this prefix

// Nginx config fix:
// proxy_http_version 1.1;              — upgrade to HTTP/1.1 keep-alive to upstream
// proxy_set_header Connection "";      — strip connection header to prevent TE/CL ambiguity

// Express fix: reject requests with both Content-Length and Transfer-Encoding headers
app.use((req, res, next) => {
  const hasCL = 'content-length' in req.headers;
  const hasTE = req.headers['transfer-encoding']?.includes('chunked');

  // FIX: Reject ambiguous requests with both CL and TE headers
  if (hasCL && hasTE) {
    return res.status(400).json({ error: 'Ambiguous request framing' });
  }
  next();
});
// nginx.conf fix — RATELIMIT13-002
// Add to the server block that proxies to Express:

/*
server {
  listen 443 ssl;
  server_name skillaudit.dev;

  location /api/ {
    # FIX: Use HTTP/1.1 to upstream (keep-alive, removes CL/TE ambiguity)
    proxy_http_version 1.1;

    # FIX: Clear Connection header — prevents TE header being forwarded as hop-by-hop
    proxy_set_header Connection "";

    # FIX: Normalize headers — Nginx rewrites Content-Length based on its own body parsing
    # This prevents the CL/TE mismatch that enables smuggling
    proxy_request_buffering on;

    proxy_pass http://express_upstream;
  }
}
*/

// Express middleware to reject ambiguous CL+TE requests as defense-in-depth:
app.use((req, res, next) => {
  const cl = req.headers['content-length'];
  const te = req.headers['transfer-encoding'];
  if (cl && te) {
    return res.status(400).end();
  }
  next();
});

HTTP/2 eliminates TE-CL smuggling: HTTP/2 uses a completely different framing mechanism (binary frames with length prefix) that eliminates TE-CL ambiguity. If your registry supports HTTP/2 end-to-end (CDN → Nginx → Express with h2c), TE-CL request smuggling is not possible on that path. HTTP/2 request smuggling requires different techniques (H2.CL, H2.TE) and is a separate topic.

RATELIMIT13-003 — CDN cache poisoning via unkeyed Host header

CDN caches key responses on the URL path plus a set of headers configured in the cache key. By default, the Host header is included in the cache key — but if the CDN is misconfigured or the response does not include Vary: Host, different Host values may be collapsed into the same cache entry. An attacker who can get their request served first populates the CDN cache with a response that was keyed on a URL the CDN served to attacker.com but that CDN then serves to skillaudit.dev visitors — a denial of service or response poisoning attack.

// VULNERABLE — RATELIMIT13-003
// CDN cache key does not include Host header.
// Attacker sends: GET /api/skills/search?q=mcp-tools HTTP/1.1 Host: attacker.com
// CDN caches the response under key: /api/skills/search?q=mcp-tools (no Host component)
// Legitimate user sends: GET /api/skills/search?q=mcp-tools HTTP/1.1 Host: skillaudit.dev
// CDN serves the cached response from attacker.com key — same content, but:
// — if attacker manipulated the response (via a cache-buster or response injection),
//   the poisoned response is now served to legitimate users

// In Express, if the app uses req.hostname in constructing absolute URLs in responses:
app.get('/api/skills/search', (req, res) => {
  const nextPageUrl = `https://${req.hostname}/api/skills/search?q=${q}&page=${page + 1}`;
  // VULNERABLE: req.hostname is attacker-controlled via Host header
  // CDN caches this response with attacker.com in the pagination URL
  res.json({ skills, nextPage: nextPageUrl });
});
// FIXED — RATELIMIT13-003
// Fix 1: Never use req.hostname or req.host to construct absolute URLs in cached responses.
// Fix 2: Set Vary: Host on all API responses that might be cached.
// Fix 3: Configure CDN to include the Host header in cache keys.
// Fix 4: Validate the Host header against an allowlist before using it.

const ALLOWED_HOSTS = new Set(['skillaudit.dev', 'www.skillaudit.dev', 'app.skillaudit.dev']);

app.use((req, res, next) => {
  // FIX 4: Reject requests with unexpected Host header values
  const host = req.headers.host?.split(':')[0];  // strip port
  if (!ALLOWED_HOSTS.has(host)) {
    return res.status(421).json({ error: 'Misdirected request' });
  }
  next();
});

app.get('/api/skills/search', (req, res) => {
  const page = parseInt(req.query.page) || 1;
  const q = typeof req.query.q === 'string' ? req.query.q.slice(0, 100) : '';

  // FIX 1: Use hardcoded base URL, not req.hostname
  const BASE_URL = 'https://skillaudit.dev';
  const nextPageUrl = `${BASE_URL}/api/skills/search?q=${encodeURIComponent(q)}&page=${page + 1}`;

  // FIX 2: Vary: Host so CDN does not collapse multiple Host values into same cache entry
  res.setHeader('Vary', 'Host, Accept-Encoding');
  res.json({ skills: [], nextPage: nextPageUrl });
});

RATELIMIT13-004 — Nginx proxy_pass path injection via CRLF in skillId

When Nginx constructs the upstream request path by interpolating a URL parameter, CRLF characters (\r\n) in the parameter value terminate the request line and begin new headers. This is CRLF injection in the HTTP request to the upstream. The attacker sends a skillId like my-skill%0d%0aX-User-Id:%20admin-user-id. After Nginx decodes the URL and constructs the upstream path, the resulting HTTP request to Express contains an injected X-User-Id: admin-user-id header. If Express trusts this header for authorization (a common pattern when Nginx sets it via proxy_set_header X-User-Id $user_id), the attacker escalates to any user.

// VULNERABLE — RATELIMIT13-004
// Nginx proxy_pass with user-controlled skillId in path.
// skillId containing CRLF injects headers into the upstream request.

// nginx.conf (vulnerable):
/*
location ~ ^/api/skills/([^/]+)/preview$ {
  # VULNERABLE: $1 (skillId) is interpolated directly into proxy_pass
  # An attacker skillId of "my-skill\r\nX-Admin: true" injects a header
  proxy_pass http://express:3000/api/skills/$1/preview;
  proxy_set_header X-Real-IP $remote_addr;
}
*/

// What Express receives (after CRLF injection):
// GET /api/skills/my-skill HTTP/1.1
// X-Admin: true                     ← injected by attacker
//  /preview HTTP/1.0               ← remainder of original path as fragment
// X-Real-IP: 203.0.113.100
// FIXED — RATELIMIT13-004
// Fix 1: Validate skillId format with strict regex BEFORE Nginx interpolates into proxy_pass.
// Use Nginx map or if/return to reject invalid skillId format.
// Fix 2: Express middleware to reject requests with CRLF in any header value.
// Fix 3: Use Nginx's built-in $uri_encoded variables (Nginx already percent-encodes $uri).

// nginx.conf fix — validate skillId format before proxying:
/*
# FIX: Use a named capture group with strict character class — only [a-z0-9-]
location ~ ^/api/skills/([a-z0-9][a-z0-9-]{2,59})/preview$ {
  # FIX: $1 matches only [a-z0-9-] — no newlines, no special chars
  proxy_pass http://express:3000/api/skills/$1/preview;
  proxy_http_version 1.1;
  proxy_set_header Connection "";
  proxy_set_header X-Real-IP $remote_addr;
}

# Reject any skillId that does not match the strict pattern:
location ~ ^/api/skills/ {
  return 400 "Invalid skill ID format";
}
*/

// Express middleware defense-in-depth: reject CRLF in skillId
app.param('skillId', (req, res, next, skillId) => {
  // FIX: Strict validation on skillId — only lowercase alphanumeric and hyphen
  if (!/^[a-z0-9][a-z0-9-]{2,59}$/.test(skillId)) {
    return res.status(400).json({ error: 'Invalid skill ID format' });
  }
  next();
});

// Generic CRLF header injection defense:
app.use((req, res, next) => {
  for (const [key, value] of Object.entries(req.headers)) {
    // FIX: Reject any header containing CRLF sequences
    if (typeof value === 'string' && /[\r\n]/.test(value)) {
      return res.status(400).json({ error: 'Invalid header value' });
    }
  }
  next();
});

Nginx already blocks CRLF in proxy_pass in modern versions: Nginx 1.17.7+ rejects raw CRLF in location regex captures and proxy_pass variables. However, percent-encoded CRLF (%0d%0a) may still pass through if Nginx decodes the URL before the CRLF check, depending on configuration. The defense is to restrict the character class in the location regex to [a-z0-9-] — this eliminates CRLF, percent signs, and all other special characters entirely, regardless of Nginx version.

Summary — SA-SKL-RATELIMIT13 at a glance

PatternRoot causeFixSeverity
RATELIMIT13-001XFF header not stripped; trust proxy: true trusts all hopstrust proxy: 1; Nginx overwrites XFF; key on X-Real-IPHIGH
RATELIMIT13-002Nginx/Express TE-CL ambiguity enables request smugglingproxy_http_version 1.1; proxy_set_header Connection ""; reject CL+TECRITICAL
RATELIMIT13-003CDN caches responses without Vary: Host; req.hostname in responseHardcode base URL; Vary: Host; validate Host header allowlistHIGH
RATELIMIT13-004CRLF in skillId injects headers into Nginx proxy_pass pathStrict [a-z0-9-] regex in location; validate before interpolationCRITICAL

SkillAudit's infrastructure scanner tests reverse proxy configurations for XFF spoofing susceptibility, TE-CL request framing inconsistencies, CDN cache key analysis, and CRLF injection vectors in proxied paths. See also SA-SKL-RATELIMIT12 (ReDoS in regex rate limiting) and SA-SKL-SSRF19 (SSRF in health check endpoints).