Incorrect `prefundingRefund` calculation will disallow claiming
The prefundingRefund calculation in claimProceeds is incorrect because routing.funding is already reduced when bidders claim payouts, leading to an underflow and revert. This prevents sellers from claiming proceeds.
ether_sky Follow with hash and joicygiore
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-03-axis-finance-judging/issues/187
Found by
ether_sky, hash, joicygiore
Summary
Incorrect prefundingRefund calculation will lead to underflow and hence disallowing claiming
Vulnerability Detail
The prefundingRefund variable calculation inside the claimProceeds function is incorrect
function claimProceeds(
uint96 lotId_,
bytes calldata callbackData_
) external override nonReentrant {
...
(uint96 purchased_, uint96 sold_, uint96 payoutSent_) =
_getModuleForId(lotId_).claimProceeds(lotId_);
....
// Refund any unused capacity and curator fees to the address dictated by the callbacks address
// By this stage, a partial payout (if applicable) and curator fees have been paid, leaving only the payout amount (`totalOut`) remaining.
uint96 prefundingRefund = routing.funding + payoutSent_ - sold_;
unchecked {
routing.funding -= prefundingRefund;
}
Here sold is the total base quantity that has been sold to the bidders. Unlike required, the routing.funding variable need not be holding capacity + (0,curator fees) since it is decremented every time a payout of a bid is claimed
function claimBids(uint96 lotId_, uint64[] calldata bidIds_) external override nonReentrant {
....
if (bidClaim.payout > 0) {
...
// Reduce funding by the payout amount
unchecked {
routing.funding -= bidClaim.payout;
}
Example
Capacity = 100 prefunded, hence routing.funding == 100 initially Sold = 90 and no partial fill/curation All bidders claim before the claimProceed function is invoked Hence routing.funding = 100 - 90 == 10 When claimProceeds is invoked, underflow and revert:
uint96 prefundingRefund = routing.funding + payoutSent_ - sold_ == 10 + 0 - 90
Impact
Claim proceeds function is broken. Sellers won't be able to receive the proceedings
Code Snippet
wrong calculation https://github.com/sherlock-audit/2024-03-axis-finance/blob/cadf331f12b485bac184111cdc9ba1344d9fbf01/moonraker/src/AuctionHouse.sol#L604
Tool used
Manual Review
Recommendation
Change the calculation to:
uint96 prefundingRefund = capacity - sold_ + curatorFeesAdjustment (how much was prefunded initially - how much will be sent out based on capacity - sold)
Discussion
sherlock-admin4
The protocol team fixed this issue in the following PRs/commits: https://github.com/Axis-Fi/moonraker/pull/140
10xhash
The protocol team fixed this issue in the following PRs/commits: Axis-Fi/moonraker#140
Fixed
Seller refund calculation is changed to uint256 prefundingRefund = capacity_ - sold_ + maxCuratorPayout - curatorPayout
sherlock-admin4
The Lead Senior Watson signed off on the fix.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the prefundingRefund calculation uses routing.funding, which is decremented during bid claims, instead of the original capacity, causing an underflow when sold exceeds the remaining funding.
Impact
Sellers are unable to claim proceeds because the function reverts due to underflow.
What the attacker needed
Auction with prefunding; Bidders claim before seller claims proceeds
The fix
The calculation was fixed to use capacity minus sold plus curator fee adjustments instead of routing.funding.
How it was found
- Set capacity to 100 prefunded, so routing.funding is 100 initially.
- Have 90 sold with no partial fill or curation.
- All bidders claim their payouts before claimProceeds is called, reducing routing.funding to 10.
- Call claimProceeds, which computes prefundingRefund as 10 + 0 - 90, causing an underflow and revert.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a seller lists an item, they lock in some funds. As buyers claim their items, the locked amount goes down. Later, when the seller tries to collect the remaining money, the code subtracts the total sold amount from the already reduced locked amount, which can go negative and cause an error, blocking the seller from getting paid.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.