Buyer only receives 1 token when fulfilling ERC1155 order #63
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate
This issue or pull request already exists
Lines of code
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/matchingPolicies/StandardPolicyERC1155.sol#L33
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/matchingPolicies/StandardPolicyERC1155.sol#L59
Vulnerability details
Impact
The
StandardPolicyERC1155
contract always returns1
for theamount
return value. Thus, when fulfilling an order, the exchange only transfers one token from the seller to the buyer, not the value specified in the order.The user still pays the full price but receives fewer tokens than expected. This is a direct loss of funds and will occur for every ERC1155 order where
amount > 1
.Proof of Concept
The user can specify the number of tokens in the order here: https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/OrderStructs.sol#L19
The actual number of tokens that is sent when the order is fulfilled is determined using
_canMatchOrder()
: https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L145The function calls the respective policy, in our case
StandardPolicyERC1155
: https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L422-L430The policy's functions always return
1
for theamount
return value instead oforder.amount
: https://github.com/code-423n4/2022-10-blur/blob/main/contracts/matchingPolicies/StandardPolicyERC1155.sol#L33https://github.com/code-423n4/2022-10-blur/blob/main/contracts/matchingPolicies/StandardPolicyERC1155.sol#L59
Thus, in the end, only one token is sent to the buyer no matter what the value of
order.amount
was. The value is ignored throughout the whole exchange contract.Tools Used
none
Recommended Mitigation Steps
Check that the
amount
value of both orders matches and then return that value instead of 1.The text was updated successfully, but these errors were encountered: