Repository navigation
feat: add balance-not-verified-after-transfer check — external token transfer with no post-balance assertion - #389
Merged
Conversation
Member
|
please recheck the codebase, your build and test is failing |
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.
Description
This PR introduces a defensive check that detects external token transfer flows where no post-transfer balance verification is performed. The new validation highlights transfer paths that assume success solely from an external call result, helping identify scenarios where token behavior may diverge from expectations.
Changes
Added a balance-not-verified-after-transfer check for external token transfers
Detects transfer flows that do not assert post-transfer balance changes
Flags cases where transfer success is inferred without balance verification
Added coverage for compliant and non-compliant transfer patterns
Documented the rationale and expected remediation approach
Motivation
External token contracts may exhibit non-standard behavior, including silent failures, transfer fees, rebasing mechanics, or unexpected return values. Relying only on an external transfer call without validating resulting balances can introduce accounting inconsistencies and hidden failure modes.
Benefits
Improves safety around external token interactions
Encourages explicit balance validation after transfers
Helps detect accounting discrepancies and silent transfer failures
Establishes a clear security guideline for token integration patterns
Reduces the risk of regressions in future transfer implementations
Example
Before
token.transfer(recipient, amount)?;
// No verification that balances changed..Closed #385