fix(bridge): correct Stellar deposit asset validation#1094
Merged
Conversation
Three correctness fixes in the Stellar->TFChain deposit path (processTransaction) and balance reporting (StatBridgeAccount): 1. Credited-effect asset check used && instead of ||, so a credit was only skipped when BOTH the asset code and issuer were wrong. A credit with the right code but a forged/wrong issuer (or vice-versa) passed the gate and could be minted. Now requires both to match. 2. The per-operation loop did `return nil, nil` on the first non-payment operation, abandoning the entire transaction and silently dropping any legitimate payment operations after it (lost deposits / missing mints). Now skips non-payment ops individually with `continue`. 3. Added operation-level asset validation: even after the effect check, each payment amount must itself be TFT, otherwise a non-TFT payment to the bridge in the same transaction would be summed and minted as TFT. Non-TFT payments are now skipped and logged as an alert. 4. StatBridgeAccount matched the TFT balance with || (code OR issuer), which could return an unrelated asset's balance; now matches on both. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 1, 2026
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
Four correctness fixes to the Stellar→TFChain deposit/mint path (
pkg/stellar/stellar.go). These were identified while decomposing the larger batching/idempotency work (#1079) into independently-shippable pieces. They are bridge-only, no runtime upgrade, and independent of the idempotency/batching changes.Two of the four are fund-safety issues that exist on
developmenttoday.Changes
1. Credited-effect asset check:
&&→||(fund-safety)processTransactionskipped anaccount_creditedeffect only when both the asset code and the issuer were wrong:So a credit with the right code but a forged/wrong issuer (or vice-versa) passed the gate. This is the only asset gate before the mint amount is summed. Fixed to require both to match (consistent with the
||-form check already used elsewhere in the file).2. Per-op loop:
return nil, nil→continue(fund-safety)The operation loop returned from the entire function on the first non-payment operation, silently discarding any legitimate payment ops later in the same transaction → lost deposits / missing mints. Now skips non-payment ops individually.
3. Operation-level asset validation (defense-in-depth)
The effect check gates entry to the loop, but each payment amount was summed without re-checking its asset. Added a per-payment
Code/Issuerguard so a non-TFT payment to the bridge in the same transaction can't be minted as TFT; non-TFT payments are skipped and logged as an alert.4.
StatBridgeAccount:||→&&Balance lookup matched on code or issuer, so it could return an unrelated asset's balance. Now matches on both. (Observability only — not fund-moving.)
Logic reasoning & regression-vector verification
(code, issuer), so it passes both the||effect gate and the new op-level guard unchanged.op.GetType() == "payment",To == bridge && From != bridge, and (new) the TFT asset match.continueonly lets later ops be evaluated under those same guards instead of aborting the tx.Code/Issuer→ skipped+logged by fix investigate test release #3. No mint.Testing
go build ./...— OKgo vet ./pkg/stellar/...— OKgofmt -l— cleanThe bridge has no Go unit harness for
processTransaction; changes are surgical and reasoned above. (A decode/mint unit test is a worthwhile follow-up.)🤖 Generated with Claude Code