Closed c4-submissions closed 1 year ago
GalloDaSballo marked the issue as duplicate of #279
GalloDaSballo changed the severity to QA (Quality Assurance)
Noted, will keep as-is for identical TransferHelper
functionality across both create and flashloan functions. Given that ERC20s, ERC721s, and ERC1155s are custodied in the same contract we can't skips checks on token types. The approved operator can either (1) call the flashloan function itself, in which case msg.sender == info.receiver
; (2) transfer the asset to msg.sender
at the conclusion of its work
0xfoobar (sponsor) acknowledged
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/interfaces/IDelegateToken.sol#L99-L103 https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L395 https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/libraries/DelegateTokenTransferHelpers.sol#L31-L38
Vulnerability details
Impact
An approved operator can't use the
DelegateToken::flashloan()
if the escrowed asset is an ERC721.Proof of Concept
Like it's documented in the
IDelegateToken::flashloan()
: https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/interfaces/IDelegateToken.sol#L99-L103A potential approved operator on the contract supposed to be able to use the
flashloan()
function. But if we look a little closer in the funtion we can see for an ERC721 token type, the following check is made:https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L395
And the
checkERC721BeforePull()
functionhttps://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/libraries/DelegateTokenTransferHelpers.sol#L31-L38
If the
msg.sender
is not the owner of the escrowed ERC721, the function revert. And because the approved is not the original owner of the NFT, it revert.It can be problematic if the user who has delegated his token relies on the fact that the approved operator he has chosen can't use the
flashloan()
function (e.g. the owner of the ERC721 is a smart contract that uses the delegate services and in his architecture, the protocol relies on another specific smart contract to useflashloan()
). This can cause a bad user experience.You can add this test in
DelegateToken.t.sol
and launch the command with foundry:forge test --match-test testApprovedUserRevertFlashloan -vvvvv
PoC :Tools Used
Manual Review
Recommended Mitigation Steps
Make changes to let the approved operator make the flashloan (e.g. you can add a similar function like
checkERC721BeforePull()
but in changing the verification to let the approved operator make the flashloan)Assessed type
Access Control