no use of safeMint() as safe guard for users
The Vault contract's deposit function mints NFTs to claimers using a plain mint call rather than a safe mint, so a recipient contract that cannot handle NFTs may not be checked. The report argues this could leave users unprotected, though the text does not demonstrate a concrete exploit.
Submitted by jayjonah8, also found by bugwriter001, camden, palina, and sirhashalot
In Vault.sol the deposit() function eventually calls claimers.mint() and depositers.mint(). Calling mint this way does not ensure that the receiver of the NFT is able to accept them. \_safeMint() should be used with reentrancy guards as a guard to protect the user as it checks to see if a user can properly accept an NFT and reverts otherwise.
Proof of Concept
- https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/Vault.sol#L470
- https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/Vault.sol#L256
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L248
Recommended Mitigation Steps
Use \_safeMint() instead of mint()
ryuheimat (Sandclock) disagreed with severity:
I think _safeMint check if the recipient contract is able to accept NFT, it does not involves any issues. However we will use _safeMint.
gabrielpoca (Sandclock) commented:
@ryuheimat this is a non-issue. The mint functions called in the Vault’s deposit function are implemented by us, they just happen to be called mint.
The Depositors contract does use
_safeMint, but the Claimers contract does not.See: https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/vault/Claimers.sol#L63 https://github.com/code-423n4/2022-01-sandclock/blob/main/sandclock/contracts/vault/Depositors.sol#L53
The
depositfunction on Vault also appears to lack reentrancy guards. The issue is valid and should be addressed, despite the fact that the warden clearly did not look at the Depositors contract to see that it already used_safeMint.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the Claimers contract mints NFTs with a plain mint call instead of the safe variant, and the deposit flow lacks reentrancy guards.
Impact
NFTs could be minted to a contract that cannot accept them, and the deposit function may be open to reentrancy; the text does not show a working exploit.
What the attacker needed
A contract recipient that cannot handle NFTs
The fix
The Claimers contract should use the safe mint function and the deposit flow should add reentrancy guards; the text does not say a fix was deployed.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a contract sends an NFT to another contract, a safe transfer asks that receiving contract whether it can handle NFTs and cancels the transfer if it says no. A plain mint skips that question, so an NFT could end up somewhere it cannot be used. The report says the deposit code should use the safe version.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.