PolicyEngine / PolicyEngine/policyengine-api
Security: gate Anthropic-backed simulation analysis with auth and quotas
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18
- Forks
- 33
- Avg merge
- 23h 40m
- Merged PRs (30d)
- 22
Description
Summary
policyengine-api exposes an unauthenticated Anthropic-backed simulation analysis endpoint.
Severity
High
Impact
Attackers can burn LLM quota and persist arbitrary analysis records by repeatedly calling the endpoint.
Affected code
policyengine_api/routes/simulation_analysis_routes.py:19-78policyengine_api/services/ai_analysis_service.py:45-77
Details
/simulation-analysis accepts public requests, and AIAnalysisService immediately initializes an Anthropic client with ANTHROPIC_API_KEY and streams a response for new prompts.
Expected behavior
LLM-backed analysis should require auth, rate limits, and ideally per-user quotas or explicit feature gating.
Suggested remediation
- Require authenticated callers
- Add rate limiting / quota enforcement
- Consider caching and internal-only generation paths for expensive prompts
- Add tests proving unauthenticated requests are denied
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with policyengine_api/routes/simulation_analysis_routes.py:19-78 and policyengine_api/services/ai_analysis_service.py:45-77 to trace how unauthenticated requests reach Anthropic-backed analysis. Review the endpoint and service behavior, then add tests proving unauthenticated requests are denied and verify the intended rate-limit or quota enforcement. Done means public callers cannot repeatedly consume LLM quota or persist arbitrary analysis records.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100