Skip to content

Commit

Permalink
Make TokenVerifier#call safely reentrant
Browse files Browse the repository at this point in the history
In a multi-threaded app, two threads might update `@request` before
either thread is able to evaluate `verified_request?`.

In order to retain backward-compatibility, this is fixed by using `dup`
and then calling the original implementation on that copy.
  • Loading branch information
nevans authored and sikachu committed May 10, 2024
1 parent 6bcc98a commit 9bf98c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/omniauth/rails_csrf_protection/token_verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class TokenVerifier
end

def call(env)
dup._call(env)
end

def _call(env)
@request = ActionDispatch::Request.new(env.dup)

unless verified_request?
Expand Down

0 comments on commit 9bf98c1

Please sign in to comment.