# How we found and fixed a rare race condition in our session handling

DevFeed: [How we found and fixed a rare race condition in our session handling](<https://devfeed.tech/articles/how-we-found-and-fixed-a-rare-race-condition-in-our-session-handling-68608.md>)

Original publisher: [Read original article](<https://github.blog/security/vulnerability-research/how-we-found-and-fixed-a-rare-race-condition-in-our-session-handling/>)

Author: Dirkjan Bussink

Published: 2021-03-18T19:59:27Z

Content type: article

Language: en

Sources: [GitHub Blog](<https://devfeed.tech/sources/github-engineering.md>)

Topics: [race-condition](<https://devfeed.tech/topics/race-condition.md>), [sessions](<https://devfeed.tech/topics/sessions.md>), [shared mutable state](<https://devfeed.tech/topics/shared-mutable-state.md>), [engineering-culture](<https://devfeed.tech/topics/engineering-culture.md>), [Error Handling](<https://devfeed.tech/topics/error-handling.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [bug](<https://devfeed.tech/tags/bug.md>), [collaboration](<https://devfeed.tech/tags/collaboration.md>), [complex-systems](<https://devfeed.tech/tags/complex-systems.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [github](<https://devfeed.tech/tags/github.md>), [race-condition](<https://devfeed.tech/tags/race-condition.md>), [security](<https://devfeed.tech/tags/security.md>), [vulnerability](<https://devfeed.tech/tags/vulnerability.md>), [vulnerability-research](<https://devfeed.tech/tags/vulnerability-research.md>)

## AI overview

GitHub describes how a rare race condition in its Ruby on Rails application caused one user's session cookie to be returned in another user's response. A background thread, shared exception context, deferred callbacks, and reuse of a Rack environment object combined to expose the issue. GitHub removed the background thread, patched Unicorn to isolate request environments, revoked active sessions, and outlined further work to improve thread safety and incident response.

## Source excerpt

On March 8, we shared that, out of an abundance of caution, we logged all users out of GitHub.com due to a rare security vulnerability. We believe that transparency is...