CORS Vulnerability with Trusted Null Origin
The application's CORS policy trusts the 'null' origin, allowing any sandboxed iframe or local file to make cross-origin requests with credentials. An attacker can host a malicious page that loads a sandboxed iframe, which then requests the victim's account details and exfiltrates the API key.
Published on bashoverflow.medium.com
This lab demonstrates a security flaw in Cross-Origin Resource Sharing (CORS) configuration, specifically when a website incorrectly trusts the "null" origin. In secure setups, web servers must validate the Origin header to ensure that only legitimate and authorized domains can request resources.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The server's CORS configuration explicitly trusts the 'null' origin, which can be sent by sandboxed iframes and other untrusted contexts.
Impact
An attacker could steal authentication tokens, API keys, or user session data, potentially leading to account takeovers or privilege escalation.
What the attacker needed
Victim visits attacker-controlled page; victim is logged in to the vulnerable site
The fix
The server should not include 'null' in its list of trusted origins and should validate the Origin header against a strict allowlist of legitimate domains.
How it was found
- Open the CORS lab and log in with the provided credentials.
- In Burp, find the request to /accountDetails in HTTP history.
- Send that request to Repeater.
- Add the header Origin: null and resend the request.
- Observe that the server accepts the null origin.
- Host an exploit page containing a sandboxed iframe that makes a credentialed request to /accountDetails and sends the response to the exploit server.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
CORS is a browser rule that lets a website say which other sites may read its data. Here the site said 'null' is allowed, and 'null' is what a sandboxed iframe or a local file sends. So an attacker's page can quietly ask for the victim's account details and read the answer.
What is CORS?
A permissive cross-origin policy lets another site read responses with the user's credentials.