Protect Your Forms from CSRF Attacks with Anti-CSRF Tokens

Security Analyzer

What is this warning?

A form on your page is missing protection against Cross-Site Request Forgery (CSRF). This is a type of attack where a malicious website can trick a logged-in user into unknowingly submitting a form on your site, potentially leading to unauthorized actions like changing a password or making a purchase. This is a serious vulnerability.

How to Fix This Issue

How to Fix It

The Problem

A form without a unique, hidden token to verify the submission.

The Solution

For each user session, your server should generate a unique, secret token. This token should be included as a hidden field in every form. When the form is submitted, the server must verify that the token matches the one it generated for that session.

<form action="/update-profile" method="post">
  <input type="hidden" name="csrf_token" value="a-unique-and-secret-value">
  <!-- Other form fields -->
</form>

Why This Works

An attacker's website cannot guess the secret CSRF token, so any forged requests they try to make will be rejected by your server. This is a standard and highly effective defense against CSRF attacks.

SEO Impact

This issue can affect your site's search engine rankings and user experience. Addressing it promptly helps ensure optimal performance and visibility in search results.

Automatic Detection

Black SEO Analyzer automatically checks for this warning during site analysis, along with hundreds of other technical SEO issues.

Ready to Unlock Your Site's Full SEO Potential?

Choose the license that fits your needs and start getting the deep, actionable insights you deserve.