How 0xdimas/nginx-rift-private-lab works
1. What this repo is
- This is a security research and exploit-lab repository for an NGINX heap overflow PoC, with a strong focus on ASLR bypass techniques.
- It is organized around one vulnerable NGINX target, one HTTP-accessible file-read primitive, and multiple exploit/assessment runners that chain those pieces together.
2. Primary runtime boundary
- The architecture is split between an attacker/controller side (Python tooling in the repo) and a target side (NGINX + PHP application stack in containers or a VM).
- The attacker never talks to the target through an internal API; everything is driven by HTTP requests to the same exposed listener and by reading files exposed through the file-read primitive.
3. Main orchestration entry point
- nginx_rifter.py is the current central orchestrator.
- Its role is assessment-first: it profiles the target, tests the file-read primitive, fingerprints the environment, discovers nginx worker/process state, and only runs the exploit when explicitly asked.
- It is also the current integrated exploit entry point for the coreless proc-mem path.
4. Legacy exploit path
- nginx_rifter_core_v2_1.py preserves the older core-guided path, where a worker crash is used to create a readable core file that is then mined for exploit data.
- Older demo_ctf_exploit_v1_* scripts and poc.py represent earlier operator-facing or demo-oriented runners for the same underlying vulnerability chain.
- The repo keeps these for comparison, reproducibility, and artifact-driven demos, but they are no longer the preferred architecture.
5. Exploit data flow
- The exploit chain is: vulnerable nginx request handling → heap overflow during rewrite processing → heap shaping and target selection → memory disclosure via LFI/procfs → derivation of runtime addresses → final code execution verification.
- The default ASLR bypass path uses PHP file reads to access nginx worker /proc/<pid>/maps, mapped libc, and /proc/<pid>/mem, then computes the runtime system() address and searches live memory for usable heap targets.
- The legacy path replaces live procfs reads with a crash core dump.
6. Target-side lab composition
- The env/ directory contains the deployment layer: Dockerfiles, Compose files, nginx configs, PHP endpoints, and entrypoint scripts.
- Important lab endpoints include the vulnerable nginx route, /lfi.php for local file reads, and /phpinfo.php for environment disclosure.
- env/server.py and the nginx/PHP configs define the same-port topology the exploit expects: the vulnerable request path and the disclosure primitive must be reachable from the same target service.
7. Deployment and repro environments
- setup.sh, Vagrantfile, and vagrant/provision.sh support repeatable lab setup across containerized and VM-based environments.
- The repo explicitly supports both a deterministic Docker-style reproduction and a more realistic ASLR-enabled VM-style setup.
- The architecture changes depending on environment only in the disclosure assumptions, not in the high-level exploit flow.
8. Research probes and alternate leak search
- tools/non_lfi_leak_probe.py and tools/non_lfi_active_response_probe.py are negative/research probes that test whether nginx itself leaks useful state without LFI.
- tools/lfi_proc_mem_scan.py and tools/proc_mem_coreless_exploit.py are more specialized harnesses for the proc-mem research path.
- These tools sit on the research side of the boundary; they are not part of the target stack.
9. Knowledge base and constraints
- known_layout_patterns.json appears to store empirically derived layout patterns used to recognize or validate memory layouts across runs.
- The docs/ directory is the project’s evidence and methodology layer: plans, findings, test logs, ASLR notes, and recording workflows.
- This repo is therefore not just exploit code; it is also a reproducibility and analysis workspace.
10. Artifacts as first-class outputs
- The artifacts/ directory contains recorded terminal sessions, JSON run outputs, and verification logs from multiple exploit iterations.
- These artifacts are important to the architecture because they document the evolution of the chain and provide proof of behavior across variants.
- They also show that the repo is built as a research lab, not merely a single-shot PoC.
11. Operational shape of the current tool
- nginx_rifter.py is parameterized around the target host/port and a pluggable file-read template, so it can adapt to different vulnerable deployments.
- That makes the file-read primitive a clean abstraction boundary: the exploit logic consumes “read arbitrary path/range” capability without hard-coding a specific LFI implementation.
- The rest of the chain assumes only that the primitive can reach the relevant process files and read enough data to resolve addresses.
12. What an architecture diagram should emphasize
- Show three layers: the target web stack, the file-read disclosure channel, and the Python exploit/assessment controller.
- Within the controller, distinguish the current nginx_rifter.py path from the legacy core-guided and demo scripts.
- The crucial dependency arrows are: HTTP request spray to nginx, disclosure reads via PHP/LFI to procfs and libc, then address derivation back into the final exploit attempt and verification.
Main entry points: nginx_rifter.py nginx_rifter.py · nginx.conf nginx stack · server.py rewrite overflow · lfi.php lfi.php
Components 21
Controller
Python-side assessment, disclosure, and exploit orchestration
- nginx_rifter.py · Current central orchestrator for assessment-first profiling and coreless proc-mem exploitation
nginx_rifter.py - core_v2_1 · Older core-guided exploit path that mines crash cores for data
nginx_rifter_core_v2_1.py - demo_ctf · Operator-facing demo runners for earlier exploit iterations
demo_ctf_exploit.py - ctf_remote · Remote exploit entrypoint for target execution
ctf_remote_exploit.py - poc.py · Minimal proof-of-concept exploit harness
poc.py - proc_mem_scan · Specialized harness for proc-mem disclosure research
tools/lfi_proc_mem_scan.py - coreless exploit · Specialized coreless exploitation harness using live procfs reads
tools/proc_mem_coreless_exploit.py - lfi probe · Tests for useful leaks without LFI-assisted disclosure
tools/non_lfi_leak_probe.py - active probe · Tests whether nginx responses reveal exploitable state
tools/non_lfi_active_response_probe.py
Target Lab
NGINX/PHP deployment and vulnerable request path
- nginx stack · Target-side NGINX and PHP service exposed on one listener
env/nginx.conf - rewrite overflow · Vulnerable NGINX request handling and heap-shaping path
env/server.py - lfi.php · HTTP-accessible arbitrary file read used to reach procfs and libc mappings
env/lfi.php - phpinfo.php · Supplementary endpoint for environment fingerprinting
env/phpinfo.php - entrypoints · Container startup scripts for lab services and modes
env/entrypoint.sh
Environments
Container and VM repro/deployment scaffolding
- compose files · Docker Compose variants for standard, LFI, CTF, and non-LFI leak modes
env/docker-compose.yml - Dockerfiles · Container build definitions for the lab images
env/Dockerfile - Vagrant · VM-based reproducible lab setup and provisioning
Vagrantfile - setup.sh · Top-level helper for repeatable lab setup
setup.sh
Research
Support tooling, notes, and captured artifacts
- patterns · Empirical layout patterns used to recognize and validate memory layouts
known_layout_patterns.json - docs · Plans, findings, logs, and workflow notes for the research lab
docs/CORELESS_ASLR_PLAN.md - artifacts · Recorded sessions, JSON outputs, and verification logs from exploit iterations
artifacts/nginx_rifter_20260515-v2-final.json
Connections 25
- nginx_rifter.py → rewrite overflow: sprays requests to · Drives the vulnerable request-handling path against the target
- nginx_rifter.py → lfi.php: reads via · Uses the file-read primitive as the disclosure boundary
- nginx_rifter.py → phpinfo.php: fingerprints via · Collects environment details for ASLR and process-state inference
- nginx_rifter.py → patterns: matches layouts with · Consults empirically derived layout patterns during assessment
- nginx_rifter.py → artifacts: records results in · Writes assessment, derive, and exploit outputs as artifacts
- nginx_rifter.py → coreless exploit: invokes path · Integrated current exploit path for live proc-mem ASLR bypass
- core_v2_1 → rewrite overflow: sprays requests to · Uses the same overflow chain but with legacy core-guided recovery
- core_v2_1 → artifacts: stores runs in · Captures legacy core-guided iterations and evidence
- demo_ctf → rewrite overflow: exercises · Earlier operator-facing demo execution of the vulnerability chain
- ctf_remote → rewrite overflow: targets · Remote exploit runner aimed at the same vulnerable request path
- poc.py → rewrite overflow: demonstrates · Minimal PoC for the underlying heap overflow
- proc_mem_scan → lfi.php: scans through · Specialized scanner for proc-mem disclosure over the file-read primitive
- coreless exploit → lfi.php: derives from · Reads live procfs data through the disclosure channel
- lfi probe → nginx stack: tests · Research probe for nginx-native leaks without LFI
- active probe → nginx stack: tests · Research probe for active-response leakage from nginx
- nginx stack → rewrite overflow: contains · Target web stack exposes the vulnerable handling path
- nginx stack → lfi.php: exposes · Same listener also exposes the file-read endpoint
- nginx stack → phpinfo.php: exposes · Same target service exposes environment disclosure
- entrypoints → nginx stack: starts · Container entrypoints bootstrap the target service
- compose files → entrypoints: orchestrates · Compose variants define which entrypoint and service mode is launched
- Dockerfiles → compose files: builds · Image definitions underpin the deployment variants
- Vagrant → compose files: mirrors · VM repro path mirrors the containerized lab topology
- setup.sh → Vagrant: bootstraps · Top-level setup helper prepares the VM-based lab workflow
- docs → nginx_rifter.py: documents · Methodology and findings track the current orchestrator and exploit flow
- artifacts → docs: evidence for · Captured runs support the project notes, plans, and logs