Skip to content
Snippets Groups Projects
Commit eb3ee4cd authored by Jared Hancock's avatar Jared Hancock
Browse files

csrf: Always rotate the token to prevent double submissions

parent 35acdea8
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,11 @@ Class CSRF {
}
function validateToken($token) {
return ($token && trim($token)==$this->getToken() && !$this->isExpired());
$rv = $token && trim($token)==$this->getToken() && !$this->isExpired();
// Prevent the token from being reused
if ($rv && !defined('AJAX_REQUEST'))
$this->rotate();
return $rv;
}
function getFormInput($name='') {
......
......@@ -111,8 +111,8 @@ class osTicket {
return ($token && $this->getCSRF()->validateToken($token));
}
function checkCSRFToken($name='') {
$name = $name?$name:$this->getCSRF()->getTokenName();
function checkCSRFToken($name=false) {
$name = $name ?: $this->getCSRF()->getTokenName();
if(isset($_POST[$name]) && $this->validateCSRFToken($_POST[$name]))
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment