Skip to content

Harden self-service API auth and redemption integrity#22

Merged
darthnithin merged 3 commits intomainfrom
codex/security-fixes
Apr 1, 2026
Merged

Harden self-service API auth and redemption integrity#22
darthnithin merged 3 commits intomainfrom
codex/security-fixes

Conversation

@darthnithin
Copy link
Copy Markdown
Owner

Summary

  • require verified app-user auth for self-service donor and GET Tools routes, and derive identity server-side instead of trusting client userId
  • tighten related surfaces by fixing /api/users/me, replacing reflective CORS with an allowlist, and moving revalidation secrets off the URL
  • make redemption recording idempotent with a unique redemptions.claim_code_id constraint and include the security audit report in the repo

Testing

  • npm run typecheck
  • npm run db:generate

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 25, 2026

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

Project Deployment Actions Updated (UTC)
slugswap Ready Ready Preview, Comment Apr 1, 2026 10:55pm

@darthnithin darthnithin merged commit 13af8ff into main Apr 1, 2026
3 of 4 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ab15f7801

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +727 to +729
if (insertedRedemptions.length === 0) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return redemption result only after idempotent write succeeds

In concurrent check-redemption polls, the transaction can hit updatedClaims.length === 0 or insertedRedemptions.length === 0 (because another request already redeemed the claim), but those return statements exit only the transaction callback, not detectRedemption. The function then still returns { amount, accountName }, so the API can report a redemption amount derived from the current balance delta even when this request did not persist that amount, which can disagree with the stored claim/redemption record. This shows up when overlapping polls race on the same claim.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is ok

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.

1 participant