Repository navigation
escrow: test the three wrong-account attacks on take_offer - #213
Open
mikemaccana wants to merge 1 commit into
Open
mikemaccana wants to merge 1 commit into
mikemaccana wants to merge 1 commit into
Conversation
Nothing tested the taker substituting an account in take_offer. Each version now runs three attacks and asserts the exact error, and that the vault and both parties' token balances are unchanged: - Bob names a TSLAx account he owns as maker_token_account_b, so his payment would come back to him - Bob passes Alice's first offer with her second offer's vault - Bob passes his own worthless mint as token_mint_b Applied to anchor-v1, anchor, native and quasar. With each check removed from the program, its test fails. Claude-Session: https://claude.ai/code/session_01GZHin6BQpAqf7j2ucSZWkx
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.
What changes
The escrow program defends against a taker passing the wrong account to
take_offer, but no test ran those attacks. Each version now has three tests.Each test asserts the exact error the defense raises, and checks that the vault and both parties' token balances are unchanged.
test_take_offer_rejects_taker_account_as_maker_token_account_b: Bob names a TSLAx account he owns asmaker_token_account_b, so his payment would come back to him.ConstraintTokenOwnerConstraintAddressTokenAccountMismatchHasOneMismatchtest_take_offer_rejects_vault_of_another_offer: Alice has two offers open, and Bob passes the first offer with the second offer's vault.ConstraintTokenOwnerConstraintAddressTokenAccountMismatchHasOneMismatchtest_take_offer_rejects_worthless_token_mint_b: Bob mints a worthless token of his own and passes it astoken_mint_b.ConstraintHasOneConstraintAddress, because that version checksaddress = offer.token_mint_bMintMismatchHasOneMismatchTwo details:
Each version's
CHANGELOG.mdhas an entry. No program source changes.Testing
cargo testpasses in every version:Each test fails without its defense. For each test, the check was removed from the program, the program rebuilt, and the test failed:
The programs were restored afterwards.
Generated by Claude Code