feat: add forward tolerance for v3 validity check #7685
Merged
+64
−38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ticket: ANT-1352
Context: during local v3 auth testing I ran into the error
server response outside response validity time window, possible man-in-the-middle-attackwhich happened because the response timestamp logged was1764777803921and theDate.now()timestamp thatverifyResponseused was1764777803898. So, the response timestamp was slightly ahead, even thoughverifyResponseis called after. This is likely server-client clock skew, this fix adds a forward validity check of 60s to accommodate this.Description
This pull request updates the HMAC utility functions to support a more flexible validity window for timestamp verification, allowing both backward and forward checks. It also adds an optional
useOriginalPathparameter to key functions for more control over HMAC subject calculation, and expands the test suite to cover the new validity window logic.HMAC validity window improvements:
verifyResponsefunction now checks if the timestamp is within a 5-minute backward window and a 1-minute forward window, improving support for minor clock drift between systems.API flexibility enhancements:
calculateRequestHMAC,calculateRequestHeaders, andverifyResponsefunctions now accept an optionaluseOriginalPathparameter to keep them in line withcalculateHMACSubject, allowing callers to specify whether to use the original URL path when calculating the HMAC subject. [1] [2] [3]Issue Number
ANT-1352
Type of change
How Has This Been Tested?
Unit test
Checklist: