Skip to content
Access control Audit finding Intermediate

JBToken: mint function could mint arbitrary amount of tokens

The JBToken contract's mint function is restricted only to the owner, and ownership can be transferred to any address via the changeTokenOf function, allowing that address to mint an arbitrary number of tokens.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

The owner of the JBToken contract can mint arbitrary amount of tokens.

In general, the owner of the JBToken contract is the JBTokenStore contract, and the minting of the tokens is controlled by the JBController contract, but when the changeTokenOf function of the JBController contract is called, the owner will be transferred to any address, which can mint arbitrary amount of tokens.

  function mint(
    uint256 _projectId,
    address _account,
    uint256 _amount
  ) external override onlyOwner {
    _projectId; // Prevents unused var compiler and natspec complaints.

    return _mint(_account, _amount);
  }

Proof of Concept

https://github.com/jbx-protocol/juice-contracts-v2-code4rena//blob/828bf2f3e719873daa08081cfa0d0a6deaa5ace5/contracts/JBToken.sol#L106-L114

Recommended Mitigation Steps

Consider setting minter as the JBTokenStore contract and adding the onlyminter modifier to the mint function.

mejango (Juicebox) acknowledged


The original report as published on Code4rena, by cccz. 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 mint function only checks that the caller is the owner, but ownership can be reassigned to an arbitrary address, so the access control is too broad.

Impact

An attacker who becomes the owner could mint an unlimited number of tokens, potentially devaluing the token and harming holders.

What the attacker needed

Attacker becomes owner via changeTokenOf

The fix

The mint function should be restricted to a specific minter (the JBTokenStore contract) rather than any owner, for example by adding an onlyMinter modifier.

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 token contract lets someone create new tokens out of thin air. Here, the contract's owner can do that, and the owner can be changed to any address, so whoever becomes owner can create as many tokens as they want.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by cccz

View all

104 more disclosed reports, best first.

More from Juicebox Buyback Delegate

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.