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: 58/88
Findings: 2
Award: $26.73
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Trust
Also found by: 0x1f8b, 0xdapper, HE1M, KIntern_NA, Lambda, Picodes, RaymondFam, RedOneN, TomJ, V_B, __141345__, c7e7eff, chaduke, codexploder, corerouter, cryptonue, fs0c, gz627, hihen, joestakey, ktg, ladboy233, minhtrng, rvierdiiev, simon135, skyle, slowmoses, wagmi, yixxas
5.604 USDC - $5.60
Detailed description of the impact of this finding.
A malicious user can perform the following steps in ONE transaction to DOS attack the auction system by front-running the first bid
transaction:
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L415
Remix
We need to take the following mitigation steps:
cancelBid()
transaction cannot be performed in the same block as the bid
transaction for the same bidIndex
.bid
transaction so that unused bidIndex
can be reused by another bidder.#0 - c4-judge
2022-11-09T16:05:57Z
0xean marked the issue as duplicate
#1 - c4-judge
2022-12-06T00:23:09Z
0xean marked the issue as satisfactory
#2 - c4-judge
2022-12-06T00:31:11Z
0xean changed the severity to 2 (Med Risk)
🌟 Selected for report: 0x1f8b
Also found by: 0xSmartContract, 0xdeadbeef, Aymen0909, B2, Bnke0x0, Deivitto, Diana, Dinesh11G, JC, RaymondFam, ReyAdmirado, Rolezn, Sathish9098, TomJ, ajtra, aviggiano, chaduke, cryptostellar5, djxploit, gianganhnguyen, gogo, halden, karanctf, leosathya, lukris02, mcwildy, oyc_109, ret2basic, skyle, slowmoses
21.132 USDC - $21.13
G1: https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L144-L146
Since quoteAmount < a.params.minimumBidQuote
already covers the case quoteAmount == 0
, so we can drop condition 1 to save gas
if (quoteAmount == type(uint128).max || (quoteAmount < a.params.minimumBidQuote)) { revert InvalidBidAmount(); }
G2: https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L223
The privateKey == 0 check should be performed at the beginning of the reveal
function to save gas.
G3: https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L241 use shifting to save gas
uint256[] memory seenBidMap = new uint256[]((bidIndices.length >> 8 )+1);
G4. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L270-L277
InvalidSorting should be checked with a separate function and then be called at the beginning of finalize()
.
G5. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L217
Dupliate detection in argument bidIndices
should be accomplished by another inner function, which should be called at the beginning of finalize()
.
G6. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L313-L315
This check is not necessary since in the for loop (L289-291), we ensure that we will never exceed the data.totalBaseAmount
.
G7. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L28-L43
for the modifier atState
, we can cache a.times.startTimestamp
and a.times.endTimestamp
to save gas as they are accessed multiple times
G8. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L376
Cache b.quoteAmount
as it is accessed twice.
G9. https://github.com/code-423n4/2022-11-size/blob/706a77e585d0852eae6ba0dca73dc73eb37f8fb6/src/SizeSealed.sol#L425
Cache a.timing.endTimestamp
as it is accessed twice
#0 - c4-judge
2022-11-10T02:17:03Z
0xean marked the issue as grade-b