Skip to content

fix(siwe): reject unparseable expirationTime and notBefore - #4990

Open
SashaMIT wants to merge 1 commit into
wevm:mainfrom
SashaMIT:fix/siwe-reject-invalid-expiration-dates
Open

fix(siwe): reject unparseable expirationTime and notBefore#4990
SashaMIT wants to merge 1 commit into
wevm:mainfrom
SashaMIT:fix/siwe-reject-invalid-expiration-dates

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 8, 2026

Copy link
Copy Markdown

Summary

parseSiweMessage turns fields like Expiration Time: never into a truthy Invalid Date. In validateSiweMessage, the lifetime checks were:

if (message.expirationTime && time >= message.expirationTime) return false
if (message.notBefore && time < message.notBefore) return false

Comparisons against Invalid Date are always false, so both gates no-op and a signed SIWE message with garbage expiration / not-before still validates. This rejects unparseable dates when those fields are present (same class as thirdweb-dev/js#8875 and supabase/auth#2688).

Test plan

  • pnpm exec vitest run -c ./test/vitest.config.ts src/utils/siwe/validateSiweMessage.test.ts → 12/12
  • Cases for Expiration Time: never / garbage Not Before

Made with Cursor

Invalid Date values from parseSiweMessage (e.g. Expiration Time: never)
are truthy, so comparisons like `time >= expirationTime` are always
false and lifetime / nbf checks were skipped. Fail closed when either
field is present but not a real date (sibling of thirdweb-dev/js#8875 /
supabase/auth#2688).
@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f0ebf3d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@SashaMIT is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

jxom commented Aug 10, 2026

Copy link
Copy Markdown
Member

Two remaining cases:

  • getTime() checks JavaScript date validity, not RFC 3339. Validate the raw SIWE timestamp before converting it to Date.
  • An invalid time makes both lifetime comparisons false. Reject it before checking expirationTime or notBefore.

See the ERC-4361 validation requirements.

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

Successfully merging this pull request may close these issues.

2 participants