Platform: Code4rena
Start Date: 05/10/2022
Pot Size: $50,000 USDC
Total HM: 2
Participants: 80
Period: 5 days
Judge: GalloDaSballo
Id: 168
League: ETH
Rank: 34/80
Findings: 1
Award: $114.82
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: dipp
Also found by: 0x4non, 0x52, 0xRobocop, 0xc0ffEE, 8olidity, Ch_301, Jeiwan, Junnon, KIntern_NA, Lambda, M4TZ1P, MiloTruck, Nyx, PaludoX0, Ruhum, RustyRabbit, Soosh, TomJ, Trust, arcoun, aviggiano, bardamu, cryptonue, csanuragjain, d3e4, enckrish, exd0tpy, hansfriese, jayphbee, joestakey, ladboy233, minhquanym, minhtrng, nicobevi, obront, polymorphism, rokinot, romand, rotcivegaf, rvierdiiev, saian, serial-coder, trustindistrust, zzykxx
114.8239 USDC - $114.82
StandardPolicyERC1155.sol
doesn't validate the order.amount
properly.
This contract is used to check a policy for matching orders of ERC1155 tokens.
But it doesn't check the amount of ERC1155 token properly and traders might lose their funds unexpectedly.
As we can see here, order.amount
can be greater than 1 for ERC1155 tokens.
But canMatchMakerAsk and canMatchMakerBid don't validate the amounts of buy/sell orders at all and return just 1 as an amount
.
So the below scenario is possible.
Alice
created a buy order tokenId = ERC1155 tokenId, amount = 10, price = 1 ETH
Bob
created a sell order with the same ERC1155 token with amount = 10, price = 1 ETH
Bob
executed the orders successfully using execute()
amount
will be 1 always because the functions in StandardPolicyERC1155.sol
return 1 here and here.Alice
will get 1 ERC1155 token for 1 ETH although she wanted to buy 10 tokens for 1 ETH.Solidity Visual Developer of VSCode
We should validate the amount properly and return the correct value with canMatchMakerAsk()
and canMatchMakerBid()
.
function canMatchMakerAsk(Order calldata makerAsk, Order calldata takerBid) external pure override returns ( bool, uint256, uint256, uint256, AssetType ) { return ( (makerAsk.side != takerBid.side) && (makerAsk.paymentToken == takerBid.paymentToken) && (makerAsk.collection == takerBid.collection) && (makerAsk.tokenId == takerBid.tokenId) && (makerAsk.matchingPolicy == takerBid.matchingPolicy) && (makerAsk.price == takerBid.price) && (makerAsk.amount == takerBid.amount), //++++++++++++++++++++++ makerAsk.price, makerAsk.tokenId, makerAsk.amount, //+++++++++++++++++++++++++ AssetType.ERC1155 ); }
#0 - GalloDaSballo
2022-10-13T22:27:29Z