Skip to content

Fix unauthenticated BaZi comprehensive AI cost abuse and cache IDOR - #41

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-622f
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-622f

Conversation

@cursor

@cursor cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown

What changed

  • Require owned Firebase Bearer auth on POST /api/bazi/comprehensive before Admin cache R/W or Groq generation (4× callTextAI).
  • Wrap the route with withRateLimit(rateLimiters.ai).
  • Send Authorization from the BaZi tools page via fetchWithFirebaseAuthRequired.
  • Add integration coverage for missing/invalid token, userId mismatch, and owned success.

Why this change is safe

Verification

  • pnpm exec eslint on touched files (0 errors; pre-existing any warnings in route helpers)
  • pnpm test — 62 suites / 325 tests passed
  • pnpm run lint:security passed
  • Dependency audit still reports pre-existing high nanoid advisory unrelated to this change
  • Playwright smoke (not required for this API auth fix)

Regression prevention

  • Added tests/integration/bazi-comprehensive-auth.test.ts (401 without auth, 401 invalid token, 403 mismatch, 200 owned → 4 AI calls).
  • Confirmed Stage B BaZi path remains on /api/tools/bazi/analysis.

Release checklist (solo-friendly)

  • CI is green
  • Ready to merge to main
  • Post-merge: hit BaZi tool while signed in and confirm comprehensive section still loads
Open in Web View Automation 

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>
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
future-seer Ready Ready Preview Aug 10, 2026 11:10am

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