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: 28/80
Findings: 2
Award: $147.47
🌟 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
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 https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L433
Order amount value is ignored. If seller created order to sell amount of 3 ERC1155 tokens and buyer execute that order then in the end buyer will pay all price amiunt, but will receive only 1 token.
BlurExchange.execute
function receives token amount that should be sent to buyer from matching policies.
function _canMatchOrders(Order calldata sell, Order calldata buy) internal view returns (uint256 price, uint256 tokenId, uint256 amount, AssetType assetType) { bool canMatch; if (sell.listingTime <= buy.listingTime) { /* Seller is maker. */ require(policyManager.isPolicyWhitelisted(sell.matchingPolicy), "Policy is not whitelisted"); (canMatch, price, tokenId, amount, assetType) = IMatchingPolicy(sell.matchingPolicy).canMatchMakerAsk(sell, buy); } else { /* Buyer is maker. */ require(policyManager.isPolicyWhitelisted(buy.matchingPolicy), "Policy is not whitelisted"); (canMatch, price, tokenId, amount, assetType) = IMatchingPolicy(buy.matchingPolicy).canMatchMakerBid(buy, sell); } require(canMatch, "Orders cannot be matched"); return (price, tokenId, amount, assetType); }
However StandardPolicyERC1155
always returns the amount of 1 and do not check the amount that was provided by seller and buyer.
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
That means that buyer will pay more if amount of seller order is bigger then 1. And the main thing is that he paid for few tokens, but received only 1.
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
If provided amount is 0 then do not send tokens. Add checking of the identical amount in seller's order and buyer's order. And then return correct amount.
#0 - GalloDaSballo
2022-10-13T22:30:12Z
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0xNazgul, 0xSmartContract, Aymen0909, Heuss, Lambda, Pheonix, RaymondFam, ReyAdmirado, Ruhum, Shinchan, Shishigami, __141345__, adriro, ajtra, c3phas, ch0bu, cryptostellar5, d3e4, enckrish, gogo, halden, lucacez, mcwildy, medikko, neko_nyaa, pedr02b2, pfapostol, ret2basic, rvierdiiev, saian, sakman, sakshamguruji
32.6464 USDC - $32.65
++i
instead of i++
. Also cache array size into variable. Use uint256 instead of any other uint types. And do not initialize I value with 0.
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L199-L201
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/BlurExchange.sol#L476
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/PolicyManager.sol#L77
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/EIP712.sol#L77
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/MerkleVerifier.sol#L38 uint256
value 1 and 2 instead of boolean to save gas.
https://github.com/code-423n4/2022-10-blur/blob/main/contracts/lib/ReentrancyGuarded.sol#L10#0 - GalloDaSballo
2022-10-21T00:21:18Z
Presentation is abysmal, you're not explaining the reEntrancy gas savings, I'm considering closing
#1 - GalloDaSballo
2022-10-22T23:25:16Z
5k
#2 - GalloDaSballo
2022-10-22T23:25:33Z
Will penalize for presentation vs other reports