fix(cashout): enforce caller wallet ownership on cashout mutations - #465
Open
islandbitcoin wants to merge 4 commits into
Open
fix(cashout): enforce caller wallet ownership on cashout mutations#465islandbitcoin wants to merge 4 commits into
islandbitcoin wants to merge 4 commits into
Conversation
requestCashOut and initiateCashOut never read the auth context: any authenticated user could create and execute cashout offers against any walletId, forcing liquidation of another account's USD/USDT balance. Payout stayed bound to the victim's own bank accounts, so the impact was unauthorized liquidation rather than direct theft, but the action was fully unauthorized either way. CashoutManager now takes the caller's accountId and rejects foreign wallets before any Ibex/ERPNext side effect; both resolvers pass domainAccount.id, matching the existing lnurl-payment-send pattern. New unit spec covers the cross-account rejection on both entry points.
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.
Summary
requestCashOutandinitiateCashOutenforced only "any valid session" — the resolvers never readdomainAccount, so any authenticated user could create and execute cashout offers against anywalletId, forcing liquidation of another account's USD/USDT balance. Payout stayed bound to the victim's own ERPNext bank accounts (verifyBankAccount), so this was unauthorized liquidation / griefing rather than direct theft — but fully unauthorized either way.CashoutManager.createOffer/executeCashoutrequire the caller'saccountIdand reject foreign wallets before any Ibex/ERPNext side effect. Both resolvers passdomainAccount.id, matching the existinglnurl-payment-sendpattern; the prior provided-vs-settlement wallet check remains as defense in depth.cashout-manager-authz.spec.tsproves the cross-account rejection on both entry points (written red-first) and that legitimate flows still proceed. Existing offers suites updated to the new signatures.Test plan
npx jest --config ./test/flash/unit/jest.config.js offers— 16/16 pass (4 suites)tsc --noEmit -p tsconfig.d.json && tsc --noEmit— cleannpx eslinton changed files — cleantest/flash/integration/offers/*) updated to the new signatures; require the docker dev stack to run