PolicyEngine / PolicyEngine/policyengine-uk-chat
Billing endpoints trust arbitrary user_id
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 16h 46m
- Merged PRs (30d)
- 2
Description
Problem
Billing endpoints accept caller-supplied user identifiers without verifying that the caller owns those identifiers.
Observed behavior:
/billing/balance?user_id=...reads balance data for the requested UUID./billing/usage?user_id=...reads usage data for the requested UUID./billing/checkoutaccepts bodyuser_id.
Risk
A caller may be able to read another user's billing state or initiate checkout flows tied to arbitrary user IDs.
Expected behavior
Billing endpoints should derive the user from verified authentication and should not trust query/body user_id as identity proof.
Acceptance criteria
- Billing endpoints require authentication.
- Balance, usage, and checkout use the authenticated user's ID from verified claims.
- Caller-supplied
user_idis removed or treated only as an admin-only parameter behind explicit authorization. - Regression tests cover unauthenticated requests, wrong-user spoofing attempts, and valid authenticated requests.
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 by locating the handlers for /billing/balance, /billing/usage, and /billing/checkout, then trace the existing authentication and claim-validation entry points. Add regression coverage for unauthenticated requests, wrong-user spoofing, and valid authenticated requests; done means all three endpoints use the authenticated user's ID rather than an untrusted caller-supplied value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, authentication, authorization, payments
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100