Platform: Code4rena
Start Date: 30/10/2023
Pot Size: $49,250 USDC
Total HM: 14
Participants: 243
Period: 14 days
Judge: 0xsomeone
Id: 302
League: ETH
Rank: 154/243
Findings: 2
Award: $1.38
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: smiling_heretic
Also found by: 00decree, 00xSEV, 0x180db, 0x3b, 0x656c68616a, 0xAadi, 0xAleko, 0xAsen, 0xDetermination, 0xJuda, 0xMAKEOUTHILL, 0xMango, 0xMosh, 0xSwahili, 0x_6a70, 0xarno, 0xgrbr, 0xpiken, 0xsagetony, 3th, 8olidity, ABA, AerialRaider, Al-Qa-qa, Arabadzhiev, AvantGard, CaeraDenoir, ChrisTina, DanielArmstrong, DarkTower, DeFiHackLabs, Deft_TT, Delvir0, Draiakoo, Eigenvectors, Fulum, Greed, HChang26, Haipls, Hama, Inference, Jiamin, JohnnyTime, Jorgect, Juntao, Kaysoft, Kose, Kow, Krace, MaNcHaSsS, Madalad, MrPotatoMagic, Neon2835, NoamYakov, Norah, Oxsadeeq, PENGUN, REKCAH, Ruhum, Shubham, Silvermist, Soul22, SovaSlava, SpicyMeatball, Talfao, TermoHash, The_Kakers, Toshii, TuringConsulting, Udsen, VAD37, Vagner, Zac, Zach_166, ZdravkoHr, _eperezok, ak1, aldarion, alexfilippov314, alexxander, amaechieth, aslanbek, ast3ros, audityourcontracts, ayden, bdmcbri, bird-flu, blutorque, bronze_pickaxe, btk, c0pp3rscr3w3r, c3phas, cartlex_, cccz, ciphermarco, circlelooper, crunch, cryptothemex, cu5t0mpeo, darksnow, degensec, dethera, devival, dimulski, droptpackets, epistkr, evmboi32, fibonacci, gumgumzum, immeas, innertia, inzinko, jasonxiale, joesan, ke1caM, kimchi, lanrebayode77, lsaudit, mahyar, max10afternoon, merlin, mrudenko, nuthan2x, oakcobalt, openwide, orion, phoenixV110, pontifex, r0ck3tz, rotcivegaf, rvierdiiev, seeques, shenwilly, sl1, slvDev, t0x1c, tallo, tnquanghuy0512, tpiliposian, trachev, twcctop, vangrim, volodya, xAriextz, xeros, xuwinnie, y4y, yobiz, zhaojie
0 USDC - $0.00
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L57-L61
In order if you want to participate in auction, then you should pay the highest bid at the moment. Also, you can cancel your bid in case if auction hasn't finished yet.
This 2 things make it possible to easily win auction. Attacker just needs to call participateToAuction
with very big amount for that token(for example if token's price on the market is 500$, then attacker can provide 5000$), so anyone else will not find it profitable to make bigger bid(as you should provide bigger bid than highest one to participate). Then, when auction is going to be finished, attacker needs to call cancelBid
and participateToAuction
with symbolic 1 wei amount.
Attacker can block others from auction and pay small amount.
VsCode
First solution is to at least have minimum amount for the auction to be successful. Second solution is to prolong auction in case if new bid was done X minutes(seconds) before the end.
Error
#0 - c4-pre-sort
2023-11-17T10:34:12Z
141345 marked the issue as duplicate of #962
#1 - c4-judge
2023-12-02T15:13:20Z
alex-ppg marked the issue as not a duplicate
#2 - c4-judge
2023-12-02T15:17:08Z
alex-ppg marked the issue as duplicate of #1784
#3 - c4-judge
2023-12-07T11:49:32Z
alex-ppg marked the issue as duplicate of #1323
#4 - c4-judge
2023-12-08T17:27:19Z
alex-ppg marked the issue as partial-25
#5 - c4-judge
2023-12-08T17:28:22Z
alex-ppg marked the issue as satisfactory
#6 - c4-judge
2023-12-08T18:24:12Z
alex-ppg marked the issue as partial-25
🌟 Selected for report: The_Kakers
Also found by: 00xSEV, 0xAsen, 0xDetermination, 0xJuda, 0xWaitress, 0xhunter, 0xlemon, 0xpiken, Al-Qa-qa, Arabadzhiev, CSL, CaeraDenoir, DarkTower, DeFiHackLabs, Greed, Haipls, MaNcHaSsS, NentoR, NoamYakov, PENGUN, Ruhum, Soul22, SovaSlava, Talfao, Toshii, TuringConsulting, VAD37, Vagner, Valix, Viktor_Cortess, ZdravkoHr, audityourcontracts, btk, codynhat, flacko, funkornaut, glcanvas, gumgumzum, immeas, innertia, ke1caM, lanrebayode77, lsaudit, mrudenko, niki, nmirchev8, openwide, oualidpro, r0ck3tz, rvierdiiev, trachev, yojeff
1.3844 USDC - $1.38
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L104-L120
When auction has started, then anyone can participate. Then in case if his bid is highest it's stored to the array.
When time is over, then winner of auction or admin, should call claimAuction
in order to receive token.
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/AuctionDemo.sol#L104-L120
function claimAuction(uint256 _tokenid) public WinnerOrAdminRequired(_tokenid,this.claimAuction.selector){ require(block.timestamp >= minter.getAuctionEndTime(_tokenid) && auctionClaim[_tokenid] == false && minter.getAuctionStatus(_tokenid) == true); auctionClaim[_tokenid] = true; uint256 highestBid = returnHighestBid(_tokenid); address ownerOfToken = IERC721(gencore).ownerOf(_tokenid); address highestBidder = returnHighestBidder(_tokenid); for (uint256 i=0; i< auctionInfoData[_tokenid].length; i ++) { if (auctionInfoData[_tokenid][i].bidder == highestBidder && auctionInfoData[_tokenid][i].bid == highestBid && auctionInfoData[_tokenid][i].status == true) { IERC721(gencore).safeTransferFrom(ownerOfToken, highestBidder, _tokenid); (bool success, ) = payable(owner()).call{value: highestBid}(""); emit ClaimAuction(owner(), _tokenid, success, highestBid); } else if (auctionInfoData[_tokenid][i].status == true) { (bool success, ) = payable(auctionInfoData[_tokenid][i].bidder).call{value: auctionInfoData[_tokenid][i].bid}(""); emit Refund(auctionInfoData[_tokenid][i].bidder, _tokenid, success, highestBid); } else {} } }
This is how the function works. This function will loop through the all auctionInfoData[_tokenid]
array and will process every bid. In case if it's a bid of the winner, then a token will be sent to him and payment will be sent to protocol(owner). In case if it's not a bid of the winner, then refund will be done in case if it wasn't done yet.
Such approach is really gas consuming. One problem is that anyone can make gas griefing to make tx revert(just use all gas provided with refund payment), which will block this contract. And another problem is that if everyone is honest it's really expensive for both winner and admins to execute such tx.
Winner pays a lot of funds to execute claiming.
VsCode
Change pattern, so everyone should claim and withdraw for himself.
Error
#0 - c4-pre-sort
2023-11-15T10:45:08Z
141345 marked the issue as duplicate of #843
#1 - c4-pre-sort
2023-11-16T13:35:06Z
141345 marked the issue as duplicate of #486
#2 - c4-judge
2023-12-05T22:21:09Z
alex-ppg marked the issue as not a duplicate
#3 - c4-judge
2023-12-05T22:21:16Z
alex-ppg marked the issue as duplicate of #734
#4 - c4-judge
2023-12-08T21:04:20Z
alex-ppg marked the issue as partial-50
#5 - c4-judge
2023-12-09T00:22:01Z
alex-ppg changed the severity to 3 (High Risk)