Problem/Motivation

CsrfTokenGenerator::validate() has an optional parameter $skip_anonymous defaulting to FALSE. Setting it to TRUE will skip token validation for anonymous users.

Grepping through core turns up no single use of this parameter. This is not only the case in 8.x but also in 7.x, 6.x and 5.x. As far as I can see this parameter was last used in Drupal 4.7.

In fact the function drupal_valid_token was introduced as part of the Drupal 4.7.4 security release, see the commitdiff. The parameter was then used in poll.module<code>, <code>user.module and some other places. The same function was introduced into Drupal 5 in #90508: Introduce tokens by default in forms including the optional parameter, however it was never used since then.

Proposed resolution

Remove the parameter and remove the dependency of CsrfTokenGenerator from the current user service.

Remaining tasks

User interface changes

API changes

Comments

znerol’s picture

znerol’s picture

Issue summary: View changes
znerol’s picture

Status: Active » Needs review
dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I really like this research!

catch’s picture

Status: Reviewed & tested by the community » Fixed

I found one usage in devel (the user switcher), but that's easy to workaround. Very nice find!

  • Commit c9ec67d on 8.x by catch:
    Issue #2245117 by znerol: Remove the optional $skip_anonymous parameter...
znerol’s picture

catch’s picture

Just updating that to add a one-liner seems fine.

damiankloip’s picture

Sorry, I've been away. Looks great!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.