A local security research workstation for studying HTTP/1.1 and HTTP/2 request desynchronization.
Real byte-level protocol engine · Differential analysis · 7 attack scenarios · Hardened mode comparison
RIFT is a fully local HTTP desynchronization research platform built for authorized security research and education. It implements a real HTTP/1.1 protocol parser that computes byte-level framing decisions and performs differential analysis — comparing how a simulated frontend proxy and backend server each interpret the same byte stream.
Every attack demonstration operates against intentionally configured local simulation components with synthetic credentials (DEMO_ prefix). No external traffic is ever generated.
Unlike dashboard-only tools, RIFT's protocol engine:
- Parses actual HTTP byte streams — Content-Length counting, chunked transfer decoding, ambiguous header detection
- Computes divergence deterministically —
compare(frontend_interpretation, backend_interpretation)identifies exact byte offsets where parsing disagrees - Extracts smuggled regions — isolates the bytes a backend sees as a new request that the frontend considered part of the previous one
- Enforces a security boundary — the test harness fails closed; only
lab.rift(synthetic) is ever targeted
| ID | Name | Protocol | Technique | Severity |
|---|---|---|---|---|
cl-te |
CL.TE Desynchronization | HTTP/1.1 | Frontend reads Content-Length; backend reads Transfer-Encoding | High |
te-cl |
TE.CL Desynchronization | HTTP/1.1 | Frontend reads Transfer-Encoding; backend reads Content-Length | High |
cl-0 |
CL.0 Desynchronization | HTTP/1.1 | Zero Content-Length tricks backend into tunneling body | Medium |
client-side |
Client-Side Desync | HTTP/1.1 | Browser-initiated desync without a reverse proxy | High |
pause-based |
Pause-Based Desync | HTTP/1.1 | Timeout differences cause boundary disagreement | Medium |
h2-cl |
H2.CL Downgrade | HTTP/2 → HTTP/1.1 | Injected Content-Length survives HTTP/2 downgrade | Experimental |
h2-te |
H2.TE Downgrade | HTTP/2 → HTTP/1.1 | Injected Transfer-Encoding survives HTTP/2 downgrade | Experimental |
┌─────────────────────────────────────────────────────────────────┐
│ Browser · React + TypeScript + Vite · localhost:5173 │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Research │ │ Byte Stream │ │ Scenario Library / │ │
│ │ Lab │ │ Visualizer │ │ Runs / Notes / Docs │ │
│ └──────┬───────┘ └──────┬───────┘ └──────────┬───────────┘ │
│ │ REST + WebSocket │ │ │
└─────────┼────────────────────────────┼───────────┘ │
▼ ▼
┌─────────────────────────────────────────────────────────────────┐
│ FastAPI · localhost:8000 │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Protocol Engine (real byte-level parsing) │ │
│ │ ┌──────────────────┐ ┌─────────────────────────────┐ │ │
│ │ │ framing.py │ │ differential.py │ │ │
│ │ │ parse_stream() │──▶│ compare(fe, be) → result │ │ │
│ │ │ detect_framing()│ │ extracts smuggled_region │ │ │
│ │ └──────────────────┘ └─────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Simulation Layer (no Docker needed) │ │
│ │ ProxyProfile(nginx | haproxy | caddy) │ │
│ │ BackendProfile(flask | fastapi) │ │
│ │ Stream builders per scenario → exact byte sequences │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ SQLite (rift.db) — Runs · ResearchNotes · Evidence │
└─────────────────────────────────────────────────────────────────┘
|
Research Lab — configure proxy/backend, run any scenario, watch events stream live |
Byte Stream Visualizer — 4 display modes with byte-semantic highlighting |
|
Scenario Library — 7 attack variants, filter by protocol |
Reports — aggregate divergence analysis by scenario and proxy |
|
Topology — simulated proxy chain visualizer |
Research Notes — linked to runs, searchable, markdown-enabled |
- Python 3.11+
- Node.js 20+
git clone https://github.com/het-P301204/rift.git
cd riftcd apps/api
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txt
uvicorn main:app --reload --port 8000cd apps/web
npm install
npm run devcd apps/api
python seed_demo.pyThis populates 12 synthetic runs and 5 research notes — no real requests are ever made.
rift/
├── apps/
│ ├── api/ # FastAPI backend
│ │ ├── main.py # Routes, WebSocket handler
│ │ ├── protocol/
│ │ │ ├── models.py # FramingMode, HttpMessage, Interpretation, Divergence
│ │ │ └── framing.py # Byte-level HTTP parser
│ │ ├── analysis/
│ │ │ └── differential.py # compare(frontend, backend) → DifferentialResult
│ │ ├── simulation/
│ │ │ └── lab.py # ProxyProfile, BackendProfile, stream builders
│ │ ├── scenarios/
│ │ │ └── loader.py # YAML fixture loader
│ │ ├── db/
│ │ │ └── models.py # Run, ResearchNote, Evidence ORM models
│ │ ├── requirements.txt
│ │ └── seed_demo.py # Demo data seeder
│ └── web/ # React + TypeScript + Vite frontend
│ └── src/
│ ├── pages/ # 14 pages
│ ├── components/ # Layout, ByteViewer, EventTimeline, ...
│ ├── store/ # Zustand lab store
│ └── lib/api.ts # Axios client + WebSocket helper
├── fixtures/ # YAML scenario definitions
│ ├── cl-te/scenario.yaml
│ ├── te-cl/scenario.yaml
│ ├── cl-0/scenario.yaml
│ ├── h2-cl/scenario.yaml
│ ├── h2-te/scenario.yaml
│ ├── client-side/scenario.yaml
│ ├── pause-based/scenario.yaml
│ └── hardened/hardened.yaml
├── tests/
│ └── backend/
│ ├── conftest.py
│ ├── test_framing.py # 19 protocol engine tests
│ └── test_simulation.py # 13 simulation tests
├── docs/
│ ├── architecture.md
│ └── threat-model.md
└── scripts/
└── start.ps1 # PowerShell one-shot launcher
HTTP/1.1 has two ways to delimit a request body:
Content-Length: 13
Hello, world!Transfer-Encoding: chunked
d\r\n
Hello, world!\r\n
0\r\n
\r\nRFC 7230 §3.3.3 says Transfer-Encoding takes priority when both are present — but not every server agrees. When a reverse proxy (frontend) uses one rule and the backend uses another, the same byte stream is interpreted as different numbers of requests. This is desynchronization.
Attacker sends (147 bytes):
POST /donate HTTP/1.1\r\n
Host: lab.rift\r\n
Content-Length: 136\r\n ← frontend stops here (reads 136 bytes)
Transfer-Encoding: chunked\r\n
\r\n
0\r\n ← backend stops here (terminal chunk)
\r\n
GET /admin HTTP/1.1\r\n ← backend sees this as a NEW request
Host: lab.rift\r\n ← 49 bytes smuggled into the next
RIFT's engine parses this stream from both the proxy's and backend's perspective and reports:
{
"severity": "high",
"frontend_count": 1,
"backend_count": 2,
"divergent_byte_offset": 92,
"smuggled_region_hex": "474554202f61646d696e..."
}Toggle Hardened in the lab to apply documented defensive settings (rejecting requests with both CL and TE headers present). The engine emits HARDENED_BLOCKED before the stream ever reaches the parsing stage, proving the mitigation works.
| Method | Path | Description |
|---|---|---|
GET |
/api/scenarios |
List all scenarios |
GET |
/api/scenarios/{id} |
Single scenario detail |
GET |
/api/runs |
Run history (paginated) |
GET |
/api/runs/{id} |
Run detail with events |
DELETE |
/api/runs |
Clear all run history |
GET |
/api/stats |
Aggregate statistics |
GET |
/api/topology |
Simulated network topology |
GET |
/api/notes |
All research notes |
POST |
/api/notes |
Create a note |
PATCH |
/api/notes/{id} |
Update a note |
DELETE |
/api/notes/{id} |
Delete a note |
GET |
/api/evidence/{run_id} |
Evidence artifacts for a run |
GET |
/api/health |
Health check |
WS |
/ws/run |
Stream scenario execution events |
Send a JSON payload to start a run:
{
"scenario_id": "cl-te",
"proxy": "nginx",
"backend": "flask",
"hardened": false,
"timing_ms": 0
}Events streamed back:
INIT → PROXY_READY → BACKEND_READY → CLIENT_SENT
→ PROXY_PARSED → BACKEND_PARSED → DIVERGENCE → DONE
or in hardened mode:
INIT → PROXY_READY → HARDENED_BLOCKED → DONE
cd rift
pip install pytest pytest-asyncio
pytest tests/ -vtests/backend/test_framing.py::test_detect_cl_framing PASSED
tests/backend/test_framing.py::test_detect_te_framing PASSED
tests/backend/test_framing.py::test_ambiguous_framing_both_headers PASSED
...
tests/backend/test_simulation.py::test_clte_scenario_produces_divergence PASSED
tests/backend/test_simulation.py::test_hardened_mode_blocks_clte PASSED
...
32 passed in 1.43s
RIFT is designed for local, authorized research only.
| ✅ Allowed | ❌ Never Allowed |
|---|---|
| Local simulation components | External URLs |
DEMO_ prefix synthetic credentials |
Real credentials |
| Controlled lab environment | Public internet |
| Authorized pentesting research | Production infrastructure |
Containment guarantees enforced by the codebase:
- All stream builders target
lab.riftonly — enforced by testtest_only_lab_targets_allowed - Victim credentials always use
DEMO_prefix — enforced by testtest_demo_credentials_are_synthetic scenario_idpath-traversal protection — resolved paths validated againstFIXTURES_DIR- No subprocess calls, no outbound requests, no credential storage
See docs/threat-model.md for a full threat analysis.
| Layer | Technology |
|---|---|
| Frontend | React 19 · TypeScript 5.7 · Vite 8 |
| State | Zustand · @tanstack/react-query |
| Styling | Tailwind CSS v3 · Framer Motion |
| Icons | Lucide React |
| Backend | FastAPI 0.142 · Python 3.11+ |
| Database | SQLite via SQLAlchemy 2 |
| Protocol | Custom byte-level HTTP parser (no external libs) |
| Testing | pytest + pytest-asyncio |
RIFT uses a graphite-dark base with semantic accent colors:
| Token | Hex | Meaning |
|---|---|---|
vermilion |
#E85D4A |
Divergence / attack |
sage |
#7FA083 |
Hardened / safe |
golden |
#D8AA42 |
Warning / experimental |
iris |
#9586B8 |
Frontend / proxy |
plum |
#4B3A4F |
Backend server |
graphite |
#171717 |
Surface / background |
Byte semantic classes: .byte-header (iris) · .byte-body (golden) · .byte-chunk-size (plum) · .byte-smuggled (vermilion, left border) · .byte-trailer
This is a research tool — contributions that add scenarios, improve protocol accuracy, or strengthen the simulation layer are welcome.
- Fork the repo
- Run tests:
pytest tests/ -v - Add tests for any new scenario or engine change
- Open a pull request
- PortSwigger Web Security Academy — HTTP Request Smuggling
- RFC 7230 — HTTP/1.1 Message Syntax and Routing
- RFC 9110 — HTTP Semantics
- HTTP/2 Desync Attacks (James Kettle, 2021)
- Browser-Powered Desync Attacks (James Kettle, 2022)
Built for security research and education.
All demonstrations operate in a controlled local simulation environment.






