Skip to content
Business logic Audit finding Beginner

The ZeroLendToken contract in the Governance mo

The ZeroLendToken contract's transfer logic incorrectly treats the whitelist as a blacklist, so whitelisted users cannot transfer tokens. This causes a temporary freezing of funds for those users.

Trust Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

29019 - [SC - High] The ZeroLendToken contract in the Governance mo...

Submitted on Mar 4th 2024 at 20:56:25 UTC by @Trust for Boost | ZeroLend

Report ID: #29019

Report type: Smart Contract

Report severity: High

Target: https://github.com/zerolend/governance

Impacts:

  • Temporary freezing of funds for at least 1 hour

Description

Brief/Intro

The ZeroLendToken contract in the Governance module mishandles the whitelist. It is treated as a blacklist.

Vulnerability Details

The code below handles updating of the balance when a token is sent by from to to.

function _update(
    address from,
    address to,
    uint256 value
) internal virtual override {
    require(!blacklisted[from] && !blacklisted[to], "blacklisted");
    require(!paused && !whitelisted[from], "paused");
    super._update(from, to, value);
}

Note that if whitelisted is True, the token should allow the transfer. However the condition is flipped, so it will certainly abort the transfer.

Impact Details

A whitelisted user will not be able to transfer their tokens, resulting in a temporary freezing of funds.

Recommended remidiation

Consider refactoring the code as suggestedbelow: require(!paused || whitelisted[from])

References

https://github.com/zerolend/governance/blob/a30d8bb825306dfae1ec5a5a47658df57fd1189b/contracts/ZeroLendToken.sol#L61

Proof of Concept

  1. User A is inserted to the whitelist
  2. User A wishes to transfer their tokens to User B
  3. The transfer() reverts, resulting in lock of funds.

The original report as published on Immunefi, by Trust. 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 condition in the _update function uses !whitelisted[from] instead of allowing whitelisted addresses, effectively inverting the intended whitelist logic.

Impact

A whitelisted user will not be able to transfer their tokens, resulting in a temporary freezing of funds.

What the attacker needed

User is on the whitelist; user attempts a token transfer

The fix

The condition should be changed to allow transfers when the sender is whitelisted, for example by using require(!paused || whitelisted[from]).

How it was found

  1. User A is inserted to the whitelist
  2. User A wishes to transfer their tokens to User B
  3. The transfer() reverts, resulting in lock of funds.

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 whitelist is a list of addresses that are allowed to do something, like transfer tokens. In this contract, the check was written backwards, so being on the whitelist actually blocked transfers instead of allowing them. That meant those users could not move their tokens until the code was fixed.

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.

More by Trust

View all

77 more disclosed reports, best first.

More from ZeroLend

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.