Skip to content
DoS Audit finding Intermediate

Heart will stop if all rewards are swept

The Heart contract's reward issuance function does not check the contract's token balance before transferring the reward, so if all reward tokens are withdrawn via the admin function, the transfer reverts and the Heart can no longer beat. An attacker with the heart_admin role could withdraw all unspent rewards, causing a denial of service until new tokens are deposited.

GalloDaSballo Follow

Originally disclosed on Code4rena

Submitted by GalloDaSballo, also found by cccz, itsmeSTYJ, and PwnPatrol

Rewards for Heart beat are sent via _issueReward

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Heart.sol#L110-L115

    function _issueReward(address to_) internal {
        rewardToken.safeTransfer(to_, reward);
        emit RewardIssued(to_, reward);
    }

The function doesn’t check for available tokens e.g. min(reward, rewardToken.balanceOf(address(this)));

In case of calling withdrawUnspentRewards

https://github.com/code-423n4/2022-08-olympus/blob/b5e139d732eb4c07102f149fb9426d356af617aa/src/policies/Heart.sol#L149-L152

    /// @inheritdoc IHeart
    function withdrawUnspentRewards(ERC20 token_) external onlyRole("heart_admin") {
        token_.safeTransfer(msg.sender, token_.balanceOf(address(this)));
    }

Because the function withdraws the entire amount, the heart will stop until a caller incentive is deposited again.

While a profitable searches will stop calling the Heart without an incentive, allowing the heart to beat when no rewards are available is preferable to having it self-DOS until a DAO aligned caller donates rewardToken or the DAO deals with the lack of tokens.

Recommended Mitigation Steps

Add a check for available tokens min(reward, rewardToken.balanceOf(address(this)));

Oighty (Olympus) confirmed and commented:

Agree based on the anti-DOS characteristics of using a min operation.


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

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 reward transfer function does not cap the reward amount by the contract's current token balance, so a full withdrawal leaves it unable to pay and causes a revert.

What the attacker needed

Heart_admin role can withdraw all rewards; Heart contract holds reward tokens

The fix

The reward transfer should be capped by the contract's available token balance, for example using a minimum of the reward and the balance, as recommended.

How it was found

  1. An admin calls withdrawUnspentRewards to transfer the entire token balance out of the Heart contract.
  2. The Heart contract now holds no reward tokens.
  3. A caller tries to make the Heart beat, which triggers _issueReward.
  4. The reward transfer fails because the contract has insufficient balance, so the Heart stops beating.

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.

A smart contract called Heart pays a reward each time it 'beats'. The code that pays the reward does not check whether the contract actually has enough tokens to pay. If an admin withdraws all the tokens, the next attempt to beat will fail because the transfer has nothing to send, and the Heart stops working until someone puts tokens back.

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 GalloDaSballo

View all

30 more disclosed reports, best first.

More from Olympus DAO contest

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.