SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Security Added 13 October 2025

CSRF: Token invalid or missing

Cross-Site Request Forgery token is invalid, expired, or missing from request.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Include CSRF token in form
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
# Or in AJAX header
headers: {'X-CSRF-Token': csrfToken}
# Refresh token if expired

How to diagnose Security errors

Security errors are usually a control working correctly. A rejected JWT, a CSP violation, an SELinux denial or a host key mismatch is the system telling you an invariant was broken, and the right response is to understand the invariant, never to disable the control. Two of these deserve special caution: an SSH host key mismatch can indicate a genuine interception, and JWT algorithm confusion is an active exploitation technique, not a configuration nuisance.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Decode tokens locally and check exp, nbf, iss and aud. Never paste a live token into an online decoder. It is a credential.
  2. Pin the accepted JWT algorithm explicitly on the verifying side. Accepting whatever the token's header claims is the algorithm-confusion vulnerability.
  3. For SELinux, read the actual denial: ausearch -m avc -ts recent | audit2why. Set the correct file context with semanage fcontext rather than running setenforce 0.
  4. For CSP violations, read the browser console message. It names the exact directive and blocked URI. Add the specific source, not a wildcard.
  5. For an SSH host key mismatch, verify the new fingerprint out of band before removing the old key. This warning exists to catch man-in-the-middle attacks.

Tools worth reaching for

  • ausearch / audit2why
  • openssl x509 -noout -text
  • ssh-keygen -lf
  • browser CSP console reports
  • local JWT decoding

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

owasp.org

Related Security errors

See all 25 Security errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.