Allow validating the created parameter#8
Conversation
To mitigate the risk of replay attacks.
| parameters = signature.parameters | ||
| components = signature.components | ||
|
|
||
| if no_older_than && (Time.now.to_i - parameters["created"]) > no_older_than.to_i |
There was a problem hiding this comment.
If the signature being verified doesn't have a created parameter and is requested to check that is not older than some some value, I think we want to raise a Error, otherwise it will fail with an exception like the following:
TypeError: nil can't be coerced into Integer (TypeError)
puts (Time.now.to_i - parameters["created"])
^^^^^^^^^^^^^^^^^^^^^
Maybe in #validate method in Verifier class can be validated that if no_older_than option is present, then signature parameter must be present and its value should respond to to_i.
There was a problem hiding this comment.
Sorry, I missed that. I moved some code around and now raise a proper error in this case.
|
Thanks for PR @oneiros! I have a couple of comments:
|
...before checking age of signature.
I think it is important to fail in these cases, which is not the same as diligently validating every possible thing that another implementation could conceivably get wrong. That is to say, you are probably right, but I worry a bit about performance. I guess one needs to find the right balance here.
I think validating based on |
|
Thanks @oneiros for bringing attention to this issue and sending a PR to address it. Yes, I agree the library should not go over the board with too many validation checks, by "thorough" I just meant that signatures with an invalid or missing I also agree that expiration validation through Thanks again for the fix, I'll cut a new release tomorrow or so. |
Fixes #7
This is a first attempt to add validation of the
createdparameter. This can be used to mitigate the risk of replay attacks.This is just a first suggestion. Let me know what you think, I am more than happy to change the API, move stuff around etc.