CSRF
Cross-Site Request Forgery.
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 > Generate CSRF PoC.
Bypassing
CSRF base
Change request method GET/POST
Remove CSRF token
Use CSRF token of its own session
CSRF in header
Need to find a way to inject header.
CSRF sessions (es.
csrfKey
in cookie header andcsrf
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.
SameSite Lax
In Symfony _method
takes precedence over the normal method.
Other frameworks support a variety of similar parameters.
Cookie Refresh
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.
SameSite Strict
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.
Referer Header
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:
CSRF WebSocket hijacking
CSRF vulnerability on a WebSocket handshake. 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.
Last updated