Cross Site Request Forgery (CSRF) Attack
Cross Site Request Forgery (CSRF) Attack
Cross Site Request Forgery (CSRF) Attack
attack
What is CSRF
Cross site request forgery (CSRF), also known as XSRF, Sea Surf or Session
Riding, is an attack vector that tricks a web browser into executing an unwanted
action in an application to which a user is logged in.
A successful CSRF attack can be devastating for both the business and user. It can
result in damaged client relationships, unauthorized fund transfers, changed
passwords and data theft—including stolen session cookies.
CSRFs are typically conducted using malicious social engineering, such as an email
or link that tricks the victim into sending a forged request to a server. As the
unsuspecting user is authenticated by their application at the time of the attack, it’s
impossible to distinguish a legitimate request from a forged one.
CSRF example
Before executing an assault, a perpetrator typically studies an application in order to
make a forged request appear as legitimate as possible.
For example, a typical GET request for a $100 bank transfer might look like:
GET http://netbank.com/transfer.do?acct=PersonB&amount=$100
HTTP/1.1
A hacker can modify this script so it results in a $100 transfer to their own account.
Now the malicious request might look like:
GET http://netbank.com/transfer.do?acct=AttackerA&amount=$100
HTTP/1.1
A bad actor can embed the request into an innocent looking hyperlink:
<a
href="http://netbank.com/transfer.do?acct=AttackerA&amount=$100
">Read more!</a>
Next, he can distribute the hyperlink via email to a large number of bank customers.
Those who click on the link while logged into their bank account will unintentionally
initiate the $100 transfer.
Note that if the bank’s website is only using POST requests, it’s impossible to frame
malicious requests using a <a> href tag. However, the attack could be delivered in a
<form> tag with automatic execution of the embedded JavaScript.
<body onload="document.forms[0].submit()">
</form>
</body>
For web applications, multiple solutions exist to block malicious traffic and prevent
attacks. Among the most common mitigation methods is to generate unique random
tokens for every session request or ID. These are subsequently checked and verified
by the server. Session requests having either duplicate tokens or missing values are
blocked. Alternatively, a request that doesn’t match its session ID token is prevented
from reaching an application.
See how Imperva Web Application Firewall can help you with CSRF attacks.
IncapRules, the Imperva cloud proprietary custom rules engine, lets customers
create their own security policies. The policies are generated using an intuitive
syntax and can be modified on the fly, augmenting our default web application
firewall configuration.
Using IncapRules, you can create a policy that filters requests to sensitive pages and
functions based on your HTTP referrer header content. Doing so allows requests to
be executed from a short list of secure domains.
This method completely counters the social engineering aspect of CSRF attacks. It
prevents execution of malicious requests outside of a security perimeter, regardless
of content.
Alternatively, you can run the rule in ‘Alert Only’ mode to track possible exploit
attempts, or present CAPTCHAs that alert unwary users.
Learning Objectives
Phishing attacks
Social Engineering
SQL (Structured query language) Injection
Cross site scripting (XSS) attacks
Reflected cross site scripting (XSS) attacks
Clickjacking
Man in the middle (MITM) attack
TCP SYN Flood
Ping flood (ICMP flood)
What is CSRF
Cross site request forgery (CSRF), also known as XSRF, Sea Surf or Session
Riding, is an attack vector that tricks a web browser into executing an unwanted
action in an application to which a user is logged in.
A successful CSRF attack can be devastating for both the business and user. It can
result in damaged client relationships, unauthorized fund transfers, changed
passwords and data theft—including stolen session cookies.
CSRFs are typically conducted using malicious social engineering, such as an email
or link that tricks the victim into sending a forged request to a server. As the
unsuspecting user is authenticated by their application at the time of the attack, it’s
impossible to distinguish a legitimate request from a forged one.
CSRF example
Before executing an assault, a perpetrator typically studies an application in order to
make a forged request appear as legitimate as possible.
For example, a typical GET request for a $100 bank transfer might look like:
GET http://netbank.com/transfer.do?acct=PersonB&amount=$100
HTTP/1.1
A hacker can modify this script so it results in a $100 transfer to their own account.
Now the malicious request might look like:
GET http://netbank.com/transfer.do?acct=AttackerA&amount=$100
HTTP/1.1
A bad actor can embed the request into an innocent looking hyperlink:
<a
href="http://netbank.com/transfer.do?acct=AttackerA&amount=$100
">Read more!</a>
Next, he can distribute the hyperlink via email to a large number of bank customers.
Those who click on the link while logged into their bank account will unintentionally
initiate the $100 transfer.
Note that if the bank’s website is only using POST requests, it’s impossible to frame
malicious requests using a <a> href tag. However, the attack could be delivered in a
<form> tag with automatic execution of the embedded JavaScript.
<body onload="document.forms[0].submit()">
</body>
For web applications, multiple solutions exist to block malicious traffic and prevent
attacks. Among the most common mitigation methods is to generate unique random
tokens for every session request or ID. These are subsequently checked and verified
by the server. Session requests having either duplicate tokens or missing values are
blocked. Alternatively, a request that doesn’t match its session ID token is prevented
from reaching an application.
See how Imperva Web Application Firewall can help you with CSRF attacks.
IncapRules, the Imperva cloud proprietary custom rules engine, lets customers
create their own security policies. The policies are generated using an intuitive
syntax and can be modified on the fly, augmenting our default web application
firewall configuration.
Using IncapRules, you can create a policy that filters requests to sensitive pages and
functions based on your HTTP referrer header content. Doing so allows requests to
be executed from a short list of secure domains.
This method completely counters the social engineering aspect of CSRF attacks. It
prevents execution of malicious requests outside of a security perimeter, regardless
of content.
Alternatively, you can run the rule in ‘Alert Only’ mode to track possible exploit
attempts, or present CAPTCHAs that alert unwary users.
Learning Objectives
Phishing attacks
Social Engineering
SQL (Structured query language) Injection
Cross site scripting (XSS) attacks
Reflected cross site scripting (XSS) attacks
Clickjacking
Man in the middle (MITM) attack
TCP SYN Flood
Ping flood (ICMP flood)