Skip to content

fix(session): regenerate new session IDs from cookies#15752

Merged
ascorbic merged 1 commit intomainfrom
fix/session-fixation
Mar 4, 2026
Merged

fix(session): regenerate new session IDs from cookies#15752
ascorbic merged 1 commit intomainfrom
fix/session-fixation

Conversation

@ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Mar 4, 2026

Changes

  • When a session ID is supplied via cookie but has no corresponding server-side storage entry, the session now generates a new ID instead of using the cookie-supplied one
  • Refactors #ensureSessionID() to track whether the session ID originated from a client cookie vs. being freshly generated
  • Adds #sessionIDFromCookie flag that is checked in #ensureData() and reset in regenerate()

Testing

Added tests

Docs

No user-facing changes

When a session ID is supplied via cookie but has no corresponding
server-side data, generate a new ID instead of accepting the
unknown one. This prevents session fixation where an attacker
pre-sets a known session ID in the victim's cookie.
@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 4, 2026
@ascorbic ascorbic changed the title fix(session): reject unrecognized session IDs from cookies fix(session): regenerate new session IDs from cookies Mar 4, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 4, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing fix/session-fixation (39ea636) with main (573d188)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (ca6894a) during the generation of this report, so 573d188 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ascorbic ascorbic merged commit 918d394 into main Mar 4, 2026
26 checks passed
@ascorbic ascorbic deleted the fix/session-fixation branch March 4, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants