Function CreateOffererLib#calculateOrderHashAndId is used to calculate ERC20/ERC721/ERC1155 order hash and delegateTokenId. It create delegateTokenId parameter by calling DelegateTokenStorageHelpers#delegateIdNoRevert function, this function calculate delegateTokenId by uint256(keccak256(abi.encode(caller, salt))) sha256 hash algorithm, then call StorageHelpers#revertAlreadyExisted. This function will revert if delegateTokenId already existed because code below:
Lines of code
https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/libraries/CreateOffererLib.sol#L274-L281 https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/DelegateToken.sol#L280-L283 https://github.com/code-423n4/2023-09-delegate/blob/a6dbac8068760ee4fc5bababb57e3fe79e5eeb2e/src/libraries/DelegateTokenStorageHelpers.sol#L117-L120
Vulnerability details
Impact
Function
CreateOffererLib#calculateOrderHashAndId
is used to calculate ERC20/ERC721/ERC1155 order hash and delegateTokenId. It createdelegateTokenId
parameter by callingDelegateTokenStorageHelpers#delegateIdNoRevert
function, this function calculatedelegateTokenId
byuint256(keccak256(abi.encode(caller, salt)))
sha256 hash algorithm, then callStorageHelpers#revertAlreadyExisted
. This function will revert ifdelegateTokenId
already existed because code below:Proof of Concept
CreateOfferer#calculateERC721OrderHashAndId
function.CreateOfferer#calculateERC721OrderHashAndId
with same parameters.Tools Used
vscode, manual review
Recommended Mitigation Steps
Considering use
msg.sender
to calculatedelegateTokenId
.Assessed type
MEV