confirm.php
<?php
session_start();
$token= md5(uniqid());
$_SESSION['delete_customer_token']= $token;
session_write_close();
?>
<form method="post" action="confirm_save.php">
<input type="hidden" name="token" value="<?php echo $token; ?>" />
Do you really want to delete?
<input type="submit" value=" Yes " />
<input type="button" value=" No " onclick="history.go(-1);" />
confirm_save.php
<?php
session_start();
$token= $_SESSION['delete_customer_token'];
unset($_SESSION['delete_customer_token']);
session_write_close();
if ($_POST['token']==$token) {
} else {
}
?>
Suppose we have a typical CSRF protection like this. What if the attacker uses this code to bypass the csrf token?
<img src="http://cia.teletubbies.com/csrf.php" height="0" weight="0"/>
$cont = get_file_contents("http://cia.google.com/confirm.php");
This thing holds me, but I'm too lazy to try to attack any random site. Is it impossible?
Example code was stolen from csrf prevention in php
Update
What happens when someone wants to transfer a token from one platform to another or from the server side to the client side? For example, Flash for PHP, how can it be protected from csrf?
source
share