Submitted by LokiThe5th, also found by EV_om, sin1st3r__ (1, 2), trachev, rbserver, juancito, yashar, Coverage, hals, evmboi32, roleengineer, KupiaSec, oakcobalt, Giorgio, said, krikolkk, BI_security, SBSecurity, Qkite, rokinot, anshujalan, and 0xAlix2
The Guard.sol contract is enabled on Safes and uses the _checkTransaction function to ensure that transactions that the Safe executes do not transfer the asset out of the Safe.
The checkTransaction function achieves this by isolating the function selector and checking that it is not a disallowed function selector. For instance: safeTransferFrom, transferFrom, approve, enableModule, etc.
The list does not, however, check for calls to burn the token, neither does it check if it is a permit. The sponsor has noted the following:
But this does not acknowledge the fact that an ERC721/ERC1155 implementation can still be an honest implementation and have extra functionality. In particular, the burn function is a common addition to many ERC721 contracts, usually granted through inheriting ERC721Burnable.
For example, the following projects all have a burn function, and Safes protected by Guard.sol that hold these NFTs will be vulnerable to loss of assets via a malicious renter:
These are three that are in the top 10 projects on Opensea at the time of writing.
We can see in the Guard.sol file that certain function selectors are imported to be tested against:
From the _checkTransaction function we see that there is no check for burn, burnFrom or permit.
A malicious renter who is renting the asset can still execute burn (common), burnFrom (rare) or permit (popularized by Uni v3), which will lead to loss of the asset.
The below test can be placed in the CheckTransaction.t.sol test file. It should be run with forge test --match-test test_PoC -vvvv
The console output is:
This shows that the checkTransaction would not protect against calls to burn the asset.
Although not a catch-all, adding checks for burn, burnFrom and permit functions (which are common in smart contracts) should prevent this in most cases.
Selectors:
In the Guard.sol file:
Please note that there may be other flavours of the permit function that have different signatures.
141345 (Lookout) commented:
Alec1017 (reNFT) acknowledged and commented:
0xean (Judge) decreased severity to Medium and commented:
Alec1017 (reNFT) commented:
lokithe5th (Warden) commented:
0xStalin (Warden) commented:
reNFT mitigated:
Status: Mitigation confirmed. Full details in reports from EV_om, sin1st3r__ and juancito.
