Fix unauthenticated energy-healing Groq cost abuse - #43
Draft
cursor[bot] wants to merge 2 commits into
Draft
cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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/tools/energy-healing/analysisbefore any Groq structured-report call.lib/energyHealing/runEnergyHealingAnalysis.tsso Stage B calls analysis in-process (no unauthenticated HTTP loopback).energyHealingIntelligencesends auth viafetchWithFirebaseAuthRequired.tests/integration/energy-healing-analysis-auth.test.tslocking 401-without-token and owned success paths.Why this change is safe
runStructuredReportAI/ Groq (llama-3.3-70b-versatile, up to 3 attempts) with no auth or rate limit. Stage B and clients hit it over HTTP without Authorization.POST /api/tools/energy-healing/analysiswith{"method":"chakra","userProfile":{...}}burnsGROQ_API_KEYwhen configured (Stage B alone issues 5 method calls per user).Verification
pnpm exec eslinton touched files (0 errors; pre-existinganywarnings)energy-healing-analysis-auth(4/4) + plan-profile-generate suite (52/52)pnpm test --runInBand— 62 suites / 325 tests passedpnpm run lint:securitypassednanoidadvisory (unrelated)Regression prevention
tests/integration/energy-healing-analysis-auth.test.tsthat fails if auth is removed.Release checklist (solo-friendly)
main(consider with or after PR Fix unauthenticated palmistry Groq vision cost abuse #40 for consistent paid-proxy auth patterns)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.