CSRF
Cross-Site Request Forgery.
Last updated
Was this helpful?
Cross-Site Request Forgery.
Last updated
Was this helpful?
Allows an attacker to induce users to perform actions that they do not intend to perform.
Steps:
Check action
Check defences
CSRF tokens
Value to check
SameSite cookies
Referer-based validation
Use of the HTTP Referer header to attempt to defend
Right click on request > Engagement tools > .
Change request method GET/POST
Remove CSRF token
Use CSRF token of its own session
Need to find a way to inject header.
CSRF sessions (es. csrfKey
in cookie header and csrf
in body)
The CSRF session isn't associated with the user session.
Try to inject and use CSRF header and token of its own session.
CSRF token is duplicated in a cookie header Try to injectthe same CSRF token in cookie header and body.
In Symfony _method
takes precedence over the normal method.
Other frameworks support a variety of similar parameters.
To avoid breaking single sign-on (SSO) mechanisms, SameSite Lax allows on top-level POST
requests in the first 120 seconds.
So you can trigger the cookie refresh from a new tab.
Browsers block popup tabs unless they're opened via a manual interaction.
Find a gadget that results in a secondary request within the same site. One possible gadget is a client-side redirect that dynamically constructs the redirection target using attacker-controllable input like URL parameters.
Some applications skip the validation if the header is omitted. The easiest way to do that is using a META tag within the HTML page that hosts the CSRF attack.
bypassing the naive way of checking
For pushing Referer header in Javascript
Many browsers now strip the query string from the Referer header by default as a security measure. To override this behavior and ensure that the full URL is included in the request add the following header to the "Head" section in webhook:
Browser security mechanism that prevent cookies from being included in requests originating from an attacker. Included in Set-Cookie and with 3 restriction levels: , (default in chrome), (+ Secure attribute)
CSRF vulnerability on a . Unlike regular CSRF, the attacker gains two-way interaction with the compromised application. You typically need to find a handshake message that relies solely on HTTP cookies for session handling and doesn't employ any tokens or other unpredictable values in request parameters.