fix: fail-closed compliance screening and add server-side enforcement in payout - #27
Open
memosr wants to merge 1 commit into
Open
fix: fail-closed compliance screening and add server-side enforcement in payout#27memosr wants to merge 1 commit into
memosr wants to merge 1 commit into
Conversation
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.
Problem
Two issues combine into a fail-open compliance vulnerability.
Issue 1 — Compliance screening defaults to PASS on errors
app/api/compliance/screen/route.ts:87-93returns HTTP 500 withresult: "PASS"on any exception (Circle API timeout, DNS failure, rate limit, malformed response):The frontend callers (
components/send-button.tsx,components/transfer-dialog.tsx) callresponse.json()without checkingresponse.ok, store the body incomplianceData, and only block the Send action whencomplianceData?.result === "FAIL". A 500 body withresult: "PASS"is indistinguishable from a clean 200 PASS at the UI layer, so the Send button activates.Issue 2 — No server-side compliance enforcement in payout
Neither
/api/payout/route.tsnor/api/wallet/transfer/route.tsperforms a server-side compliance re-check. Screening is advisory client-side only. A directcurlto/api/payoutbypasses compliance entirely, regardless of the fail-open bug above.Exploit path
A sanctioned address submits a transfer. The attacker triggers (or waits for) a transient failure in Circle's screening service. The 500+PASS response flows to the client, the Send button enables, and the transfer executes. No server-side backstop catches it.
Fix
Part 1 — Fail-closed in
compliance/screen/route.ts} catch (error) { console.error('Compliance screening error:', error); return NextResponse.json( { success: false, - result: 'PASS', - message: 'Compliance screening service is currently unavailable. Proceeding with caution.', + result: 'FAIL', + message: 'Compliance screening unavailable. Transaction blocked.', }, - { status: 500 } + { status: 503 } ); }503 Service Unavailableis semantically correct here and won't look like a success to any future HTTP-layer guards.Part 2 — Server-side compliance enforcement in
payout/route.tsReused the existing
screenAddressandmapComplianceResultutilities (the same functionscompliance/screen/route.tsuses — no duplication). After input validation and chain resolution, the recipient address is screened on Circle. Any result other than"PASS"(i.e."FAIL"or"REVIEW") returns 403 before wallets are fetched, balances checked, or any on-chain action taken.A direct
curlto/api/payoutnow goes through the same compliance gate as the UI.Impact