Skip to content

fix(auth): validate verify payload before SIWE import#295

Merged
GsCommand merged 2 commits into
mainfrom
codex/fix-api-auth-validation-before-siwe-import
May 22, 2026
Merged

fix(auth): validate verify payload before SIWE import#295
GsCommand merged 2 commits into
mainfrom
codex/fix-api-auth-validation-before-siwe-import

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Motivation

  • Prevent invalid or malformed requests from triggering a 503 by ensuring basic request validation happens before attempting to load or use the siwe dependency.
  • Make /api/auth/verify return 400 for missing/incorrect payload shapes and non-string message/signature inputs prior to SIWE parsing.
  • Preserve cryptographic SIWE verification and existing domain/URI/chain/statement checks so authentication remains strict.

Description

  • Add explicit request-shape validation in api/auth/verify.js to reject non-object bodies, missing message/signature, and non-string types with 400 errors.
  • Move the require('siwe') usage to after these basic validations so the SIWE dependency is only loaded for complete-looking requests, and return a 503 (dependency_unavailable) if it cannot be imported.
  • Keep all SIWE parsing, domain/URI/chain/statement checks, and parsed.verify(...) cryptographic verification unchanged so AUTHENTICATED is only returned on successful verification.
  • Update tests/api-auth.test.js to assert 400 for missing message and malformed request body and to tolerate dependency_unavailable when SIWE is absent for malformed SIWE payload tests.

Testing

  • Ran npm test (executes node --test tests/*.test.js) and all tests passed (56 passed, 0 failed), including the previously failing auth test.
  • Ran npm run check in examples/webhook-auto-verify and it passed.

Codex Task

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
commandlayer-commandlayer-org Ready Ready Preview, Comment May 22, 2026 10:35pm
commandlayer-org Ready Ready Preview, Comment May 22, 2026 10:35pm
commandlayer-org111 Ready Ready Preview, Comment May 22, 2026 10:35pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant