CSRF
Exploit
With POST
With GET
Defences
CSRF tokens bypass
Switch from
POST
to theGET
methodRemove the parameter containing the token
Invent a token in the required format (the app doesn't keep valid server-side tokens).
Log in to the application with your account, obtain a valid token, and then feed that token to the victim user in their CSRF attack (some apps don't validate if the token belongs to the same session as the requesting user).
Are there two token: one in a cookie and one in hidden input? (this can also have the same value)
Some apps do tie the CSRF token to a cookie, but not to the session cookie.
Can you set a cookie? E.g. Header injection with
CRLF
.(%0d%0a
)Log in to the application with your account -> obtain a valid token and associated cookie.
Generate CSRF PoC and remove the auto-submit
<script>
block. Then add the following code to inject the cookie.
SameSite cookies bypass
Lax bypass
Using GET requests (bypass lax)
GET method override (bypass lax)
Even if an ordinary
GET
request isn't allowed, some frameworks supports_method
parameter. (Other frameworks support a variety of similar parameters)
Strict bypass
Bypass via client-side redirect. Consider a page https://vulnerable-website.com/post/confirm?postId=10
that load this script.
Note: this attack isn't possible with server-side redirects, as browsers recognize the cross-site request and apply cookie restrictions.
Referer-based validation bypass
Some apps validate the Referer header if present, but skip if omitted
Validation of Referer can be circumvented
To sed referer you need to add
Referrer-Policy: unsafe-url
. One way to set it in html:<meta name="referrer" content="unsafe-url"/>
Tip: Instead of use http://attacker-website.com/vulnerable-website.com
, you can use http://attacker-website.com/
and add <script>history.pushState('', '', '/vulnerable-website.com')</script>
Firefox 87 new default Referrer Policy strict-origin-when-cross-origin
trimming user sensitive information like path and query string to protect privacy. [🔗]
Last updated