Skip to content
Access control Audit finding Beginner

Unauthorized Token Creation and Minting Vulnerability

The token factory's create function had no access control, so any address could deploy a new collateral token with an arbitrary supply and make itself the owner. As owner, the attacker gained full transfer rights, bypassing the intended restriction that only the owner or ConditionalTokens could move tokens.

kenzo Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#39153 [SC-Insight] Unauthorized Token Creation and Minting Vulnerability

Submitted on Jan 23rd 2025 at 15:35:01 UTC by @kenzo for Audit Comp | Butter

Description

Brief/Intro

The PlayCollateralTokenFactory contract contains a critical vulnerability in its createCollateralToken function that allows any user to create tokens with arbitrary supply and gain full control over token transfers. This bypasses the intended restrictive nature of the token contract where only specific addresses should be able to send/receive tokens.

Vulnerability Details

The vulnerability exists in the createCollateralToken function of the PlayCollateralTokenFactory contract:

Solidity
function createCollateralToken(
    string memory name, 
    string memory symbol, 
    uint256 initialSupply, 
    address owner
) external returns (address) {
    PlayCollateralToken newToken = new PlayCollateralToken(
        name, 
        symbol, 
        initialSupply,
        CONDITIONAL_TOKENS, 
        owner
    );
    
    emit PlayCollateralTokenCreated(address(newToken));
    return address(newToken);
}

The vulnerability arises because:

  1. Any address can call createCollateralToken
  2. The caller can specify any amount for initialSupply
  3. The caller can make themselves the owner
  4. As owner, they gain full control over token transfers

Attack scenario:

  1. Attacker calls createCollateralToken with themselves as owner
  2. Attacker creates massive supply of tokens
  3. Being the owner, attacker can now transfer tokens to any address
  4. This bypasses the intended restriction where only owner or ConditionalTokens should control transfers.

Impact Details

As stated in PlayCollateralToken.sol, this is a restrictive ERC20 for "play money": only the owner or ConditionalTokens can send or receive tokens. However, due to this vulnerability:

  1. Any address can create new tokens with themselves as owner
  2. They can mint arbitrary amounts of tokens
  3. As owner, they gain full transfer rights, bypassing the intended restrictions
  4. This completely breaks the token's security model where transfers should be restricted

Recommendation

Add access control to the createCollateralToken function to ensure only authorized addresses can create new tokens.

Proof of Concept

Add this to PlayCollateralTokenFactoryTest.t.sol

function testUnauthorizedTokenCreation() public {
       address attacker = makeAddr("attacker");
       vm.startPrank(attacker);
       
       // Create token with massive supply for attacker
       uint256 massiveSupply = 1_000_000_000_000 ether;
       address tokenAddr = factory.createCollateralToken(
           "Token",
           "TKN",
           massiveSupply,
           attacker
       );

       PlayCollateralToken token = PlayCollateralToken(tokenAddr);

       // Verify attacker has full control
       assertEq(token.OWNER(), attacker, "Attacker should be owner");
       assertEq(token.balanceOf(attacker), massiveSupply, "Attacker should have all tokens");
       assertEq(token.totalSupply(), massiveSupply, "Total supply should be massive");

       vm.stopPrank();

       // Log the details
       emit log_named_address("Token creator & owner", attacker);
       emit log_named_address("Token address", tokenAddr);
       emit log_named_uint("Supply created", massiveSupply);
   }

The original report as published on Immunefi, by kenzo. 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 createCollateralToken function lacked access control, letting any caller choose the initial supply and owner of a new token.

Impact

The attacker could mint arbitrary amounts of a token and transfer it freely, which the report says could cause protocol insolvency or griefing, though no concrete loss is demonstrated.

What the attacker needed

None

How it was found

  1. The attacker calls createCollateralToken, naming themselves as owner and choosing a very large initial supply.
  2. The factory deploys a new PlayCollateralToken with those values.
  3. The attacker, now the owner, can transfer tokens to any address, bypassing the intended restriction.

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 factory is a contract that creates other contracts. This factory let anyone call it to make a new 'play money' token, choose how many tokens exist, and name themselves the owner. The owner of this token type is allowed to send tokens anywhere, so the attacker could hand out unlimited fake tokens and break the rule that only certain addresses may move them.

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 kenzo

View all

53 more disclosed reports, best first.

More from Butter

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.