feat(lint): add solmate-safe-transfer-lib detector#15580
Open
0xMars42 wants to merge 1 commit into
Open
Conversation
Flags references resolving to `safeTransfer`, `safeTransferFrom` or `safeApprove` declared in a library named exactly `SafeTransferLib`. In the released solmate v6, a token call that returns no data succeeds without checking that the token has code, so a token operation against a token-less address is a silent no-op; the unreleased main branch has since added a code check to that path. `safeTransferETH` involves no token code and stays out. References are resolved through the type checker, so the `using for` method form, the library-qualified form, import aliases and references used as values are recognized, while same-name functions of other libraries (Uniswap's TransferHelper style) stay out. Aderyn flags the import directive instead; resolving the calls anchors the warning where the risk sits and skips files that import the library without using it.
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.
Adds the
solmate-safe-transfer-liblint from #14381 (Low).Reports a reference, called or used as a value, that resolves to
safeTransfer,safeTransferFromorsafeApprovedeclared in a library named exactlySafeTransferLib. In the released solmate v6, a token call that returns no data is treated as a success without checking that the token has code (success := 1on the empty-return path), so a token operation against a token-less address is a silent no-op; the unreleased main branch has since added a code check to that path.safeTransferETHinvolves no token code and stays clean.Resolution goes through the type checker, so the
using formethod form, the library-qualified form, import aliases (fixtureUsesAliasedImportwith an auxiliary file) and references used as values are recognized, while same-name functions of other libraries stay out (TransferHelperstyle, in the fixture).Aderyn's detector flags the import directive whose path contains
solmateandSafeTransferLib; resolving the calls anchors the warning where the risk sits, skips files importing the library without using it, and keeps vendored copies under the same name covered.Checked against the real solmate v6 sources: a consumer using the three token operations and
safeTransferETHreports exactly the three token operations.