Skip to content

Prevent timing attack on CSRF, completing wonderful pr by @eutopian#174

Merged
BobbyMcWho merged 4 commits intoomniauth:masterfrom
jhartzler:master
Oct 12, 2023
Merged

Prevent timing attack on CSRF, completing wonderful pr by @eutopian#174
BobbyMcWho merged 4 commits intoomniauth:masterfrom
jhartzler:master

Conversation

@jhartzler
Copy link
Copy Markdown

@jhartzler jhartzler commented Sep 27, 2023

Attempting to complete the CSRF fix introduced in #123 by @eutopian
It looks like that PR has been untouched since 2021 so opening a new one that is up to date with latest master and implements the renamed test that was suggested

@jhartzler
Copy link
Copy Markdown
Author

@BobbyMcWho @nov do either of you have write access? 🙏
New contributor just trying to fix a vuln, if you are around thank you so much in advance for your time!

@jhartzler
Copy link
Copy Markdown
Author

Let me fix this build error

error = request.params["error_reason"] || request.params["error"]
if !options.provider_ignores_state && (request.params["state"].to_s.empty? || request.params["state"] != session.delete("omniauth.state"))
fail!(:csrf_detected, CallbackError.new(:csrf_detected, "CSRF detected"))
elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || !secure_compare(request.params["state"], session.delete("omniauth.state")))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elsif !options.provider_ignores_state && (request.params["state"].to_s.empty? || !secure_compare(request.params["state"], session.delete("omniauth.state")))
if !options.provider_ignores_state && (request.params["state"].to_s.empty? || !secure_compare(request.params["state"], session.delete("omniauth.state")))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Looks like I didn't copy from the initial PR properly

@jhartzler
Copy link
Copy Markdown
Author

Running specs locally it looks like there might be some more work to reconcile this PR with master. I'm looking into it

@jhartzler
Copy link
Copy Markdown
Author

Alright everything should be fixed now as far as I can tell. Specs pass locally.

@jhartzler
Copy link
Copy Markdown
Author

@BobbyMcWho thank you for the earlier review and code suggestion
Not sure what your cadence/availability is but when you get a chance could I get a workflow kickoff and a re review?

@jhartzler
Copy link
Copy Markdown
Author

I will buy someone a coffee if they review this PR lol

@BobbyMcWho
Copy link
Copy Markdown
Member

No coffee needed, I don't mind merging, but the whole release process is the headache

@BobbyMcWho BobbyMcWho merged commit c830138 into omniauth:master Oct 12, 2023
@jhartzler
Copy link
Copy Markdown
Author

Haha thank you for the review + merge
I'm guessing there's nothing I can do to help the release process along?

@BobbyMcWho
Copy link
Copy Markdown
Member

I just haven't released on this laptop yet so I gotta do some pre requisite installs, that's all

@BobbyMcWho
Copy link
Copy Markdown
Member

Release v1.9.0 available on Rubygems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants