Skip to content
DoS Audit finding Intermediate

BkdLocker depositFees can be blocked

The BkdLocker contract's fee burning function fails when the contract holds ETH but none of the liquidity pools use ETH as their underlying token. An attacker could send a small amount of ETH to the contract to cause the fee burning to revert, blocking fee deposits.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

burnFees will fail if none of the pool tokens have underlying token as native ETH token. This is shown below. Since burnFees fails so no fees is deposited in BKDLocker.

Proof of Concept

  1. Assume RewardHandler.sol has currently amount 5 as address(this).balance (ethBalance) (even attacker can send a small balance to this contract to do this dos attack)
  2. None of the pools have underlying as address(0) so no ETH tokens and only ERC20 tokens are present
  3. Now feeBurner.burnToTarget is called passing current ETH balance of amount 5 with all pool tokens
  4. feeBurner loops through all tokens and swap them to WETH. Since none of the token is ETH so burningEth_ variable is false
  5. Now the below require condition fails since burningEth_ is false
require(burningEth_ || msg.value == 0, Error.INVALID_VALUE);
  1. This fails the burnFees function.

Recommended Mitigation Steps

ETH should not be sent if none of pool underlying token is ETH. Change it to something like below:

bool ethFound=false;
for (uint256 i; i < pools.length; i = i.uncheckedInc()) {
            ILiquidityPool pool = ILiquidityPool(pools[i]);
            address underlying = pool.getUnderlying();
            if (underlying != address(0)) {
                _approve(underlying, address(feeBurner));
            } else
{
ethFound=true;
}
            tokens[i] = underlying;
        }

if(ethFound){
        feeBurner.burnToTarget{value: ethBalance}(tokens, targetLpToken);
} else {
feeBurner.burnToTarget(tokens, targetLpToken);
}

samwerner (Backd) confirmed

Alex the Entreprenerd (judge) decreased severity to Medium and commented:

The warden has shown how, due to a flaw in the logic, if ETH is present in the contract and no pool is denominated in ETH, then the contract will revert.

This can be done as a DOS attack or for griefing.

However, remediation would simply require adding a pool denominated in ETH, to ensure that the logic goes through

For this reason, I believe Medium Severity to be more appropriate


The original report as published on Code4rena, by csanuragjain. 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

The contract sends its ETH balance to the fee burner even when no pool uses ETH, causing a require statement to fail because the fee burner expects ETH only if a pool uses it.

Impact

An attacker could block the fee burning process by sending a small amount of ETH to the contract, preventing fees from being deposited.

What the attacker needed

Attacker can send ETH to the contract; No pool uses ETH as underlying

The fix

The contract should only send ETH to the fee burner if at least one pool uses ETH as underlying; otherwise, call without sending ETH.

How it was found

  1. Assume the RewardHandler contract has a small ETH balance (attacker can send ETH to it).
  2. None of the pools have ETH as underlying token, so only ERC20 tokens are present.
  3. The feeBurner.burnToTarget function is called with the ETH balance and all pool tokens.
  4. The feeBurner loops through tokens, swaps them to WETH, but since no token is ETH, burningEth_ remains false.
  5. The require condition fails because burningEth_ is false and msg.value is not zero, causing the burnFees function to 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.

A smart contract called BkdLocker is supposed to burn fees by swapping tokens. If someone sends a tiny amount of ETH (the native cryptocurrency) to the contract, and none of the pools it uses are based on ETH, the burning function crashes. This means fees cannot be deposited, which is a denial-of-service attack.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from Backd Tokenomics 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.