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

Signature helper is mixing seconds with milliseconds with whatever 3000 is #357

Open
ciscou opened this issue Nov 18, 2024 · 0 comments
Open
Assignees

Comments

@ciscou
Copy link

ciscou commented Nov 18, 2024

About https://github.com/HubSpot/hubspot-api-ruby/blob/master/lib/hubspot/helpers/signature.rb

According to the docs, we should reject requests older than 5 minutes. 5 minutes is 300 seconds or 300,000 milliseconds, but Signature::MAX_ALLOWED_TIMESTAMP is neither (3000)

If the timestamp argument is the value of the x-hubspot-request-timestamp header then we should be using milliseconds all over the place (MAX_ALLOWED_TIMESTAMP = 300_000).

Then, this comparison

current_time = DateTime.now.strftime("%s").to_i
if current_time - timestamp.to_i > MAX_ALLOWED_TIMESTAMP
  raise InvalidSignatureTimestampError.new(timestamp)
end

should become

current_time = DateTime.now.to_i * 1_000
if current_time - timestamp.to_i > MAX_ALLOWED_TIMESTAMP
  raise InvalidSignatureTimestampError.new(timestamp)
end
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

No branches or pull requests

2 participants