Fix unauthenticated BaZi comprehensive AI cost abuse and cache IDOR - #41
Draft
cursor[bot] wants to merge 1 commit into
Draft
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Unauthenticated callers could burn Groq via four callTextAI prompts and
read/write users/{userId}/baziReports through the Admin SDK using any
body userId. Require owned Firebase Bearer auth and AI rate limiting;
send the token from the BaZi tools page.
Co-authored-by: ANDY OLIVER ROZARIO <AndyOliverR@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
11 tasks
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.
What changed
POST /api/bazi/comprehensivebefore Admin cache R/W or Groq generation (4×callTextAI).withRateLimit(rateLimiters.ai).fetchWithFirebaseAuthRequired.Why this change is safe
userIdwas trusted with no auth; Admin SDK could read/writeusers/{userId}/baziReports, and unauthenticated callers could burn Groq.POST /api/bazi/comprehensivewith anyuserId+ valid BaZi reading JSON and no Authorization → 4 LLM calls and/or victim cache access./api/tools/bazi/analysis, not this route.Verification
pnpm exec eslinton touched files (0 errors; pre-existinganywarnings in route helpers)pnpm test— 62 suites / 325 tests passedpnpm run lint:securitypassednanoidadvisory unrelated to this changeRegression prevention
tests/integration/bazi-comprehensive-auth.test.ts(401 without auth, 401 invalid token, 403 mismatch, 200 owned → 4 AI calls)./api/tools/bazi/analysis.Release checklist (solo-friendly)
main