Blacklisting a Kodiak vault unintentionally whitelists a previously blacklisted token
The Zapper contract's function to blacklist a Kodiak vault also automatically whitelists the vault's underlying tokens, even if they were previously blacklisted. This means an owner trying to blacklist a vault containing a bad token inadvertently re-whitelists that token, allowing it to be used in other vaults.
- Disclosed after under an hour
#41689 [SC-Insight] Blacklisting a Kodiak vault unintentionally whitelists a previously blacklisted token
Submitted on Mar 17th 2025 at 15:32:22 UTC by @peppef for Audit Comp | Yeet
- Report ID: #41689
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/contracts/Zapper.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
In the Zapper.sol contract the methods updateSwappableTokens() and updateWhitelistedKodiakVault() helps the blacklisting token and vault processes.
```solidity
function updateSwappableTokens(address token, bool isWhitelisted) external override onlyOwner {
_updateWhitelistedTokens(token, isWhitelisted);
}
function _updateWhitelistedTokens(address token, bool isWhitelisted) private {
require(token != address(0), "Zapper: token is zero address");
whitelistedTokens[token] = isWhitelisted;
emit TokenWhitelisted(token, isWhitelisted);
}
function updateWhitelistedKodiakVault(address vault, bool isEnabled) external override onlyOwner {
... // other code
whitelistedKodiakVaults[vault] = isEnabled;
... // other code
if (!whitelistedTokens[token0]) {
_updateWhitelistedTokens(token0, true);
}
if (!whitelistedTokens[token1]) {
_updateWhitelistedTokens(token1, true);
}
}
```
However they both edit the state of the mapping _updateWhitelistedTokens[] which can lead to a weird scenario where blacklisting a vault which involves a blacklisted token has the contrary effect to whitelist it again in _updateWhitelistedTokens[].
Proof of Concept
Suppose the following scenario:
-
A token named $BAD_TOKEN is blacklisted by the owner using the following code
Solidity updateSwappableTokens(bad_token_address, false)This, through
_updateWhitelistedTokens()private function setswhitelistedTokens[bad_token_address] = false -
At this point zapIn and zapOut methods are still usable on vaults involving $BAD_TOKEN since the
onlyWhitelistedKodiakVaults()modifier only checks for whitelisted vaults in the mappingwhitelistedKodiakVaults[] -
For this reason the owner proceeds to blacklist the first vault involving $BAD_TOKEN, for example
wBERA/BAD_TOKENvault withSolidity updateWhitelistedKodiakVault(wBera_BadToken_vault, false)This function call sets
whitelistedKodiakVaults[wBera_BadToken_vault] = falsebut at the same time whitelists again bad_token_address insidewhitelistedTokens[]which was previously blacklisted due to the howupdateWhitelistedKodiakVault()is implemented -
Additionally the owner needs some time to blacklist all the other vaults involving $BAD_TOKEN for example: HONEY/BAD_TOKEN, USDT/BAD_TOKEN, USDC/BAD_TOKEN and thus, in the meanwhile, those vaults are still being usable by users and every potential blacklisting call to
updateSwappableTokens()is useless due to nextupdateWhitelistedKodiakVault()call.
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 function updateWhitelistedKodiakVault unconditionally whitelists the vault's tokens if they are not already whitelisted, without checking if they were intentionally blacklisted.
Impact
The owner cannot effectively blacklist a token if it appears in any vault, because blacklisting each vault re-whitelists the token, potentially allowing continued use of the bad token in other vaults.
What the attacker needed
Owner role; a token is blacklisted; a vault contains that token
How it was found
- Owner blacklists a bad token using updateSwappableTokens(bad_token_address, false).
- Owner blacklists a vault containing the bad token using updateWhitelistedKodiakVault(wBera_BadToken_vault, false).
- The vault blacklisting call re-whitelists the bad token because the function sets whitelistedTokens[token0] to true if it was false.
- Other vaults containing the bad token remain usable until individually blacklisted, and each blacklisting call again re-whitelists the token.
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.
This is a smart contract where an owner can mark certain tokens or vaults as 'bad' (blacklist) to stop people using them. But the function that blacklists a vault also automatically marks the tokens inside that vault as 'good' (whitelist), even if they were already marked bad. So trying to block a bad token by blocking its vault actually unblocks the token.
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.