Fix validAfter boundary condition in EIP3009 authorization validation#657
Open
Kewe63 wants to merge 4 commits into
Open
Fix validAfter boundary condition in EIP3009 authorization validation#657Kewe63 wants to merge 4 commits into
Kewe63 wants to merge 4 commits into
Conversation
- Update @typechain/ethers-v6 from 0.4.3 to 0.5.1 - Update typechain from 8.3.1 to 8.3.2 - Resolves peer dependency conflicts that break project setup
This reverts commit 2c2f3a1.
Change strict greater-than (>) to greater-than-or-equal (>=) in _requireValidAuthorization for the validAfter check. Per the EIP-3009 specification, an authorization should be valid at the exact timestamp specified by validAfter, not only after it.
Author
|
Note on commit history: This PR includes a revert of a previous experimental commit (2c2f3a1) that attempted broader security fixes. That commit was reverted because it introduced unintended scope creep — mixing unrelated changes with this boundary fix. This PR intentionally focuses only on the validAfter operator change to keep the diff minimal and reviewable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix off-by-one error in
_requireValidAuthorizationwherevalidAfterboundary check used strict greater-than (>) instead of greater-than-or-equal (>=), causing authorizations to be rejected at the exactvalidAftertimestamp.Detail
In
EIP3009.sol, the_requireValidAuthorizationfunction checks whether the current block timestamp satisfies thevalidAfterconstraint. The original code used:require(now > validAfter, "FiatTokenV2: authorization is not yet valid");Per the EIP-3009 specification, an authorization should be considered valid at the
validAftertimestamp, not only after it. The asymmetry withvalidBefore(which correctly uses strict<) confirms this is a bug:validAfter: authorization is valid from this time →>=validBefore: authorization is valid until this time →<Fix: Changed
>to>=on line 320 ofEIP3009.sol.This affects all functions that rely on
_requireValidAuthorization:_transferWithAuthorization(both overloads)_receiveWithAuthorization(both overloads)Testing
block.timestamp == validAfterblock.timestamp < validAfterblock.timestamp >= validBeforevalidAfterandvalidBeforeDocumentation
No documentation changes required. This is a single-operator fix that aligns the implementation with the EIP-3009 specification.
Requested Reviewers: @Kewe63