Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Securely compare webhook hmac #216

Merged
merged 4 commits into from
Feb 11, 2016
Merged

Conversation

Hammadk
Copy link
Member

@Hammadk Hammadk commented Feb 11, 2016

This PR updates WebhookController so we use ActiveSupport::SecurityUtils.secure_compare to compare webhook data with the actual HMAC. This improves our ability to handle timing attacks.

@kevinhughes27 @djoume Please review.

def hmac_valid?(data)
secret = ShopifyApp.configuration.secret
digest = OpenSSL::Digest.new('sha256')
ActiveSupport::SecurityUtils.secure_compare(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you consider using variable_size_secure_compare ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@djoume
Copy link
Contributor

djoume commented Feb 11, 2016

one comment otherwise LGTM

@kevinhughes27
Copy link
Contributor

lgtm!

@djoume
Copy link
Contributor

djoume commented Feb 11, 2016

:shipit:

Hammadk added a commit that referenced this pull request Feb 11, 2016
@Hammadk Hammadk merged commit 38da99c into master Feb 11, 2016
@Hammadk Hammadk deleted the secure-compare-webhook-validation branch February 11, 2016 19:02
@kevinhughes27 kevinhughes27 temporarily deployed to rubygems March 16, 2016 21:20 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants