Platform: Code4rena
Start Date: 04/11/2022
Pot Size: $42,500 USDC
Total HM: 9
Participants: 88
Period: 4 days
Judge: 0xean
Total Solo HM: 2
Id: 180
League: ETH
Rank: 22/88
Findings: 2
Award: $182.57
🌟 Selected for report: 0
🚀 Solo Findings: 0
138.2838 USDC - $138.28
https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L98 https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L163 https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L351 https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L381 https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L409 https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L439
In createAuction() and finalize() and withdraw(), refund() and cancelBid() and cancelAuction()
the safetransfer and safetransferfrom doesn’t check the existence of code at the token address. This is a known issue while using solmate’s libraries.
Hence this may lead to miscalculation of funds and may lead to loss of funds , because if safetransfer() and safetransferfrom() are called on a token address that doesn’t have contract in it, it will always return success, bypassing the return value check. Due to this protocol will think that funds has been transferred and successful , and records will be accordingly calculated, but in reality funds were never transferred. So this will lead to miscalculation and possibly loss of funds
Code inspection
Use openzeppelin’s safeERC20 or implement a code existence check.
#0 - c4-judge
2022-11-09T15:19:08Z
0xean marked the issue as duplicate
#1 - c4-judge
2022-12-06T00:26:12Z
0xean marked the issue as satisfactory
🌟 Selected for report: 0x1f8b
Also found by: 0xSmartContract, 0xc0ffEE, Aymen0909, B2, Deivitto, Josiah, KingNFT, Rahoz, RaymondFam, RedOneN, ReyAdmirado, Trust, ajtra, aviggiano, brgltd, c7e7eff, cryptonue, ctf_sec, delfin454000, djxploit, lukris02, peanuts, rvierdiiev, shark, simon135, slowmoses, tnevler, trustindistrust
44.2869 USDC - $44.29
When creating a auction,
the base token and quote token can be the same token (same address).
To avoid such misconfiguration,
We recommend the project add the check
if(auctionParams.baseToken == auctionParams.quoteToken) revert InvalidAuctionTokenSetting();
When creating auction, the code has this sanity check
if (timings.endTimestamp <= block.timestamp) { revert InvalidTimestamp(); } if (timings.startTimestamp >= timings.endTimestamp) { revert InvalidTimestamp(); } if (timings.endTimestamp > timings.vestingStartTimestamp) { revert InvalidTimestamp(); } if (timings.vestingStartTimestamp > timings.vestingEndTimestamp) { revert InvalidTimestamp(); }
this make sure
start timestamp < end timstamp < start vesting timestamp < end vesting timestamp.
and current timestamp < end timestamp,
However, the code does not check if
current timstamp < start timestamp,
the seller can set the start timestamp to the past. The impact is low, but it just does not make sense,
We recommend the project add the check
if (timings.startTimestamp < block.timestamp) { revert InvalidTimestamp(); }
the will not be working after the block.timestamp pass the timestamp type(uint32).max
function tokensAvailableForWithdrawal(uint256 auctionId, uint128 baseAmount) public view returns (uint128 tokensAvailable) { Auction storage a = idToAuction[auctionId]; return CommonTokenMath.tokensAvailableAtTime( a.timings.vestingStartTimestamp, a.timings.vestingEndTimestamp, uint32(block.timestamp), a.timings.cliffPercent, baseAmount ); }
We recommend the project just uint256 for the timestamp.
struct EncryptedBid { address sender; uint128 quoteAmount; uint128 filledBaseAmount; uint128 baseWithdrawn; bytes32 commitment; ECCMath.Point pubKey; bytes32 encryptedMessage; }
The code use uint128 for token amount extensively.
struct AuctionParameters { address baseToken; address quoteToken; uint256 reserveQuotePerBase; uint128 totalBaseAmount; uint128 minimumBidQuote; bytes32 merkleRoot; ECCMath.Point pubKey; }
this means that the code will not support the auction if the token amount larger than type(uint128).max.
We recommend the project just use uint256 to handle the token amount.
#0 - c4-judge
2022-11-10T02:41:32Z
0xean marked the issue as grade-b