CSRF form tokens
This page is for administrators, website creators and developers who need to know how public and administration forms
are protected against forged submissions. Exponential adds a secret token to every POST form and refuses posts without
it; this is the ezformtoken extension in the kernel. Sources: Form expired page,
Spam protection for forms and
Security standards.
Contents
- What the token protects against
- What visitors see when a token is refused
- Settings
- Checks for your own forms
- Troubleshooting
What the token protects against
Cross-site request forgery: a page on another site makes a visitor's browser post to your site, using the visitor's session. With a token in every form, a post that did not come from your own page is refused. It protects:
- the administration (every edit, removal, setting);
- signed-in visitors' actions (profile changes, subscriptions);
- public forms (information collector posts).
It is one layer of OWASP Top 10 A01 and A08 mitigations listed in Security standards. It does not stop a person, or a script that loads your form first, from sending spam; that is what Spam protection and third parties covers.
What visitors see when a token is refused
Since 27 September 2026 a refused post gets a clear page instead of an error:
| Part | Value |
|---|---|
| Message | the form has expired; nothing was saved; reload the form and send it again |
| Status | 403 Forbidden (kernel error 6, error.ini) |
| Headers | Cache-Control: no-store and the configured security headers |
XHR with Accept: application/json | a JSON body with the same message |
| Log | one line in var/log/warning.log with the check (missing or wrong), method, path and siteaccess, never the token |
The page is design:error/kernel/6.tpl in design/standard; your design can override it. A form left open for a long
time (a long consultation response) can expire; tell people to copy long texts before sending, or keep forms short.
Settings
| File | Block | Key | Default | Do |
|---|---|---|---|---|
settings/site.ini | HTMLForms | Secret | ThisTokenIsNotSoSecretChangeIt | set your own value in settings/override/site.ini.append.php; keep it out of version control |
settings/site.ini | HTMLForms | RefusalLogCollapseSeconds | 60 | repeated refusals within the window are counted, not written |
settings/error.ini | ErrorSettings-kernel | HTTPError[6] | 403 | leave it |
Keep the ezformtoken extension active; the installer sets it up.
Checks for your own forms
- To do: Forms post with
method="post"; the token is added to POST forms of the page output. - To do: Forms built by JavaScript send the token too (read it from the page's form or meta data, as the shipped scripts do).
- To do: No state-changing action is reachable by GET (a link that removes something).
- To do: After a deploy, a form opened before still works or shows the "form expired" page, not an error.
Troubleshooting
| Symptom | Cause |
|---|---|
| Every post is refused after a change | the secret changed while forms were open, or a cache served a page with an old token to many visitors; do not cache pages with forms for signed-in users |
Refusals from one address in warning.log | someone posting without loading the form; usually harmless, possibly an attack worth watching |
| A custom form is always refused | it is built outside the page output (an iframe, a static HTML file) and has no token |
Related pages
- Building forms
- Security hardening: CSRF
- Forms, CSRF protection and HTTP input
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
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.