Skip to content
DoS Audit finding Intermediate

Adversary can permanently brick auctions due to precision error in Auction#_computeTotalRewards

A precision error in the auction reward calculation can cause the batch deposit of rewards to revert, permanently preventing the auction from being settled. An attacker can engineer a bid amount that triggers this mismatch, bricking the auction.

0x52 Follow with Bauer, Brenzee and 12 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-09-nounsbuilder-judging/issues/251

Found by

0x52, Bauer, Brenzee, HHK, Kow, KupiaSec, SilentDefendersOfDeFi, coffiasd, cu5t0mPe0, dany.armstrong90, ggg_ttt_hhh, gqrp, pontifex, unforgiven, xAriextz

Summary

When batch depositing to ProtocolRewards, the msg.value is expected to match the sum of the amounts array EXACTLY. The issue is that due to precision loss in Auction#_computeTotalRewards this call can be engineered to always revert which completely bricks the auction process.

Vulnerability Detail

ProtocolRewards.sol#L55-L65

    for (uint256 i; i < numRecipients; ) {
        expectedTotalValue += amounts[i];

        unchecked {
            ++i;
        }
    }

    if (msg.value != expectedTotalValue) {
        revert INVALID_DEPOSIT();
    }

When making a batch deposit the above method is called. As seen, the call with revert if the sum of amounts does not EXACTLY equal the msg.value.

Auction.sol#L474-L507

    uint256 totalBPS = _founderRewardBps + referralRewardsBPS + builderRewardsBPS;

    ...

    // Calulate total rewards
    split.totalRewards = (_finalBidAmount * totalBPS) / BPS_PER_100_PERCENT;

    ...

    // Initialize arrays
    split.recipients = new address[](arraySize);
    split.amounts = new uint256[](arraySize);
    split.reasons = new bytes4[](arraySize);

    // Set builder reward
    split.recipients[0] = builderRecipient;
    split.amounts[0] = (_finalBidAmount * builderRewardsBPS) / BPS_PER_100_PERCENT;

    // Set referral reward
    split.recipients[1] = _currentBidRefferal != address(0) ? _currentBidRefferal : builderRecipient;
    split.amounts[1] = (_finalBidAmount * referralRewardsBPS) / BPS_PER_100_PERCENT;

    // Set founder reward if enabled
    if (hasFounderReward) {
        split.recipients[2] = founderReward.recipient;
        split.amounts[2] = (_finalBidAmount * _founderRewardBps) / BPS_PER_100_PERCENT;
    }

The sum of the percentages are used to determine the totalRewards. Meanwhile, the amounts are determined using the broken out percentages of each. This leads to unequal precision loss, which can cause totalRewards to be off by a single wei which cause the batch deposit to revert and the auction to be bricked. Take the following example:

Assume a referral reward of 5% (500) and a builder reward of 5% (500) for a total of 10% (1000). To brick the contract the adversary can engineer their bid with specific final digits. In this example, take a bid ending in 19.

split.totalRewards = (19 * 1,000) / 100,000 = 190,000 / 100,000 = 1

split.amounts[0] = (19 * 500) / 100,000 = 95,000 / 100,000 = 0
split.amounts[1] = (19 * 500) / 100,000 = 95,000 / 100,000 = 0

Here we can see that the sum of amounts is not equal to totalRewards and the batch deposit will revert.

Auction.sol#L270-L273

if (split.totalRewards != 0) {
    // Deposit rewards
    rewardsManager.depositBatch{ value: split.totalRewards }(split.recipients, split.amounts, split.reasons, "");
}

The depositBatch call is placed in the very important _settleAuction function. This results in auctions that are permanently broken and can never be settled.

Impact

Auctions are completely bricked

Code Snippet

Auction.sol#L244-L289

Tool used

Manual Review

Recommendation

Instead of setting totalRewards with the sum of the percentages, increment it by each fee calculated. This way they will always match no matter what.

Discussion

nevillehuang

Contrary to #103 which only affects bidding, this causes a complete DoS of settlement of auctions, forcing the DAO to possibly have to redeploy to resolve the issue and continue auctions, so I believe high severity is fair.

neokry

Fixed here: https://github.com/ourzora/nouns-protocol/pull/123

The original report as published on Sherlock, by 0x52. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 total reward is computed from the sum of percentages, while individual rewards are computed separately, leading to unequal rounding and a mismatch that causes the batch deposit to revert.

Impact

Auctions are completely bricked, preventing settlement and potentially forcing the DAO to redeploy.

What the attacker needed

Attacker can place a bid; auction has referral and builder rewards

The fix

The total rewards should be incremented by each calculated fee instead of using the sum of percentages, ensuring they always match.

How it was found

  1. The attacker places a bid with a specific final amount that causes rounding differences.
  2. When the auction is settled, the total rewards and individual reward amounts are calculated with different rounding.
  3. The sum of individual amounts does not equal the total rewards, so the batch deposit reverts.
  4. The auction settlement fails permanently, bricking the auction.

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 an auction ends, the contract pays out rewards to the builder, referrer, and founder. It calculates the total reward and each person's share separately, and rounding can make the total slightly different from the sum of the shares. If they don't match exactly, the payment fails, and the auction can never be settled.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by 0x52

View all

211 more disclosed reports, best first.

More from Nouns Builder

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.