In AllPayAuction.sol and EnglishAuction.sol, the withdraw functions are external so must be secured#41
Conversation
📝 WalkthroughWalkthroughAccess control checks have been added to the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
contracts/AllPayAuction.sol (1)
107-117:⚠️ Potential issue | 🟠 MajorAdd
onlyAfterDeadlinemodifier to prevent mid-auction fund withdrawals.The
withdrawfunction lacks theonlyAfterDeadlineguard, allowing the auctioneer to drain accumulated bid funds before the auction deadline. In an all-pay auction where all bids are non-refundable, this enables the auctioneer to extract funds while bidders continue to pay in, breaking the auction's security model.EnglishAuction.withdraw(line 110) andVickreyAuction.withdraw(line 146) both enforce this check.Proposed fix
- function withdraw(uint256 auctionId) external exists(auctionId) { + function withdraw(uint256 auctionId) external exists(auctionId) onlyAfterDeadline(auctions[auctionId].deadline) {
🧹 Nitpick comments (2)
contracts/AllPayAuction.sol (1)
110-116: Consider guarding against zero-amount withdrawals.If
availableFundsis already 0 (e.g., already withdrawn or no bids placed), the function proceeds with two zero-valuesendERC20calls and emitsWithdrawnwith amount 0, wasting gas and producing misleading events.Proposed fix
+ require(withdrawAmount > 0, "Nothing to withdraw"); auction.availableFunds = 0;contracts/EnglishAuction.sol (1)
113-119: Same zero-amount withdrawal concern as in AllPayAuction.If no bids were placed,
availableFundsis 0 and the function will execute two no-op token transfers and emit a misleadingWithdrawn(auctionId, 0)event. Arequire(withdrawAmount > 0, "Nothing to withdraw")guard would prevent this.
In AllPayAuction.sol and EnglishAuction.sol, the withdraw functions are external but do not verify that the msg.sender is the auctioneer.
Issue: Anyone can trigger the withdrawal of funds to the auctioneer's address.
Risk: While the funds go to the correct person (the auctioneer), this allows external parties to force financial realizations for the auctioneer, which might have tax or accounting implications, or interfere with a manager's planned strategy.
Fix: Add require(msg.sender == auction.auctioneer) to the withdraw functions.
Closes #21
Summary by CodeRabbit
Bug Fixes