Attack taxonomy
Biniam F. Demissie
Security & Trust Research Unit
Fondazione Bruno Kessler
Trento, Italy
Cross Site Request
Forgery
“…
is a type of attack that occurs when a malicious web
Cross Site Request
Forgery
“…
is a type of attack that occurs when a malicious web
site, email, blog, instant message, or program causes a
user's web browser to perform an unwanted action on a
trusted site when the user is authenticated.”
Cross Site Request
Forgery
”…
is a type of attack that occurs when
a malicious web
site, email, blog, instant message, or program
causes a
Cross Site Request
Forgery
”…
is a type of attack that occurs when a malicious web
Cross Site Request
Forgery
”…
is a type of attack that occurs when a malicious web
Cross Site Request
Forgery
”…
is a type of attack that occurs when a malicious web
site, email, blog, instant message, or program causes a
user's web browser to perform an unwanted action on a
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Cross Site Request
Forgery
Eve wants to make Alice
transfer money to her
Cross Site Request
Forgery
Alice
Cross Site Request
Forgery
Alice
Cross Site Request
Forgery
Alice
https://mybank.com/transferFunds
Cross Site Request
Forgery
Alice
https://mybank.com/transferFunds
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cross Site Request
Forgery
Alice https://mybank.com/transferFunds <?php session_start();if (isset($_SESSION)) {
// check auth cookie & handle transfer
}
?>
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cross Site Request
Forgery
Alice https://mybank.com/transferFunds <?php session_start();if (isset($_SESSION)) {
// check auth cookie & handle transfer
}
?>
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cross Site Request
Forgery
Alice https://mybank.com/transferFunds <?php session_start();if (isset($_SESSION)) {
// check auth cookie & handle transfer
}
?>
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cross Site Request
Forgery
Eve
Cross Site Request
Forgery
Eve
Cross Site Request
Forgery
Eve
100 123
Cross Site Request
Forgery
Eve
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id ???>
Cross Site Request
Forgery
Eve
<?php
session_start();
if (isset($_SESSION)) {
// transfer will not happen because Eve does not have Alice’s
auth/session cookies
}
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id ???>
Cross Site Request
Forgery
Eve
<?php
session_start();
if (isset($_SESSION)) {
// transfer will not happen because Eve does not have Alice’s
auth/session cookies
}
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id ???>
Cross Site Request
Forgery
Eve
<?php
session_start();
if (isset($_SESSION)) {
// transfer will not happen because Eve does not have Alice’s
auth/session cookies
}
100 123
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id ???>
Cross Site Request
Forgery
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
Cross Site Request
Forgery
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
Cross Site Request
Forgery
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cross Site Request
Forgery
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Summary
Summary
Problem: an attacker makes a user perform a sensitive action on a trusted website where he/she is authenticated to.
• Example of sensitive actions
o /login.aspx
o /delete_user.php
Summary
Problem: an attacker makes a user perform a sensitive action on a trusted website where he/she is authenticated to.
• Example of sensitive actions
o /login.aspx
o /delete_user.php
o /UpdateStatus/
• Make user perform sensitive action
Fixing CSRF
• Make sensitive action requests unique by attaching
unpredictable request identifiers (nonce, one time token)
• Use reCAPTCHAs to complete actions
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id>
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id>
<input type="hidden" name="csrf_token" value=“UNIQUE_CSRF_TOKEN" />
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id>
<input type="hidden" name="csrf_token" value=“UNIQUE_CSRF_TOKEN" />
100 123
Fixing CSRF
• Using nonce/one time token
Alice
<!DOCTYPEhtml> <html>
<header>
<title>Download New Movies</title> </header>
<body>
<img src="https://mybank.com/transferFunds?amount=100&accountID=123" />
<h2>List of movies</h2>
GET /transferFunds?amount=100&accountID=123 HTTP/1.1 Host: mybank.com
Cookie: <alice auth/session id>
&csrf_token=UNIQUE_CSRF_TOKEN
<input type="hidden" name="csrf_token" value=“UNIQUE_CSRF_TOKEN" />
100 123
Fixing CSRF
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
• Using nonce/one time token (setting nonce)
<?php
session_start();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32)); }
$csrf_token =$_SESSION['csrf_token'];
?>
<!DOCTYPE html> <html>
<header><title>My account</title></header> <body>
<form>
...
<input type="hidden" name="csrf_token" value="<?phpecho $csrf_token; ?>"/>
Fixing CSRF
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
• Using nonce/one time token (checking nonce)
<?php
session_start();
$csrf_token =$_SESSION['csrf_token'];
// or $token = $_POST['csrf_token'];
if (!empty($_GET['csrf_token'])) {
$token =$_GET['csrf_token'];
if(hash_equals($csrf_token, $token)) {
// all ok, proceed processing data
}else{
// possible csrf attack
Fixing CSRF
Fixing CSRF
• Use reCAPTCHAs to complete sensitive actions
Fixing CSRF
• Use reCAPTCHAs to complete sensitive actions
• The user has to first click on I’m not a robot and solve CAPTCHA
Fixing CSRF
Fixing CSRF
Summary
• Make sensitive actions requests unique by attaching
unpredictable request identifiers (nonce, one time token)
• Use reCAPTCHAs to complete actions
• Prompt authentication to complete sensitive action