Session fixation for anonymous users - discard invalid session identifiers instead of accepting them

Created on 8 December 2015, almost 9 years ago
Updated 2 March 2024, 9 months ago

Problem/Motivation

If a user sends us a session cookie that contains a session ID that we do not have in our database we should throw away their session id and give them a new one. But we don't.

Steps to reproduce

  1. Install Drupal 8
  2. Install a module that adds some information to the session for anonymous users (outdated but e.g. Sessions Everywhere, https://www.drupal.org/sandbox/kscheirer/2629288 β†’ )
  3. Visit site as an anonymous user, check sessions table
  4. Truncate sessions table
  5. Visit site again, same session id
  6. Truncate sessions table
  7. Modify session value and site again. modified session id stored and kept.

Proposed resolution

If a user comes back with an sid that we don't have in the sessions table, we should create a new session ID for them and send that cookie back to them.

User interface changes

None.

API changes

None.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 1 hour ago

Created by

πŸ‡ΊπŸ‡ΈUnited States kscheirer Vallejo

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Security improvements

    It makes Drupal less vulnerable to abuse or misuse. Note, this is the preferred tag, though the Security tag has a large body of issues tagged to it. Do NOT publicly disclose security vulnerabilities; contact the security team instead. Anyone (whether security team or not) can apply this tag to security improvements that do not directly present a vulnerability e.g. hardening an API to add filtering to reduce a common mistake in contributed modules.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

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