GET forms shouldn't have CSRF tokens by default

Created on 21 September 2015, over 9 years ago
Updated 16 February 2025, 8 days ago

Problem/Motivation

In #2463567: Push CSRF tokens for forms to placeholders + #lazy_builder , we've found that there were GET forms with CSRF tokens.

A CSRF token is only useful when changing data, and changing state during a GET request is something that the HTTP spec says SHOULD NOT be done. ( #2502785: Remove support for $form_state->setCached() for GET requests )

Proposed resolution

Make sure that GET forms never have CSRF tokens by setting $form['#token'] = FALSE; in the form builder.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

8.0 ⚰️

Component

forms system

Created by

🇧🇪Belgium borisson_ Mechelen, 🇧🇪

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024