Rack session gets restored after deletion
Description
Rack is a modular Ruby web server interface. Prior to version 2.2.14, 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. Rack session middleware prepares the session at the beginning of request, then saves is back to the store with possible changes applied by host rack application. This way the session becomes to be a subject of race conditions in general sense over concurrent rack requests. When using the Rack::Session::Pool middleware, and provided the attacker can acquire a session cookie (already a major issue), the session may be restored if the attacker can trigger a long running request (within that same session) adjacent to the user logging out, in order to retain illicit access even after a user has attempted to logout. Version 2.2.14 contains a patch for the issue. Some other mitigations are available. Either ensure the application invalidates sessions atomically by marking them as logged out e.g., using a logged_out flag, instead of deleting them, and check this flag on every request to prevent reuse; or implement a custom session store that tracks session invalidation timestamps and refuses to accept session data if the session was invalidated after the request began.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
rackRubyGems | < 2.2.14 | 2.2.14 |
Affected products
1Patches
13 files changed · +60 −1
CHANGELOG.md+6 −0 modified@@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/). +## [2.2.14] - 2025-05-06 + +### Security + +- [CVE-2025-32441](https://github.com/rack/rack/security/advisories/GHSA-vpfw-47h7-xj4g) Rack session can be restored after deletion. + ## [2.2.13] - 2025-03-11 ### Security
lib/rack/session/pool.rb+6 −1 modified@@ -55,6 +55,7 @@ def find_session(req, sid) def write_session(req, session_id, new_session, options) with_lock(req) do + return false unless get_session_with_fallback(session_id) @pool.store session_id.private_id, new_session session_id end @@ -64,7 +65,11 @@ def delete_session(req, session_id, options) with_lock(req) do @pool.delete(session_id.public_id) @pool.delete(session_id.private_id) - generate_sid unless options[:drop] + unless options[:drop] + sid = generate_sid + @pool.store(sid.private_id, {}) + sid + end end end
test/spec_session_pool.rb+48 −0 modified@@ -261,4 +261,52 @@ res = Rack::MockRequest.new(app).get("/") res["Set-Cookie"].must_be_nil end + + user_id_session = Rack::Lint.new(lambda do |env| + session = env["rack.session"] + + case env["PATH_INFO"] + when "/login" + session[:user_id] = 1 + when "/logout" + if session[:user_id].nil? + raise "User not logged in" + end + + session.delete(:user_id) + session.options[:renew] = true + when "/slow" + Fiber.yield + end + + Rack::Response.new(session.inspect).to_a + end) + + it "doesn't allow session id to be reused" do + app = Rack::Session::Pool.new(user_id_session) + + login_response = Rack::MockRequest.new(app).get("/login") + login_cookie = login_response["Set-Cookie"] + + slow_request = Fiber.new do + Rack::MockRequest.new(app).get("/slow", "HTTP_COOKIE" => login_cookie) + end + slow_request.resume + + # Check that the session is valid: + response = Rack::MockRequest.new(app).get("/", "HTTP_COOKIE" => login_cookie) + response.body.must_equal({"user_id" => 1}.to_s) + + logout_response = Rack::MockRequest.new(app).get("/logout", "HTTP_COOKIE" => login_cookie) + logout_cookie = logout_response["Set-Cookie"] + + # Check that the session id is different after logout: + login_cookie[session_match].wont_equal logout_cookie[session_match] + + slow_response = slow_request.resume + + # Check that the cookie can't be reused: + response = Rack::MockRequest.new(app).get("/", "HTTP_COOKIE" => login_cookie) + response.body.must_equal "{}" + end end
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-vpfw-47h7-xj4gghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2025-32441ghsaADVISORY
- github.com/rack/rack-session/security/advisories/GHSA-9j94-67jr-4cqjghsaWEB
- github.com/rack/rack/blob/v2.2.13/lib/rack/session/abstract/id.rbghsax_refsource_MISCWEB
- github.com/rack/rack/commit/c48e52f7c57e99e1e1bf54c8760d4f082cd1c89dghsax_refsource_MISCWEB
- github.com/rack/rack/security/advisories/GHSA-vpfw-47h7-xj4gghsax_refsource_CONFIRMWEB
- github.com/rubysec/ruby-advisory-db/blob/master/gems/rack/CVE-2025-32441.ymlghsaWEB
News mentions
0No linked articles in our index yet.