Skip to content
DoS Audit finding Intermediate

Users can DoS Zapper::zapIn functionality for a token

The Zapper contract sets token allowances to the router without validating the maximum amounts, allowing an attacker to inflate the allowance to near the maximum value without spending tokens. This blocks future deposits for that token because further allowance increases overflow.

kmm Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42158 [SC-High] Users can DoS `Zapper::zapIn` functionality for a token

Submitted on Mar 21st 2025 at 11:29:11 UTC by @kmm for Audit Comp | Yeet

Description

Brief/Intro

In certain edge cases involving Kodiak Island's liquidity pools, specifically when totalSupply is 0 or when there is only one-sided liquidity, a user can exploit the safeIncreaseAllowance mechanism used by the zapper. This allows the user to perform a Denial-of-Service (DoS) attack on the router's approval functionality, effectively blocking any future deposit attempts via the Kodiak router for that specific token.

Vulnerability Details

Kodiak Island calculates mint share rates using the following logic:

Solidity
function getMintAmounts(uint256 amount0Max, uint256 amount1Max) external view returns (uint256 amount0, uint256 amount1, uint256 mintAmount) {
    uint256 totalSupply = totalSupply();
    if (totalSupply > 0) {
        (amount0, amount1, mintAmount) = _computeMintAmounts(totalSupply, amount0Max, amount1Max);
    } else {
        (uint160 sqrtRatioX96,,,,,,) = pool.slot0();
        uint128 newLiquidity = LiquidityAmounts.getLiquidityForAmounts(sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), amount0Max, amount1Max);
        mintAmount = uint256(newLiquidity);
        (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity(sqrtRatioX96, lowerTick.getSqrtRatioAtTick(), upperTick.getSqrtRatioAtTick(), newLiquidity);
    }
}

function _computeMintAmounts(uint256 totalSupply, uint256 amount0Max, uint256 amount1Max) private view returns (uint256 amount0, uint256 amount1, uint256 mintAmount) {
    (uint256 amount0Current, uint256 amount1Current) = getUnderlyingBalances();

    if (amount0Current == 0 && amount1Current > 0) {
        mintAmount = FullMath.mulDiv(amount1Max, totalSupply, amount1Current);
    } else if (amount1Current == 0 && amount0Current > 0) {
        mintAmount = FullMath.mulDiv(amount0Max, totalSupply, amount0Current);
    } else if (amount0Current == 0 && amount1Current == 0) {
        revert("");
    } else {
        uint256 amount0Mint = FullMath.mulDiv(amount0Max, totalSupply, amount0Current);
        uint256 amount1Mint = FullMath.mulDiv(amount1Max, totalSupply, amount1Current);
        require(amount0Mint > 0 && amount1Mint > 0, "mint 0");

        mintAmount = amount0Mint < amount1Mint ? amount0Mint : amount1Mint;
    }

    amount0 = FullMath.mulDivRoundingUp(mintAmount, amount0Current, totalSupply);
    amount1 = FullMath.mulDivRoundingUp(mintAmount, amount1Current, totalSupply);
}

When totalSupply == 0, the mint amount directly correlates to the liquidity minted from the provided token amounts. In the case of one-sided liquidity, the vault only pulls one of the token amounts.

The zapper's _yeetIn function sets token allowances to the router using safeIncreaseAllowance for both amount0Max and amount1Max, and then invokes addLiquidity. However, the zapInNative function does not validate amount0Max or amount1Max. This opens the door for an attacker to set a massive allowance, such as type(uint256).max, without actually spending the tokens.

In zero-supply situations, an attacker can manipulate the pool state (e.g., by shifting it outside of tickLower or tickUpper) to ensure one of the token amounts calculated by getAmountsForLiquidity returns zero. This causes the vault to pull only the other token, allowing the attacker to set an inflated approval for the unused token.

For pools with one-sided liquidity, this same effect occurs without the need to push the pool outside any tick range, as one of the amounts will inherently be zero.

Impact Details

This vulnerability enables an attacker to push the router's token allowance to near type(uint256).max without spending it, leveraging the behavior of safeIncreaseAllowance. As a result, future attempts to increase the allowance for that token will fail, effectively blocking zapper deposits for that token. This creates a persistent DoS condition for the affected token within the Kodiak Island ecosystem.

References

Proof of Concept

Proof of Concept

totalSupply=0

  1. The vault is added with totalSupply=0
  2. The user sees this and in one transaction
    • Pushes the price outside of the range in the island
    • Calls zapInNative, and passes amount1Max as type(uint256).max
    • The island only pulls amount0 leaving the approval at type(uint256).max
  3. Any further attempt at depositing this token, will revert due to overflow in safeIncreaseAllowance.

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

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 `zapInNative` function does not validate the `amount0Max` and `amount1Max` parameters before using `safeIncreaseAllowance`, allowing an attacker to set an arbitrarily large allowance that is not fully spent.

Impact

An attacker can cause a persistent denial of service for zapper deposits of a specific token by exhausting the allowance, blocking future deposits.

What the attacker needed

Vault with totalSupply=0 or one-sided liquidity; attacker can call zapInNative

How it was found

  1. The vault is added with totalSupply=0.
  2. The user pushes the price outside of the range in the island.
  3. The user calls zapInNative and passes amount1Max as type(uint256).max.
  4. The island only pulls amount0, leaving the approval at type(uint256).max.
  5. Any further attempt at depositing this token reverts due to overflow in safeIncreaseAllowance.

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 lets users deposit tokens into a liquidity pool. The contract approves the pool to spend the user's tokens, but it does not check how large that approval is. An attacker can make the approval extremely large without actually depositing tokens, so later deposits fail because the approval cannot be increased further.

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 kmm

View all

2 more disclosed reports, best first.

More from Yeet

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.