CTF web challenges
When it applies
The handout is a URL (sometimes plus source). The goal is almost always to read a flag file
(/flag, /flag.txt, an env var, or a DB row) — so every bug you find should be steered toward
read a file, run a command, or become admin. This skill is the CTF routing layer; work the
deep techniques with web-ssti, web-ssrf, web-sqli, web-lfi-path-traversal, web-auth-jwt,
web-deserialization, web-command-injection, web-file-upload.
Why it works
CTF web challenges strip an app to one intended bug plus decorations, so the surface is small and
the bug is findable by enumeration, not luck. Provided source turns black-box guessing into
reading comprehension; the framework banner (Flask/PHP/Express) predicts the bug class before you
send a request.
Method
- Enumerate the obvious first (5 minutes).
curl -sS -D- the root; read every HTML comment,
JS file, cookie, and header. Hit robots.txt, /sitemap.xml, common admin paths, and run a
quick ffuf -w raft-small-words -u <url>/FUZZ. Check the HTTP methods (OPTIONS, try
PUT/POST where GET works). CTF apps hide routes in comments and robots more than real ones.
- Grab source if it exists — it usually does.
- Provided zip /
Dockerfile: read it; the bug is visible, and the Dockerfile tells you the
flag's location and any sandbox (read-only fs, seccomp).
.git exposed: git-dumper <url>/.git out/ then read history (recon-github-code-leaks).
- Backups:
index.php~, index.php.bak, .index.php.swp, app.py.bak — ffuf for them.
- PHP filters as source oracle:
?page=php://filter/convert.base64-encode/resource=index
(web-lfi-path-traversal).
- Flask/Werkzeug debugger page exposed → the PIN is crackable from machine-id + boot-id +
username (leak them via an LFI) or is printed in console output you can reach.
- Work the framework's favorite bug:
- Flask/Jinja2 → SSTI:
{{7*7}} then climb to {{ self.__init__.__globals__ }} /
config / cycler.__init__.__globals__.os.popen('cat /flag').read(). Filter bypasses:
|attr(), request-args gadgets, hex/octal string building (web-ssti,
web-python-sandbox-escape).
- PHP → the quirks are the challenge: loose comparison type juggling (
== with "0e..."
magic hashes, 0 == "password", array params to skip strcmp/md5 checks — ?a[]=1),
wrapper chains (php://filter, data://, phar://), preg_replace /e, unserialize
with a provided class → POP chain (web-deserialization).
- Node/Express → prototype pollution (
web-prototype-pollution), SSTI in EJS/Pug,
eval on JSON fields, NoSQL injection ({"$gt":""} on login forms).
- Play the cookie games. Flask session cookie →
flask-unsign --decode, brute the secret
(flask-unsign --unsign --wordlist rockyou.txt) then re-sign {'is_admin': True}. JWT →
alg:none, RS256→HS256 confusion with a reachable public key, weak HMAC secret brute
(web-auth-jwt). Homegrown base64/hex cookies → decode, flip the role field, handle the MAC
with crypto-oracle-attacks.
- SSRF, the CTF shape. Any URL fetcher (webhook tester, PDF renderer, image proxy) →
http://127.0.0.1/ for internal-only routes, http://169.254.169.254/ only when the Docker
setup hints cloud, file:///flag, and gopher:// to hit internal Redis/MySQL
(web-ssrf, web-ssrf-gopher-redis-rce). In CTF, the internal service on a weird port is
the challenge — scan 127.0.0.1 ports through the SSRF.
- Chain to the flag. One primitive rarely suffices: LFI → source → secret → signed cookie →
admin panel → SSTI → RCE →
cat /flag. Treat each confirmed bug as a key that unlocks the next
stage (exploit-chaining).
Gotchas
{{7*7}} rendering as {{7*7}} doesn't rule out SSTI — some challenges only evaluate in
error pages, emails, or PDF exports. Try the sink contexts, and try ${7*7}, #{7*7}, <%= 7*7 %>
for other engines.
- PHP
assert/eval challenges filter obvious words; build strings dynamically
($_GET['x']($_GET['y']) with x=system&y=cat /flag) instead of fighting the blocklist.
- Provided source != deployed source occasionally — verify a behavior against the live app
before building an exploit on the reading.
- The flag may need root — RCE as www-data with
/flag readable only by root means a second
stage: look for setuid binaries, cron, or a SUID flag-reader you must exploit (privesc domain).
- Rate-limited login / captcha in CTF usually hides race conditions (
web-race-conditions) or
SQLi in the login query, not a brute-force task.
Verify success
The flag string in the correct format, read from the target (file, env, or DB) — not a local
reproduction. If you got RCE, id; cat /flag output is the proof.
References
Deep techniques: web-ssti, web-ssrf, web-auth-jwt, web-deserialization,
web-lfi-path-traversal, web-python-sandbox-escape, web-command-injection, web-sqli;
source-leak hunting: recon-content-discovery, recon-github-code-leaks; token attacks:
crypto-oracle-attacks. Triage via ctf-methodology.
1---2name: ctf-web3description: >4 CTF web challenge playbook — the recurring shapes jeopardy web challenges take: source disclosure5 (.git, backups, flask debug), SSTI/SSRF in their CTF forms, PHP quirks (type juggling, wrappers,6 filters), cookie/JWT games, and chained primitives to read /flag. Load on any CTF challenge whose7 handout is a URL. Signals: "web" category, flask/werkzeug or PHP banner, /flag or flag.txt on the8 box, robots.txt, provided app.py/index.php source, JWT or flask session cookie.9domain: ctf10type: methodology11stability: learning12modes: [pentest, bugbounty]13severity: high14owasp: [A03:2021-Injection, A01:2021-Broken-Access-Control]15cwe: [CWE-94, CWE-918, CWE-697]16tools: [curl, burp, flask-unsign, jwt-tool, ffuf]17schema_version: 118metadata:19 source: https://skillmd.com/skills/noorqureshi/ctf-web20---2122# CTF web challenges2324## When it applies25The handout is a URL (sometimes plus source). The goal is almost always to read a flag file26(`/flag`, `/flag.txt`, an env var, or a DB row) — so every bug you find should be steered toward27*read a file*, *run a command*, or *become admin*. This skill is the CTF routing layer; work the28deep techniques with `web-ssti`, `web-ssrf`, `web-sqli`, `web-lfi-path-traversal`, `web-auth-jwt`,29`web-deserialization`, `web-command-injection`, `web-file-upload`.3031## Why it works32CTF web challenges strip an app to one intended bug plus decorations, so the surface is small and33the bug is findable by *enumeration*, not luck. Provided source turns black-box guessing into34reading comprehension; the framework banner (Flask/PHP/Express) predicts the bug class before you35send a request.3637## Method381. **Enumerate the obvious first (5 minutes).** `curl -sS -D-` the root; read every HTML comment,39 JS file, cookie, and header. Hit `robots.txt`, `/sitemap.xml`, common admin paths, and run a40 quick `ffuf -w raft-small-words -u <url>/FUZZ`. Check the HTTP methods (`OPTIONS`, try41 `PUT`/`POST` where GET works). CTF apps hide routes in comments and robots more than real ones.422. **Grab source if it exists — it usually does.**43 - Provided zip / `Dockerfile`: read it; the bug is visible, and the Dockerfile tells you the44 flag's location and any sandbox (read-only fs, seccomp).45 - `.git` exposed: `git-dumper <url>/.git out/` then read history (`recon-github-code-leaks`).46 - Backups: `index.php~`, `index.php.bak`, `.index.php.swp`, `app.py.bak` — ffuf for them.47 - PHP filters as source oracle: `?page=php://filter/convert.base64-encode/resource=index`48 (`web-lfi-path-traversal`).49 - Flask/Werkzeug debugger page exposed → the PIN is crackable from machine-id + boot-id +50 username (leak them via an LFI) or is printed in console output you can reach.513. **Work the framework's favorite bug:**52 - **Flask/Jinja2** → SSTI: `{{7*7}}` then climb to `{{ self.__init__.__globals__ }}` /53 `config` / `cycler.__init__.__globals__.os.popen('cat /flag').read()`. Filter bypasses:54 `|attr()`, request-args gadgets, hex/octal string building (`web-ssti`,55 `web-python-sandbox-escape`).56 - **PHP** → the quirks are the challenge: loose comparison type juggling (`==` with `"0e..."`57 magic hashes, `0 == "password"`, array params to skip `strcmp`/`md5` checks — `?a[]=1`),58 wrapper chains (`php://filter`, `data://`, `phar://`), `preg_replace /e`, unserialize59 with a provided class → POP chain (`web-deserialization`).60 - **Node/Express** → prototype pollution (`web-prototype-pollution`), SSTI in EJS/Pug,61 `eval` on JSON fields, NoSQL injection (`{"$gt":""}` on login forms).624. **Play the cookie games.** Flask session cookie → `flask-unsign --decode`, brute the secret63 (`flask-unsign --unsign --wordlist rockyou.txt`) then re-sign `{'is_admin': True}`. JWT →64 `alg:none`, RS256→HS256 confusion with a reachable public key, weak HMAC secret brute65 (`web-auth-jwt`). Homegrown base64/hex cookies → decode, flip the `role` field, handle the MAC66 with `crypto-oracle-attacks`.675. **SSRF, the CTF shape.** Any URL fetcher (webhook tester, PDF renderer, image proxy) →68 `http://127.0.0.1/` for internal-only routes, `http://169.254.169.254/` only when the Docker69 setup hints cloud, `file:///flag`, and `gopher://` to hit internal Redis/MySQL70 (`web-ssrf`, `web-ssrf-gopher-redis-rce`). In CTF, the internal service on a weird port *is*71 the challenge — scan `127.0.0.1` ports through the SSRF.726. **Chain to the flag.** One primitive rarely suffices: LFI → source → secret → signed cookie →73 admin panel → SSTI → RCE → `cat /flag`. Treat each confirmed bug as a key that unlocks the next74 stage (`exploit-chaining`).7576## Gotchas77- **`{{7*7}}` rendering as `{{7*7}}` doesn't rule out SSTI** — some challenges only evaluate in78 error pages, emails, or PDF exports. Try the sink contexts, and try `${7*7}`, `#{7*7}`, `<%= 7*7 %>`79 for other engines.80- **PHP `assert`/`eval` challenges** filter obvious words; build strings dynamically81 (`$_GET['x']($_GET['y'])` with `x=system&y=cat /flag`) instead of fighting the blocklist.82- **Provided source != deployed source** occasionally — verify a behavior against the live app83 before building an exploit on the reading.84- **The flag may need root** — RCE as www-data with `/flag` readable only by root means a second85 stage: look for setuid binaries, cron, or a SUID flag-reader you must exploit (`privesc` domain).86- **Rate-limited login / captcha** in CTF usually hides race conditions (`web-race-conditions`) or87 SQLi in the login query, not a brute-force task.8889## Verify success90The flag string in the correct format, read from the target (file, env, or DB) — not a local91reproduction. If you got RCE, `id; cat /flag` output is the proof.9293## References94Deep techniques: `web-ssti`, `web-ssrf`, `web-auth-jwt`, `web-deserialization`,95`web-lfi-path-traversal`, `web-python-sandbox-escape`, `web-command-injection`, `web-sqli`;96source-leak hunting: `recon-content-discovery`, `recon-github-code-leaks`; token attacks:97`crypto-oracle-attacks`. Triage via `ctf-methodology`.