CSRF Attck
CSRF Attck
1. What is CSRF ?
Session Management –
STEPS –
CSRF CONDITIONS –
Now before you attack you have to make sure that the
sight is vulnerable to CSRF , for CSRF attack there are three
main condition –
1) Relevant action.
2) Cookie-based session handling.
3) No unpredictable request parameters .
How To Find CSRF
Vulnerabilities –
Depends on perspective of
testing –
Black box & White box testing.
PRIMARY DEFENSE –
CSRF Tokens - is a randomly generated string that is passed
as a parameter in the request and tied to user session.
How should CSRF tokens be generated?
• Unpredictable with high entropy, similar to session tokens
• Tied to the user's session
• Validated before the relevant action is executed .
How should CSRF tokens be transmitted?
Strict – the cookie will only be sent in first party content and
not be sent along with request initiated by third party
website.
LAX – request should use GET method the result has to be
generated when clicked on link .
Inadequate Defense – Referer Header The Referer HTTP
request header contains an absolute or partial address of the
page making the request.
• Referer headers can be spoofed
• The defense can usually be bypassed:
• Example #1 –if it’s not present, the application does not
check for it
• Example #2 –the referrer header is only checked to see if it
contains the domain and exact
Resources
• Web Security Academy - CSRF
https://portswigger.net/web-security/csrf
• OWASP –CSRF
https:// owasp.org/www-community/attacks/csrf