no reentrancy guard on mint() function that has a callback
The mint() function in CollateralizedDebt.sol calls _safeMint(), which invokes a callback to the recipient address. Without a reentrancy guard, a malicious recipient could re-enter the function during that callback, potentially causing unexpected behaviour.
Submitted by jayjonah8, also found by Fitraldys
In CollateralizedDebt.sol, the mint() function calls _safeMint() which has a callback to the “to” address argument. Functions with callbacks should have reentrancy guards in place for protection against possible malicious actors both from inside and outside the protocol.
Proof of Concept
- https://github.com/code-423n4/2022-01-timeswap/blob/main/Timeswap/Timeswap-V1-Convenience/contracts/CollateralizedDebt.sol#L76
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L263
- https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L395
Recommended Mitigation Steps
Add a reentrancy guard modifier on the mint() function in CollateralizedDebt.sol
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 mint() function lacks a reentrancy guard despite calling _safeMint(), which performs an external callback to the recipient.
Impact
A malicious recipient could re-enter mint() during the callback, potentially disrupting contract state or minting behaviour, though the report does not demonstrate a concrete exploit.
What the attacker needed
Attacker controls the recipient address
The fix
Add a reentrancy guard modifier to the mint() function in CollateralizedDebt.sol.
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 a token to another contract, it can trigger code in the receiving contract. If the sending function does not protect itself, the receiver can call back into the same function before the first call finishes. This is called reentrancy and can lead to repeated actions or inconsistent state.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.