PolicyEngine / PolicyEngine/policyengine-uk-chat

Unauthenticated Anthropic spend path

Open
#134 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1
Forks
1
Avg merge
16h 46m
Merged PRs (30d)
2

Description

Problem

Several endpoints can trigger server-side Anthropic calls without a verified authenticated user.

Observed behavior:

  • No endpoint exposes the Anthropic key directly.
  • /chat/message, /chat/title, gateway classification, and suggestions call Anthropic server-side.
  • Anonymous chat skips billing because billing only checks when user_id is present.

Risk

Unauthenticated callers may be able to generate Anthropic spend through public backend endpoints while bypassing user billing checks.

Expected behavior

Server-side model spend should require either authenticated, billable users or a deliberately bounded anonymous/free path with strict controls.

Acceptance criteria

  • Define whether anonymous chat/title usage is allowed.
  • If not allowed, require authentication before any Anthropic-backed path.
  • If allowed, enforce explicit anonymous quotas/rate limits that do not rely on spoofable headers.
  • Ensure billing/spend checks are applied before model calls for authenticated users.
  • Regression tests cover anonymous spend attempts and valid authenticated usage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the /chat/message, /chat/title, gateway classification, and suggestions entry points to where Anthropic calls and billing checks occur. Confirm the project’s policy for anonymous usage, then inspect existing tests before adding regression coverage. Done means model calls are authenticated or explicitly quota-controlled, billing checks precede calls, and anonymous spend attempts are covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication, backend-api-design, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.