mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	validate token value from csrf token header
if supplied and not overridden by post request param
This commit is contained in:
		| @@ -83,7 +83,19 @@ function CSRFMetaTag() | |||||||
| */ | */ | ||||||
| function CSRFValidate() | function CSRFValidate() | ||||||
| { | { | ||||||
|     if (hash_equals($_POST['csrf_token'], $_SESSION['csrf_token'])) { |     $post_token   = $_POST['csrf_token']; | ||||||
|  |     $header_token = $_SERVER['HTTP_X_CSRF_TOKEN']; | ||||||
|  |  | ||||||
|  |     if (empty($post_token) && empty($header_token)) { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     $request_token = $post_token; | ||||||
|  |     if (empty($post_token)) { | ||||||
|  |         $request_token = $header_token; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (hash_equals($_SESSION['csrf_token'], $request_token)) { | ||||||
|         return true; |         return true; | ||||||
|     } else { |     } else { | ||||||
|         error_log('CSRF violation'); |         error_log('CSRF violation'); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user