fix: Remove unused AuthNonce and add UsedChallenge pruning job#382
Closed
Auwal007 wants to merge 2 commits into
Closed
fix: Remove unused AuthNonce and add UsedChallenge pruning job#382Auwal007 wants to merge 2 commits into
Auwal007 wants to merge 2 commits into
Conversation
- Dropped `AuthNonce` from Prisma schema. - Created Prisma migration to safely drop the table. - Removed unused `authNonce` references from cron prune endpoint. - Updated unit tests.
…66163399618 fix: Remove AuthNonce to fix unbounded database growth
|
@Auwal007 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3m1n3nc3
requested changes
Jun 26, 2026
3m1n3nc3
left a comment
Contributor
There was a problem hiding this comment.
Please resolve failing CI
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.
closes #359
Investigation Report
AuthNonce
app/app/api/auth/nonce/route.tswhich inserts a new nonce row and serves it over the legacy endpoint.UsedChallenge
app/lib/wallet-auth.ts.Replay protection flow diagram
Justification for Deletion
Because
/api/auth/nonceandAuthNonceare completely disconnected from the active authentication/verification strategy, they simply produce dead rows in the database upon unauthenticated invocations. Removing them immediately eliminates this vector for unbounded growth. The database footprint is decreased and dead paths are trimmed safely.Code Changes Summary
app/app/api/auth/nonce/route.tsapp/prisma/schema.prisma- RemovedAuthNoncemodel.app/prisma/migrations/20260625150646_drop_auth_nonce/migration.sql- Safely drop the model.app/app/api/cron/prune-auth/route.ts- New protected endpoint to purge challenges older than 20 minutes (exceeding the SEP-10 expiration).app/vercel.json- Scheduled/api/cron/prune-authto execute securely on an hourly interval.app/tests/api/cron-prune-auth.test.ts- Ensure the cron job is idempotent, effectively deletes stale rows, and requiresCRON_SECRETauthorization.Migration Summary
The generated migration file correctly uses
-- DropTableto delete the deprecatedauth_noncestable along with its attached indexes. This removes the legacy schema objects. Data will be completely, permanently lost, which is explicitly expected as the records hold zero system value.Security Assessment
UsedChallengerows verify transaction hashes and correctly bounce duplicate use requests inside the existing 15 minute transaction time boundary. The cron keeps them alive for 20 minutes padding to protect border edge-cases securely.verifyChallengesuccess.CRON_SECRETsecurely gates execution usingisAuthorizedCron. Unauthorized access requests automatically reject with401.