fix(schema): add auth challenges and rate limiting tables and OCC RPCs - #217
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| INSERT INTO public.auth_challenges (nonce, address, expiration) | ||
| VALUES (p_nonce, p_address, p_expiration); |
There was a problem hiding this comment.
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
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| 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(); |
There was a problem hiding this comment.
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
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| $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; |
There was a problem hiding this comment.
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
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
User description
close #204
CodeAnt-AI Description
Add shared authentication challenge storage and request rate limiting
What Changed
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:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
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:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
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.