CVE-2025-46336 (rack-session): Rack session gets restored after deletion
The Rack session middleware loads a session at the start of a request and writes it back at the end, so concurrent requests can race. If an attacker already holds a session cookie and triggers a long-running request while the user logs out, the deleted session can be restored, letting the attacker keep access.
rubysec.com
Published on rubysec.com
When using the Rack::Session::Pool middleware, simultaneous rack requests can restore a deleted rack session, which allows the unauthenticated user to occupy that session.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the session middleware reads the session at the start of a request and writes it back at the end without checking whether the session was deleted in the meantime, so a concurrent request can recreate it.
Impact
An attacker who already has a session cookie could retain access after the user logs out by timing a long-running request next to the logout, though the report notes that acquiring the cookie is already a major issue.
What the attacker needed
Attacker already has a session cookie; attacker can trigger a long-running request; timing near the user's logout
The fix
It was fixed by updating rack-session to version 2.1.1 or later; alternatively, applications should mark sessions as logged out with a flag instead of deleting them, or use a custom store that checks invalidation timestamps.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A session cookie is like a temporary ID card a website gives your browser after you log in. This bug means that if someone already stole that ID card, they can keep using it even after you log out, because a slow request can put the session back into the server's memory. The report says stealing the cookie is already a serious problem, so this makes the damage last longer.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.