Skip to content

feat(lint): add solmate-safe-transfer-lib detector#15580

Open
0xMars42 wants to merge 1 commit into
foundry-rs:masterfrom
0xMars42:feat/lint-solmate-safe-transfer-lib
Open

feat(lint): add solmate-safe-transfer-lib detector#15580
0xMars42 wants to merge 1 commit into
foundry-rs:masterfrom
0xMars42:feat/lint-solmate-safe-transfer-lib

Conversation

@0xMars42

@0xMars42 0xMars42 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Adds the solmate-safe-transfer-lib lint from #14381 (Low).

Reports a reference, called or used as a value, that resolves to safeTransfer, safeTransferFrom or safeApprove declared in a library named exactly SafeTransferLib. 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 := 1 on 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. safeTransferETH involves no token code and stays clean.

Resolution goes through the type checker, so the using for method form, the library-qualified form, import aliases (fixture UsesAliasedImport with an auxiliary file) and references used as values are recognized, while same-name functions of other libraries stay out (TransferHelper style, in the fixture).

Aderyn's detector flags the import directive whose path contains solmate and SafeTransferLib; 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 safeTransferETH reports exactly the three token operations.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant