Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,196 of 9,196 pages
About the help in other languages
All help pages

CSRF and form tokens

For administrators and developers of public sites - how the ezformtoken extension protects every form against cross-site request forgery, how to check it is active, what custom AJAX code must do, and the form expired…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/government/security/csrf-and-form-tokens.md

On this page

CSRF and form tokens

This page is for administrators and developers. In a cross-site request forgery, another site makes a signed-in editor's browser send a form: publish, delete, change a role. Exponential's ezformtoken extension adds a per-session token to every HTML form and checks it on every POST; a forged form cannot know the token (13.8 Form tokens against cross-site request forgery).

Contents

  1. How it works
  2. Keep it active
  3. Custom code
  4. When a token is refused
  5. Related pages

How it works

  • The setup wizard activates ezformtoken on every new installation.
  • Event listeners add the token to forms in the output and check it on input.
  • Session cookies are SameSite=Lax as defense in depth.
  • A page carrying a token is sent Cache-Control: private, so no shared cache stores it.
  • Some views must accept browser POSTs without a token by design, such as csp/report for Content Security Policy reports with their specific content types; the view only writes a log line.

Keep it active

Check that it is in [ExtensionSettings] ActiveExtensions[]:

php bin/php/console exp:ini where site.ini/ExtensionSettings/ActiveExtensions --allow-root-user

or Setup > Extensions. If it is missing on a live site, every form is open to forgery; add it in the override and clear caches.

Custom code

  • Custom AJAX code that sends POST requests must send the token too; the kernel's own scripts and ezjscore do. The extension's README.rst shows how.
  • A reverse proxy must not override Cache-Control: private on pages with a token.
  • Extensions that add their own forms get the token automatically when they render normal HTML forms through the templates.

When a token is refused

The answer is 403 with the "form expired" page; no token is written to the log (Form expired page). Common harmless causes: the session timed out while a form was open, or the user signed in again in another tab. Repeated refusals for many users after a change point to a proxy or caching problem.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x