Open c4-submissions opened 1 year ago
GalloDaSballo changed the severity to QA (Quality Assurance)
I believe this is a valid medium, as it's not self-inflicted.
Please note that, unlike other similar duplicates that state this will occur if the user targets a contract that does not have an onERC721Received
hook (i.e. user error), I'm stating that this issue can occur even if the user does everything correctly (i.e., when the user transfers to a delegateInfo.principalHolder
that has an onERC721Received
hook):
In some scenarios, this could result in a locked principal if the receiver is a smart contract that expects an onERC721Received callback.
This is very likely to occur, especially when delegateInfo.principalHolder != msg.sender
and delegateInfo.principalHolder
is not an EOA.
If you can buy X And you send it to Y And Y requires you to call it via safeTransfer And you don't You made a mistake
That's why it's self-rekt
If Alice wants to protect the token by adding it to a magical contract that needs it to receive a callback ontransfer, she can mint and then transfer the token
The system has to defend itself, not some other contract
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/main/src/DelegateToken.sol#L321 https://github.com/code-423n4/2023-09-delegate/blob/main/src/PrincipalToken.sol#L33-L37
Vulnerability details
Impact
When a user locks their tokens inside the escrow, they can choose where to receive the principal token, which is necessary to withdraw their original tokens.
In some scenarios, this could result in a locked principal if the receiver is a smart contract that expects a
onERC721Received
callback.Proof of Concept
DelegateToken.create
, and he provides a smart contract address as adelegateInfo.principalHolder
which expects anonERC721Received
callback.https://github.com/code-423n4/2023-09-delegate/blob/main/src/DelegateToken.sol#L321
mintPrincipal
is called:which calls
PrincipalToken(principalToken).mint
:https://github.com/code-423n4/2023-09-delegate/blob/main/src/PrincipalToken.sol#L33-L37
_mint
will not trigger anonERC721Received
callback, so the principal will be sent and locked inside the contract.Tools Used
Manual review
Recommended Mitigation Steps
Consider using
safeMint
instead ofmint
when minting aPrincipalToken
:Assessed type
ERC721