모든 풀 리퀘스트를 머지 전에 검토
같은 결함의 비용은 풀 리퀘스트의 코멘트 하나이거나, 운영 환경의 사고 하나입니다. 차이는 누군가 언제 들여다봤는지뿐입니다. 도마뱀은 두 번 봅니다. 이미 보유한 저장소 전체에서 한 번, 그리고 푸시하는 모든 줄에서 다시 한 번 — 런타임에 닿기 전에.
코드 위험 화면.
에이전트가 풀 리퀘스트에서 찾은 위험. 그것을 들여온 diff, 정확한 줄, 그리고 이미 작성한 패치. 담당자가 판단할 때까지 병합은 계속 막혀 있습니다.
Race condition in credit deduction allows a double spend
Merge rejected. The agent stopped this pull request and notified its author. Nothing merges until an owner decides.
TL;DR
Two concurrent requests can both pass the balance check before either writes, so a workspace with 40 credits can start two 40-credit runs. The read and the write are separate statements with no lock and no transaction between them.
Business Impact
Credits are the billing unit, so this is unmetered consumption of paid compute. It is reachable by any authenticated customer with two clients and no special access, and it leaves no anomaly in the ledger — both writes are individually valid.
Technical Analysis
deductCredits reads the balance with a plain SELECT at line 69 and writes the decremented value at line 79. Nothing holds a row lock across the two, and the enclosing handler does not open a transaction, so two callers interleave read-read-write-write and the second write overwrites the first. FOR UPDATE on the read, or a single conditional UPDATE … WHERE balance >= :cost, closes it.
Assumptions
The agent read the diff and the two files it touches. It did not run the service: this is a static finding about a code path, graded on reachability from an authenticated route, not a reproduction against a deployed environment.
Affected Context
- Repository
- acme/platform
- Service
- billing
- Entry point
- POST /api/app/runs
- Scope
- Acme Production Edge
Classification
- Category
- Race condition
- CWE
- CWE-367 · Time-of-check time-of-use race condition
- OWASP
- A04:2021 — Insecure Design
- Confidence
- High (94%)