burn() doesn’t call ERC721 _burn()
The burn() function in CollateralizedDebt.sol does not call the ERC721 _burn() function, so the ERC721 token representing a collateral position is not destroyed when a user burns their position and receives their funds. An attacker could continue to hold the ERC721 token after burning, potentially allowing them to reuse or misrepresent the position.
Originally disclosed on Code4rena
Submitted by sirhashalot
The CollateralizedDebt.sol contract is a ERC721 token. It has a mint() function, which uses the underlying safeMint() function to create an ERC721 token representing a collateral position. The burn() function in CollateralizedDebt.sol should reverse the actions of mint() by burning the ERC721 token, but the ERC721 _burn() function is never called. This means a user can continue to hold their ERC721 token representing their position after receiving their funds. This is unlike the burn() function found in Bond.sol, Insurance.sol, and Liquidity.sol, which all call the _burn() function (though note the _burn() function in these other Timeswap Convenience contracts is the ERC20 _burn()).
Proof of Concept
The problematic burn() function is found in CollareralizedDebt.sol https://github.com/code-423n4/2022-01-timeswap/blob/bf50d2a8bb93a5571f35f96bd74af54d9c92a210/Timeswap/Timeswap-V1-Convenience/contracts/CollateralizedDebt.sol#L80-L88
Compare this function to the burn() functions defined in the other Timeswap Convenience contracts, which contain calls to _burn()
Recommended Mitigation Steps
Include the following line in the burn() function _burn(id);
Mathepreneur (Timeswap) acknowledged:
If decided not to burn the ERC721 token at all. The burn in this context is burning the debt and collateral locked balance in the ERC721 token.
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
The burn() function in CollateralizedDebt.sol omits the call to the ERC721 _burn() function, so the token is not destroyed.
Impact
A user could retain their ERC721 token after burning their position and receiving funds, potentially allowing them to reuse or misrepresent the position, though the report does not detail further exploitation.
What the attacker needed
A position represented by an ERC721 token
The fix
The burn() function should be modified to include a call to _burn(id) to destroy the ERC721 token.
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.
This contract creates digital tokens (like receipts) that represent a user's collateral. When a user closes their position, the contract should destroy that receipt, but it forgets to. So the user keeps the receipt even after getting their money back, which could let them pretend they still have a position.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.