Modern browsers trust each other across origins only when a long chain of header, event and DNS checks agrees. Real applications still get those checks wrong — a reflected Origin, a postMessage that trusts a substring of the sender, or an allowlist read before the second DNS lookup. A single gap lets another site read your account. Here you exploit all three classes in one target and watch each check fall.
What You'll Learn
Detect a CORS policy that reflects any Origin and allows credentials
Prove the impact of permissive CORS by reading authenticated data from a different origin
Read client-side JavaScript to find a postMessage listener with a weak origin check
Bypass a substring-based origin check to trigger a privileged action across origins
Identify a server-side allowlist that trusts a hostname instead of the IP it actually connects to
Use DNS rebinding to defeat that allowlist and reach an internal-only service
Why this lab is different
Server-Side Request Forgery & Attacks showed you how a server that fetches a URL on your behalf can be redirected at 127.0.0.1 or an internal IP. This lab attacks a harder target: an app whose checks look correct on paper. It checks the Origin header before answering a cross-origin request. It checks event.origin before trusting a postMessage. It checks a webhook's hostname before fetching it. Each check has a gap. Each gap is a different class of browser-trust failure: a reflected Origin with credentials enabled, a substring match instead of an exact one, and a hostname validated once but resolved again later.
Prerequisites
Finish Server-Side Request Forgery & Attacks first. You need the idea of a server fetching a URL on your behalf before you attack the allowlist that is supposed to stop it.
JavaScript Deobfuscation is useful but not required — this lab's JavaScript is not obfuscated, only unread.
Comfort with curl, basic Python 3, and editing /etc/hosts.
Lab setup
Item
Purpose
curl
Sends crafted requests and reads response headers
python3 (standard library only)
Serves attacker-controlled pages and runs the DNS responder in Step 7
dig
Confirms what a DNS query actually returns
A browser with developer tools
Loads the app and the proof-of-concept pages, inspects requests
Build the target
KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a small team dashboard, RebindCo, that you build. The addresses 10.0.9.50 and 10.0.9.51 and the domain rebindco.example.com below are the examples of this lab. Replace them with your own.
Your target must have these parts:
Host
Role
dashboard.rebindco.example.com (10.0.9.50)
The RebindCo web app
10.0.9.51:9091
An internal-only metrics page, reachable only from the app's own backend network
A login that creates your own account and a session cookie. Sign yourself up; no password is handed to you.
GET /api/account, session-cookie authenticated, returning JSON such as {"email":"...","plan":"team","apiKey":"rbc_live_..."}. Make the app set Access-Control-Allow-Origin to whatever Origin header it received, and Access-Control-Allow-Credentials: true, with no allowlist check. This is the flaw of Steps 1 to 3.
/static/app.js, served statically, containing exactly this listener:
window.addEventListener('message', function (event) { if (event.origin.indexOf('rebindco.example.com') !== -1) { if (event.data && event.data.type === 'setEmail') { updateAccountEmail(event.data.email); } }});
The substring check, instead of an exact match, is the flaw of Steps 4 and 5.
POST /api/integrations (take name and url, reject a URL that resolves to a private address at creation time, otherwise return {"id":N,"status":"validated"}) and GET /api/integrations/{id} (return the stored result as lastPreview). Run a background worker that polls each stored URL every 15 seconds and re-resolves its hostname on every poll, with no re-check against the private-address rule. This is the flaw of Steps 6 and 7.
The internal metrics page at 10.0.9.51:9091/metrics returning plain text, for example backend_build_info{version="4.2.1"} 1\nbackend_internal_host="rebindco-db-01.corp.local"\n.
A DNS zone rebind.rebindco.example.com delegated to your own Kali attack box, so a DNS responder you run there becomes authoritative for it. On a single-machine lab, point your test resolver (for example dnsmasq on the app's host) to forward queries for that zone to your Kali box's address on port 53.
No public training target combines a reflected-Origin CORS bug, a substring postMessage check and a DNS-rebinding allowlist bypass, so write this small app yourself; keep each flaw exactly as described above so the steps work. Take a snapshot of each virtual machine (or note the container state) before Step 1.
Authorized-lab only. Run every command in this lab only against a target that you own or have written permission to test, here 10.0.9.50 and 10.0.9.51 as you set them up, using the account you created on it. Do not point CORS, postMessage, or DNS-rebinding techniques at a real site you do not own or do not have written permission to test.
Step 1: Map the CORS policy
1
Send the same request with different Origin headers
A correct CORS (Cross-Origin Resource Sharing) policy only ever allows the app's own origin. Send a request with an origin that has no business being allowed, and read the response headers, not the body.
# Your own session cookie, from the browser's dev tools after logging inSESSION="s%3Aexample-session-token"curl -s -i -H "Origin: https://evil.example.com" \ -H "Cookie: session=${SESSION}" \ "https://dashboard.rebindco.example.com/api/account" | head -n 12
Access-Control-Allow-Origin reflects whatever Origin you sent, instead of checking it against an allowlist. Access-Control-Allow-Credentials: true tells the browser it may read this response from a cross-origin page even with your session cookie attached. A spec-compliant browser never allows Access-Control-Allow-Origin: * together with credentials, so a vulnerable app has to reflect the value — that reflection is the signature to look for.
Step 2: Confirm the CORS misconfiguration is exploitable
2
Repeat the request with an origin you do not own
Reflection alone is not proof. Confirm the app answers the same way for an origin that was never on any allowlist.
Every origin gets the same answer. There is no allowlist at all — the app trusts whatever the browser says Origin was. Any page you can get a signed-in user to open can now read /api/account with that user's cookie, including the apiKey field.
Sign in to continue
9 more sections are for signed-in members. It is free: sign in with Google.