Skip to content

Fix unauthenticated energy-healing Groq cost abuse - #43

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-49b0
Draft

cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-49b0

Conversation

@cursor

@cursor cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

What changed

  • Require Firebase Bearer auth + AI rate limiting on POST /api/tools/energy-healing/analysis before any Groq structured-report call.
  • Extract lib/energyHealing/runEnergyHealingAnalysis.ts so Stage B calls analysis in-process (no unauthenticated HTTP loopback).
  • Browser energyHealingIntelligence sends auth via fetchWithFirebaseAuthRequired.
  • Add tests/integration/energy-healing-analysis-auth.test.ts locking 401-without-token and owned success paths.

Why this change is safe

Verification

  • pnpm exec eslint on touched files (0 errors; pre-existing any warnings)
  • Focused Jest: energy-healing-analysis-auth (4/4) + plan-profile-generate suite (52/52)
  • pnpm test --runInBand — 62 suites / 325 tests passed
  • pnpm run lint:security passed
  • Dependency audit still reports pre-existing high nanoid advisory (unrelated)
  • Playwright smoke (not required: API auth + Stage B helper path; tools page reads stored reports)

Regression prevention

  • Added tests/integration/energy-healing-analysis-auth.test.ts that fails if auth is removed.
  • Stage B continues via direct helper import; client wrapper updated for Bearer auth.

Release checklist (solo-friendly)

Bug / impact

Unauthenticated callers could burn Groq credits via the energy-healing analysis proxy.

Root cause

Route had no verifyUserRequest / rate limit; Stage B relied on open HTTP loopback.

Fix

Auth-gate + rate limit on the public route; in-process helper for Stage B.

Open in Web View Automation 

cursoragent and others added 2 commits August 12, 2026 11:04
Unauthenticated POST /api/tools/energy-healing/analysis could burn
GROQ_API_KEY. Gate the public route, extract an in-process helper for
Stage B, and send Bearer auth from the client intelligence wrapper.

Co-authored-by: ANDY OLIVER ROZARIO <AndyOliverR@users.noreply.github.com>
extractUserContext expects UserProfile; Stage B may pass a plain object.

Co-authored-by: ANDY OLIVER ROZARIO <AndyOliverR@users.noreply.github.com>
@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
future-seer Error Error Aug 12, 2026 11:07am

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