Skip to content

fix(schema): add auth challenges and rate limiting tables and OCC RPCs - #217

Merged
Soumen1080 merged 1 commit into
mainfrom
Samanway2405
Aug 31, 2026
Merged

fix(schema): add auth challenges and rate limiting tables and OCC RPCs#217
Soumen1080 merged 1 commit into
mainfrom
Samanway2405

Conversation

@Soumen1080

@Soumen1080 Soumen1080 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

User description

close #204


CodeAnt-AI Description

Add shared authentication challenge storage and request rate limiting

What Changed

  • Authentication challenges are stored centrally so multiple application instances can create and consume the same login challenges
  • Expired challenges are removed automatically, and each wallet address is limited to a fixed number of pending challenges
  • Challenges can only be consumed once and only before their expiration time
  • Authentication requests can be limited by key within a time window, with responses showing whether access is allowed, remaining requests, and reset time

Impact

✅ Consistent authentication across application instances
✅ Fewer replayed or stale login challenges
✅ Clearer rate-limit decisions

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Aug 31, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR dad56b6 Aug 31, 2026 · 11:51 11:55

@codeant-ai

codeant-ai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
stellar-star Error Error Aug 31, 2026 11:51am

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Aug 31, 2026
@Soumen1080
Soumen1080 merged commit 667815c into main Aug 31, 2026
3 of 5 checks passed
Comment thread supabase-setup.sql
Comment on lines +1334 to +1335
INSERT INTO public.auth_challenges (nonce, address, expiration)
VALUES (p_nonce, p_address, p_expiration);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The public challenge-recording RPC accepts arbitrary addresses and non-expiring timestamps, allowing one persistent row per new address and unbounded table growth. [resource leak]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** supabase-setup.sql
**Line:** 1334:1335
**Comment:**
	*Resource Leak: The public challenge-recording RPC accepts arbitrary addresses and non-expiring timestamps, allowing one persistent row per new address and unbounded table growth.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread supabase-setup.sql
Comment on lines +1390 to +1393
INSERT INTO public.auth_rate_limits (key, count, window_start, updated_at)
VALUES (p_key, 1, p_now, NOW())
ON CONFLICT (key) DO UPDATE
SET count = 1, window_start = p_now, updated_at = NOW();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The public rate-limit RPC inserts a permanent row for every new p_key, allowing unauthenticated callers to grow this table and its index without bound. [resource leak]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** supabase-setup.sql
**Line:** 1390:1393
**Comment:**
	*Resource Leak: The public rate-limit RPC inserts a permanent row for every new `p_key`, allowing unauthenticated callers to grow this table and its index without bound.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread supabase-setup.sql
$fn$;

GRANT EXECUTE ON FUNCTION public.record_auth_challenge(TEXT, TEXT, BIGINT, INT) TO anon, authenticated;
GRANT EXECUTE ON FUNCTION public.consume_auth_challenge(TEXT, TEXT, BIGINT, BIGINT) TO anon, authenticated;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: anon can call consume_auth_challenge with values from the challenge response and delete the challenge before the signed verification request consumes it. [security]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** supabase-setup.sql
**Line:** 1423:1423
**Comment:**
	*Security: `anon` can call `consume_auth_challenge` with values from the challenge response and delete the challenge before the signed verification request consumes it.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make wallet authentication safe on more than one server instance

1 participant