Skip to content

Require SNIP-12 request signing for high-value mutating billing endpoints in src/routes/billing.ts #656

Description

@Jagadeeshftw

Description

src/auth/challenge.ts already builds SNIP-12 typed data (CHALLENGE_TYPES, buildTypedChallenge) for wallet-signature login, but that pattern is not reused anywhere for individual mutating actions after login. src/routes/billing.ts mutating endpoints currently rely solely on the session bearer token plus an Idempotency-Key. For the highest-value billing mutations, require a fresh SNIP-12 signature over the specific request payload so a stolen/replayed session token alone cannot mutate billing state.

Requirements and context

  • Extend the typed-data pattern from src/auth/challenge.ts with a BillingAction type covering profile/payment-method mutations
  • Add a requireSignedAction middleware verifying the signature against the caller's known wallet public key before the handler runs
  • Return a clear, non-sensitive 400 (not 401/403) when the signature is missing or invalid, distinct from session auth failures
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested execution

Fork the repo and create a branch

git checkout -b feature/billing-request-signing

Implement changes

  • Update/Write: src/routes/billing.ts
  • Update/Write: src/auth/challenge.ts
  • Add/Update tests: src/routes/billing.test.ts
  • Add documentation: docs/routes/billing.md
  • Include clear code comments and TS types
  • Validate security assumptions

Test and commit

  • Run tests: pnpm test
  • Cover edge cases
  • Include test output and security notes

Example commit message

feat: require SNIP-12 request signing on billing mutations

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuebackendBackend / API worksecuritySecurity hardening / audit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions