Remediation Steps
Follow the steps below to remediate this finding on Generic / Developer guidance.
Add a per-session, per-form CSRF token to every state-changing HTML form and validate it server-side.
Generation example (PHP):
$token = bin2hex(random_bytes(32)); $_SESSION['csrf_token'] = $token;Form field:
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($token) ?>">
Validation:
if (!hash_equals($_SESSION['csrf_token'], $_POST['csrf_token'] ?? '')) {
http_response_code(403); exit('CSRF validation failed'); }Use the SameSite=Strict or SameSite=Lax cookie attribute as a complementary defence.