If we look at the create function in the delegateToken contract we can see the line :
TransferHelpers.checkAndPullByType(erc1155PullAuthorization, delegateInfo);
this line calls the TransferHelpers.checkAndPullByType so if we look into it we can see :
we can see that Structs.Uint256 storage erc1155Pulled this is storage and if (erc1155Pulled.flag == ERC1155_NOT_PULLED) { erc1155Pulled.flag = ERC1155_PULLED; it is set to ERC1155_PULLED and now back at the checkAndPullByType the pullERC1155AfterCheck(erc1155Pulled, delegateInfo.amount, delegateInfo.tokenContract, delegateInfo.tokenId); is called. If we look into it :
now this if (erc1155Pulled.flag == ERC1155_PULLED) will revert because it is true and we know that in the
checkERC1155BeforePull function it was storage and was set to already set to ERC1155_PULLED.
Tools Used
manual review.
Recommended Mitigation Steps
set to ERC1155_PULLED only after the actual pull and remove in the checkERC1155BeforePull function.
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/main/src/DelegateToken.sol#L296-L322
Vulnerability details
Impact
ERC1155 tokens can never be used.
Proof of Concept
If we look at the
create
function in the delegateToken contract we can see the line :TransferHelpers.checkAndPullByType(erc1155PullAuthorization, delegateInfo);
this line calls theTransferHelpers.checkAndPullByType
so if we look into it we can see :so when it is ERC1155, let us look at the
checkERC1155BeforePull(erc1155Pulled, delegateInfo.amount)
:we can see that
Structs.Uint256 storage erc1155Pulled
this is storage andif (erc1155Pulled.flag == ERC1155_NOT_PULLED) { erc1155Pulled.flag = ERC1155_PULLED;
it is set toERC1155_PULLED
and now back at thecheckAndPullByType
thepullERC1155AfterCheck(erc1155Pulled, delegateInfo.amount, delegateInfo.tokenContract, delegateInfo.tokenId);
is called. If we look into it :now this
if (erc1155Pulled.flag == ERC1155_PULLED)
will revert because it is true and we know that in thecheckERC1155BeforePull
function it was storage and was set to already set toERC1155_PULLED
.Tools Used
manual review.
Recommended Mitigation Steps
set to
ERC1155_PULLED
only after the actual pull and remove in thecheckERC1155BeforePull
function.Assessed type
DoS