Skip to content
Business logic Audit finding Intermediate

Alchemist can mint AlTokens above their assigned ceiling by calling lowerHasMinted()

A whitelisted user could call lowerHasMinted() to reduce their recorded minted total, then mint more AlTokens than their assigned ceiling. This allowed them to mint an unlimited number of tokens within the total supply.

tintin Follow

Originally disclosed on Code4rena

Submitted by tintin, also found by 0xsomeone, AuditsAreUS, and hyh

AlchemicTokenV2Base.sol#L111-L124 AlchemicTokenV2Base.sol#L189-L191

An alchemist / user can mint more than their alloted amount of AlTokens by calling lowerHasMinted() before they reach their minting cap.

Proof of Concept

Function mint() in AlchemicTokenV2Base.sol

  function mint(address recipient, uint256 amount) external onlyWhitelisted {
    if (paused[msg.sender]) {
      revert IllegalState();
    }

    uint256 total = amount + totalMinted[msg.sender];
    if (total > mintCeiling[msg.sender]) {
      revert IllegalState();
    }

    totalMinted[msg.sender] = total;

    _mint(recipient, amount);
  }

Note the require conditional check that total > mintCeiling[msg.sender].

In the same contract, there is the function lowerHasMinted() with the same permission level as mint and is thus callable by the same user as well.

  function lowerHasMinted(uint256 amount) external onlyWhitelisted {
    totalMinted[msg.sender] = totalMinted[msg.sender] - amount;
  }

It is clear that a user can accumulate an infinite (within supply) amount of AlTokens by calling lowerHasMinted() before any action that would make them exceed their minting cap.

Tools Used

Manual review, VScode

Recommended Mitigation Steps

Change the permissioning on lowerHasMinted() to be restricted to a higher permissioned role like onlySentinel() , or deprecate this function as I could not find any uses of it throughout the codebase or in tests.

0xfoobar (Alchemix) confirmed

0xleastwood (judge) commented:

Great find! This would allow whitelisted account to mint any number of tokens. However, as this pertains to only whitelisted accounts, I think medium severity is justified and correct.


The original report as published on Code4rena, by tintin. 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 lowerHasMinted() function has the same permission level as mint(), allowing any whitelisted minter to reduce their own totalMinted counter and thereby bypass the mintCeiling check.

Impact

A whitelisted account could mint any number of AlTokens, up to the total supply, exceeding its assigned ceiling.

What the attacker needed

Whitelisted account

The fix

The permission on lowerHasMinted() should be restricted to a higher-privileged role such as onlySentinel(), or the function should be removed.

How it was found

  1. Be a whitelisted account with a mint ceiling.
  2. Call lowerHasMinted() to reduce totalMinted[msg.sender].
  3. Call mint() to create tokens; the total stays below the ceiling.
  4. Repeat to mint more than the assigned ceiling.

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 certain trusted users create new tokens, but each user has a maximum they can create. The contract also has a function that lets a user lower the count of tokens they have already created. Because the same user can call both functions, they can lower the count and then create more tokens, bypassing the maximum.

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 from Alchemix contest

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.