fix(web3): honor SIWE ExpirationTime when NotBefore is absent#2488
Open
vatsalpatel wants to merge 1 commit intosupabase:masterfrom
Open
fix(web3): honor SIWE ExpirationTime when NotBefore is absent#2488vatsalpatel wants to merge 1 commit intosupabase:masterfrom
vatsalpatel wants to merge 1 commit intosupabase:masterfrom
Conversation
Per EIP-4361, NotBefore and ExpirationTime are independent optional fields. The Ethereum handler gated the expiration check on NotBefore != nil, silently accepting expired messages that omitted NotBefore. MaximumValidityDuration does not compensate — a short per-message expiry was skipped entirely. Fills out test matrix coverage: NotBefore-absent + ExpirationTime-past (regression), NotBefore-absent + ExpirationTime-future (accept), both absent + too old (reject), both in future (NotBefore fires first). Closes supabase#2453
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.
What kind of change does this PR introduce?
Bug fix; Closes #2453.
What is the current behavior?
In
web3GrantEthereum(internal/api/web3.go), the SIWEExpirationTimecheck is gated onNotBefore != nil:Per EIP-4361,
not-beforeandexpiration-timeare independent optional fields. A SIWE message that setsexpirationTimebut omitsnotBeforecauses the entire expiration check to be skipped, and an expired message is accepted.The Solana handler checks the two fields independently and is unaffected.
MaximumValidityDurationdoes not compensate: it bounds validity based onIssuedAt, not the per-messageExpirationTime. A message with a 5-minute expiry is still accepted for the fullMaximumValidityDurationwindow.What is the new behavior?
Drop the
parsedMessage.NotBefore != nil &&clause soExpirationTimeis honored whenever it is set, independent ofNotBefore. The adjacentNotBeforecheck is already independent and is untouched.Test coverage is filled out across the
NotBefore/ExpirationTimematrix so future regressions are caught:TestHappyPath_MinimalMessage(existing)TestValidationRules_IssedTooLongAgo(new case)TestValidationRules_Expired(new case)TestHappyPath_FullMessage(new case)TestValidationRules_ValidatedBeforeNotBefore(existing)TestValidationRules_Expired(existing)TestHappyPath_FullMessage(existing)TestValidationRules_ValidatedBeforeNotBefore(new case)ErrNotBeforeAfterExpiration)internal/utilities/siwe/parser_test.go(existing)Additional context
!parsedMessage.ExpirationTime.IsZero()is kept alongside the nil check. The asymmetry with the Solana handler (value type, not pointer) is intrinsic to the SIWE parser types, not something to normalize.0x2638aB94…) to keep the diff tight.