Token creator can revoke the upgrader role from the factory in order to avoid upgrades
Plume Network
Originally disclosed on Immunefi
51456 sc high token creator can revoke the upgrader role from the factory in order to avoid upgrades
- Report ID: #51456
- 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
Brief / Intro
{% hint style="info" %} Since the token creator is granted the DEFAULT_ADMIN_ROLE, the token creator can revoke or grant any role. This allows the token creator to remove the UPGRADER_ROLE from the factory (or grant it to themselves), preventing the factory from performing intended upgrades or enabling arbitrary upgrades by the token owner. {% endhint %}
Vulnerability Details
When a token is created, the factory assigns multiple roles to the token creator and assigns the UPGRADER_ROLE to the factory (address(this)):
token.grantRole(token.DEFAULT_ADMIN_ROLE(), msg.sender);
token.grantRole(token.ADMIN_ROLE(), msg.sender);
token.grantRole(token.MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_DISTRIBUTOR_ROLE(), msg.sender);
token.grantRole(token.MINTER_ROLE(), msg.sender);
token.grantRole(token.BURNER_ROLE(), msg.sender);
token.grantRole(token.UPGRADER_ROLE(), address(this));
Because the token creator is granted DEFAULT_ADMIN_ROLE, they can revoke or grant any role, including revoking the UPGRADER_ROLE from the factory. The token enforces upgrades via UUPS and requires UPGRADER_ROLE:
function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) { }
The factory exposes an admin-only upgrade function that expects to be able to upgrade tokens it created:
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
FactoryStorage storage fs = _getFactoryStorage();
// Ensure the token was created by this factory
if (fs.tokenToImplementation[token] == address(0)) {
revert TokenNotCreatedByFactory();
}
// Ensure the new implementation is whitelisted
bytes32 codeHash = _getCodeHash(newImplementation);
if (!fs.allowedImplementations[codeHash]) {
revert ImplementationNotWhitelisted();
}
// Perform the upgrade (this assumes the token implements UUPSUpgradeable)
UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");
// Update the implementation mapping
fs.tokenToImplementation[token] = newImplementation;
emit TokenUpgraded(token, newImplementation);
}
If the token creator revokes UPGRADER_ROLE from the factory, the factory's call to UUPSUpgradeable(token).upgradeToAndCall will revert because _authorizeUpgrade will fail the onlyRole(UPGRADER_ROLE) check. Conversely, the token owner (having DEFAULT_ADMIN_ROLE) can grant themself UPGRADER_ROLE and upgrade the token implementation arbitrarily.
Impact Details
- The ArcTokenFactory will be unable to upgrade tokens it created if the token creator revokes the UPGRADER_ROLE from the factory.
- Token creators could upgrade their token to an arbitrary implementation by granting themselves UPGRADER_ROLE, which may break intended guarantees or introduce malicious logic.
- Overall: intended upgradeability and central admin control can be lost or subverted by token creators who hold DEFAULT_ADMIN_ROLE.
Proof of Concept
{% stepper %} {% step %} User creates a token by calling createToken on ArcTokenFactory. {% endstep %}
{% step %} The factory grants the user roles including DEFAULT_ADMIN_ROLE. {% endstep %}
{% step %} The factory also grants itself the UPGRADER_ROLE to allow upgrades. {% endstep %}
{% step %} The token creator revokes every role that was granted to the ArcTokenFactory (including UPGRADER_ROLE). {% endstep %}
{% step %} The factory (admin) can no longer upgrade the token using upgradeToken because _authorizeUpgrade requires UPGRADER_ROLE. {% endstep %}
{% step %} The token creator can grant themself UPGRADER_ROLE and upgrade the token implementation to any address. {% endstep %} {% endstepper %}
References
- https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenFactory.sol#L144
- https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcTokenFactory.sol#L261
- https://github.com/immunefi-team/attackathon-plume-network/blob/580cc6d61b08a728bd98f11b9a2140b84f41c802/arc/src/ArcToken.sol#L648
Context
Plume Network runs a smart contract bug bounty on Immunefi, and this report targets the ArcTokenFactory contract in the arc package of the attackathon repository. The factory is the component that creates Arc tokens and is also the component expected to upgrade them later. Each token it creates is a UUPS-upgradeable contract whose upgrade authorisation is gated by a role check.
The feature under scrutiny is the role wiring done at token creation time. When a token is created, the factory hands the creator a broad set of roles and keeps the upgrade role for itself, so that the factory can push new implementations to tokens it created through an admin-only upgradeToken function. The report shows that this arrangement can be undone by the token creator, because the creator is also given the role that administers every other role.
The report is rated High, with the stated impact being that the contract fails to deliver promised returns but does not lose value.
Setup
The relevant actors and roles are:
- The token creator, the account that calls
createTokenon the factory. - The factory itself, which holds
UPGRADER_ROLEon each token it creates and exposesupgradeTokentoDEFAULT_ADMIN_ROLEholders. - The token, a UUPS-upgradeable contract that enforces
UPGRADER_ROLEin_authorizeUpgrade.
The precondition is simply that a token has been created through the factory. No special tooling, version numbers or configuration are described in the report; the analysis is entirely about the role model and the upgrade path.
Finding it
The factory assigns DEFAULT_ADMIN_ROLE to the creator at creation. In an AccessControl-style model, the admin of a role can grant and revoke that role. Since DEFAULT_ADMIN_ROLE is the top of the hierarchy, the creator can therefore grant or revoke any role on the token, including the UPGRADER_ROLE that the factory relies on.
That looked wrong because the factory's upgrade function assumes it will always be able to upgrade the tokens it created. The token's own upgrade guard only checks UPGRADER_ROLE, and the creator controls who holds it.
Exploitation
Step 1: Create a token
The user creates a token by calling createToken on ArcTokenFactory.
Step 2: The factory grants the creator roles
At creation the factory assigns multiple roles to the token creator and assigns UPGRADER_ROLE to itself (address(this)):
token.grantRole(token.DEFAULT_ADMIN_ROLE(), msg.sender);
token.grantRole(token.ADMIN_ROLE(), msg.sender);
token.grantRole(token.MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_DISTRIBUTOR_ROLE(), msg.sender);
token.grantRole(token.MINTER_ROLE(), msg.sender);
token.grantRole(token.BURNER_ROLE(), msg.sender);
token.grantRole(token.UPGRADER_ROLE(), address(this));
The important line is the first one: DEFAULT_ADMIN_ROLE goes to msg.sender, the creator. The last line gives the factory the upgrade role.
Step 3: The token enforces upgrades through the role
The token uses UUPS and requires UPGRADER_ROLE for any upgrade:
function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) { }
Step 4: The factory's upgrade path
The factory exposes an admin-only upgrade function that expects to be able to upgrade tokens it created:
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
FactoryStorage storage fs = _getFactoryStorage();
// Ensure the token was created by this factory
if (fs.tokenToImplementation[token] == address(0)) {
revert TokenNotCreatedByFactory();
}
// Ensure the new implementation is whitelisted
bytes32 codeHash = _getCodeHash(newImplementation);
if (!fs.allowedImplementations[codeHash]) {
revert ImplementationNotWhitelisted();
}
// Perform the upgrade (this assumes the token implements UUPSUpgradeable)
UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");
// Update the implementation mapping
fs.tokenToImplementation[token] = newImplementation;
emit TokenUpgraded(token, newImplementation);
}
The function checks that the token came from this factory and that the new implementation is whitelisted, then calls upgradeToAndCall on the token. That inner call is what runs _authorizeUpgrade, and therefore what depends on the factory still holding UPGRADER_ROLE.
Step 5: The creator revokes the factory's roles
The token creator revokes every role that was granted to the ArcTokenFactory, including UPGRADER_ROLE. Because the creator holds DEFAULT_ADMIN_ROLE, this is permitted.
Step 6: The factory can no longer upgrade
The factory (admin) can no longer upgrade the token using upgradeToken, because _authorizeUpgrade requires UPGRADER_ROLE and the factory no longer has it. The call to UUPSUpgradeable(token).upgradeToAndCall reverts when the onlyRole(UPGRADER_ROLE) check fails.
Step 7: The creator upgrades on their own terms
Conversely, the token creator can grant themself UPGRADER_ROLE and upgrade the token implementation to any address. The factory's whitelist check on implementations is bypassed entirely, because the creator is not going through upgradeToken.
Root cause
The mistake is in the role design at creation time: the creator is granted DEFAULT_ADMIN_ROLE, which is the admin of every role on the token, while the factory's ability to upgrade depends on holding UPGRADER_ROLE on that same token. The two facts are incompatible. The factory's upgradeToken guards its own entry point with onlyRole(DEFAULT_ADMIN_ROLE) and checks factory provenance and implementation whitelisting, but none of those checks help once the token's own _authorizeUpgrade rejects the factory. The token's upgrade guard trusts UPGRADER_ROLE alone, and the creator can remove that role from the factory or take it for themself.
Impact
- The
ArcTokenFactorywill be unable to upgrade tokens it created if the token creator revokesUPGRADER_ROLEfrom the factory. - Token creators could upgrade their token to an arbitrary implementation by granting themselves
UPGRADER_ROLE, which may break intended guarantees or introduce malicious logic. - Overall, intended upgradeability and central admin control can be lost or subverted by token creators who hold
DEFAULT_ADMIN_ROLE.
Fix
The report does not describe a fix or a change that was made. Based on the root cause, the role wiring needs to change so that the creator cannot remove the factory's upgrade authority, for example by not giving the creator DEFAULT_ADMIN_ROLE over the upgrade role, or by having the token's upgrade guard accept the factory independently of a role the creator can revoke. The report itself does not state which approach was chosen.
Variants to test
- Look for factories that grant
DEFAULT_ADMIN_ROLEto the creator while relying on a role they hold on the created contract. A positive result is that the creator can revoke the factory's role and the factory's admin function then reverts. - Look for upgrade guards that check only a role on the token, with no separate check that the caller is the factory. A positive result is that the creator can grant themselves the upgrade role and call the upgrade entry point directly, bypassing any whitelist enforced by the factory.
- Look for admin functions that validate provenance and whitelisting but assume the downstream call will succeed. A positive result is a revert inside the downstream authorisation check after all the factory's own checks have passed.
Hunting notes
This kind of bug hides in role assignment code at deployment or creation time, especially where a broad admin role is handed to an external party and the protocol later depends on a narrower role on the same contract. During review, the signal is a grantRole block that gives the caller DEFAULT_ADMIN_ROLE alongside roles the protocol itself needs. The second signal is an upgrade or privileged function whose success depends on a role held by the protocol on a contract the user administers.
The proof of concept walks the full lifecycle: creation, role grants, revocation by the creator, the resulting revert in the factory's upgrade path, and the creator's ability to upgrade to an arbitrary implementation.
What happened, in plain words
Plume Network is a blockchain project, and it runs a bug bounty programme on a platform called Immunefi. A bug bounty is a public offer: if you find a security problem in the software and report it responsibly, the project pays you a reward. This report is one of those submissions. It is rated High severity, which on these platforms usually means a serious problem that should be fixed soon.
The report is about a smart contract called ArcTokenFactory. A smart contract is a small program that lives on a blockchain. Once deployed, anyone can call its functions, and the code runs exactly as written. Think of it as a vending machine that anyone can walk up to and press buttons on: the machine has rules about who is allowed to do what.
The factory has one job: it creates new tokens. A token here is a digital asset contract, a bit like a custom-made coin with its own rules. The factory also has a second job: it is supposed to be able to upgrade the tokens it created later on, for example to fix a bug or add a feature. Upgrading a smart contract means swapping out the code that runs behind the same address, so users keep the same token but the behaviour changes.
The report shows that the person who creates a token through the factory is given so much power over that token that they can take away the factory's ability to upgrade it. Worse, that same person can then upgrade the token themselves to any code they like, skipping the factory's safety checks. The factory promises a controlled upgrade process, and the token creator can quietly break that promise.
Background you need first
Before the details make sense, here are the ideas the report leans on.
Blockchain and smart contracts. A blockchain is a shared ledger that many computers keep copies of. A smart contract is code stored on that ledger. Anyone can send it a message (a "call") asking it to do something, and the contract executes the instructions it was programmed with. There is no administrator sitting behind it clicking buttons; the code is the authority.
Tokens. In this context a token is itself a smart contract that represents something valuable, for example a balance that users hold. Because it is a contract, it has functions that can mint new units, burn units, move them around, and so on.
Roles and access control. Most serious contracts do not let anyone do anything. They use a role system: named permissions that can be handed to wallet addresses. If your address holds the MINTER_ROLE, you may create new tokens. If it holds the BURNER_ROLE, you may destroy them. This is the same idea as staff badges in an office: the badge for the server room opens the server room, the badge for the cash office opens the cash office.
DEFAULT_ADMIN_ROLE. In the widely used AccessControl pattern (part of the OpenZeppelin library), there is one special role that sits above all the others. Whoever holds the admin role of a given role can grant it to someone and revoke it from someone. DEFAULT_ADMIN_ROLE is the admin of every role by default. In badge terms, it is the master key that can also print and cancel every other badge. If you hold it, you decide who holds everything else.
Upgradeable contracts and UUPS. Normally a smart contract's code can never change. To allow fixes, developers use an upgrade pattern. The address users interact with stays the same, but it forwards calls to a separate contract that holds the actual logic, called the implementation. Swapping the implementation is an upgrade. UUPS (Universal Upgradeable Proxy Standard) is one such pattern. It includes a guard function, _authorizeUpgrade, that runs before any upgrade and decides whether the caller is allowed to do it. If the guard rejects the caller, the upgrade fails.
Revert. When a smart contract decides a call is not allowed, it "reverts": it stops, undoes any changes, and returns an error. It is the blockchain equivalent of a form being rejected at the counter.
Whitelist. A list of approved items. Here, the factory keeps a list of implementation contracts it is willing to upgrade tokens to, so that nobody can point a token at arbitrary code.
The setup: who is who
The report describes three parties.
- The token creator: the account (a wallet address) that calls
createTokenon the factory to make a new token. - The factory: the
ArcTokenFactorycontract itself. It holds the upgrade role on every token it creates, and it offers an admin-only function calledupgradeTokenfor pushing new implementations. - The token: a UUPS-upgradeable contract that checks for the upgrade role before allowing an upgrade.
The only precondition is that a token has been created through the factory. The report does not mention any special tools, version numbers or configuration; the whole issue is about how permissions are handed out and how the upgrade path depends on them.
Finding it: what the researcher noticed
The code that runs when a token is created hands out the roles described below. The creator receives DEFAULT_ADMIN_ROLE. That is the master key described above. Because the holder of the admin role of a role can grant and revoke that role, and because DEFAULT_ADMIN_ROLE is the admin of everything, the creator can grant or revoke any role on the token. That includes the UPGRADER_ROLE that the factory itself relies on.
That looked wrong because the factory's upgrade function assumes it will always be able to upgrade the tokens it created. The token's own upgrade guard checks only for UPGRADER_ROLE, and the creator controls who holds that role. So the factory's assumption and the creator's power contradict each other.
Exploitation, step by step
Step 1: Create a token
The user creates a token by calling createToken on ArcTokenFactory. This is the normal, intended first step: the factory is the official way to make a new Arc token, so the creator goes through it.
Step 2: The factory grants the creator roles
At creation the factory assigns multiple roles to the token creator and assigns UPGRADER_ROLE to itself (address(this)):
token.grantRole(token.DEFAULT_ADMIN_ROLE(), msg.sender);
token.grantRole(token.ADMIN_ROLE(), msg.sender);
token.grantRole(token.MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_MANAGER_ROLE(), msg.sender);
token.grantRole(token.YIELD_DISTRIBUTOR_ROLE(), msg.sender);
token.grantRole(token.MINTER_ROLE(), msg.sender);
token.grantRole(token.BURNER_ROLE(), msg.sender);
token.grantRole(token.UPGRADER_ROLE(), address(this));
Line by line:
token.grantRole(token.DEFAULT_ADMIN_ROLE(), msg.sender);gives the master admin role tomsg.sender. In a contract,msg.senderis the address that made the current call, here the token creator. This is the line that matters most: it makes the creator the top authority on the token.token.grantRole(token.ADMIN_ROLE(), msg.sender);gives the creator the general admin role.token.grantRole(token.MANAGER_ROLE(), msg.sender);gives the creator the manager role.token.grantRole(token.YIELD_MANAGER_ROLE(), msg.sender);gives the creator the role that manages yield, meaning the returns or rewards the token produces.token.grantRole(token.YIELD_DISTRIBUTOR_ROLE(), msg.sender);gives the creator the role that distributes those returns.token.grantRole(token.MINTER_ROLE(), msg.sender);gives the creator the right to create new units of the token.token.grantRole(token.BURNER_ROLE(), msg.sender);gives the creator the right to destroy units of the token.token.grantRole(token.UPGRADER_ROLE(), address(this));gives the upgrade role toaddress(this), which is the factory contract's own address. This is how the factory reserves for itself the right to upgrade the token later.
So the first line hands the creator the master key, and the last line hands the factory the upgrade badge. The creator, holding the master key, can later cancel the factory's badge.
Step 3: The token enforces upgrades through the role
The token uses UUPS and requires UPGRADER_ROLE for any upgrade:
function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) { }
This is the guard that runs before any upgrade. _authorizeUpgrade is the function the UUPS pattern calls to ask "is this caller allowed to change the implementation?". The parameter newImplementation is the address of the new code that would take over. The body is empty, because the decision is made entirely by the modifier onlyRole(UPGRADER_ROLE): if the caller does not hold the upgrade role, the call reverts. Nothing else is checked here, no factory identity, no whitelist. The role is the only gate.
Step 4: The factory's upgrade path
The factory exposes an admin-only upgrade function that expects to be able to upgrade tokens it created:
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {
FactoryStorage storage fs = _getFactoryStorage();
// Ensure the token was created by this factory
if (fs.tokenToImplementation[token] == address(0)) {
revert TokenNotCreatedByFactory();
}
// Ensure the new implementation is whitelisted
bytes32 codeHash = _getCodeHash(newImplementation);
if (!fs.allowedImplementations[codeHash]) {
revert ImplementationNotWhitelisted();
}
// Perform the upgrade (this assumes the token implements UUPSUpgradeable)
UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");
// Update the implementation mapping
fs.tokenToImplementation[token] = newImplementation;
emit TokenUpgraded(token, newImplementation);
}
Line by line:
function upgradeToken(address token, address newImplementation) external onlyRole(DEFAULT_ADMIN_ROLE) {declares a function anyone can call from outside (external), taking the token address and the address of the new implementation. The modifieronlyRole(DEFAULT_ADMIN_ROLE)means only holders of the factory's own admin role may call it.FactoryStorage storage fs = _getFactoryStorage();loads the factory's stored data, so the function can read and write its records.if (fs.tokenToImplementation[token] == address(0)) {checks the factory's record of which implementation each token uses. If the record is empty (the zero address), the token was not made by this factory.revert TokenNotCreatedByFactory();stops the call with that error if the check failed. This is the provenance check: only tokens born here can be upgraded here.bytes32 codeHash = _getCodeHash(newImplementation);computes a fingerprint (hash) of the new implementation's code.if (!fs.allowedImplementations[codeHash]) {asks whether that fingerprint is on the factory's whitelist of approved implementations.revert ImplementationNotWhitelisted();stops the call if it is not on the list.UUPSUpgradeable(token).upgradeToAndCall(newImplementation, "");is the actual upgrade. It calls the token's upgrade function, which internally runs_authorizeUpgradefrom Step 3. The empty string is extra data to run after the upgrade, here nothing.fs.tokenToImplementation[token] = newImplementation;records the new implementation in the factory's storage.emit TokenUpgraded(token, newImplementation);writes a log entry (an event) so the upgrade is visible on the blockchain.
The key point: the factory checks provenance and the whitelist, then relies on the token accepting the call. That acceptance depends on the factory still holding UPGRADER_ROLE.
Step 5: The creator revokes the factory's roles
The token creator revokes every role that was granted to the ArcTokenFactory, including UPGRADER_ROLE. Because the creator holds DEFAULT_ADMIN_ROLE, this is permitted. The master key can cancel any badge, including the factory's upgrade badge.
Step 6: The factory can no longer upgrade
The factory (admin) can no longer upgrade the token using upgradeToken, because _authorizeUpgrade requires UPGRADER_ROLE and the factory no longer has it. The call to UUPSUpgradeable(token).upgradeToAndCall reverts when the onlyRole(UPGRADER_ROLE) check fails. The factory's own checks pass, the whitelist check passes, and then the token itself says no.
Step 7: The creator upgrades on their own terms
Conversely, the token creator can grant themself UPGRADER_ROLE and upgrade the token implementation to any address. The factory's whitelist check on implementations is bypassed entirely, because the creator is not going through upgradeToken. They call the token's upgrade function directly, and the token's guard sees the role and allows it. The safety net that was supposed to keep tokens on approved code no longer applies.
Root cause
The mistake is in the role design at creation time: the creator is granted DEFAULT_ADMIN_ROLE, which is the admin of every role on the token, while the factory's ability to upgrade depends on holding UPGRADER_ROLE on that same token. The two facts are incompatible. The factory's upgradeToken guards its own entry point with onlyRole(DEFAULT_ADMIN_ROLE) and checks factory provenance and implementation whitelisting, but none of those checks help once the token's own _authorizeUpgrade rejects the factory. The token's upgrade guard trusts UPGRADER_ROLE alone, and the creator can remove that role from the factory or take it for themself.
In everyday terms: the building manager hands a new tenant the master key to the building, and also relies on a key of their own to get into the tenant's flat for maintenance. The tenant can change the locks, and the manager is locked out. The tenant can also let anyone else in without the manager's approval.
Impact
- The
ArcTokenFactorywill be unable to upgrade tokens it created if the token creator revokesUPGRADER_ROLEfrom the factory. - Token creators could upgrade their token to an arbitrary implementation by granting themselves
UPGRADER_ROLE, which may break intended guarantees or introduce malicious logic. - Overall, intended upgradeability and central admin control can be lost or subverted by token creators who hold
DEFAULT_ADMIN_ROLE.
The report is rated High, with the stated impact being that the contract fails to deliver promised returns but does not lose value. In other words, no funds are directly stolen by this bug, but the upgrade mechanism the protocol promises does not work as advertised, and the whitelist that is supposed to constrain upgrades can be sidestepped.
Fix
The report does not describe a fix or a change that was made. Based on the root cause, the role wiring needs to change so that the creator cannot remove the factory's upgrade authority, for example by not giving the creator DEFAULT_ADMIN_ROLE over the upgrade role, or by having the token's upgrade guard accept the factory independently of a role the creator can revoke. The report itself does not state which approach was chosen.
Variants to test
If you want to look for the same class of bug elsewhere, these angles are worth testing.
- Look for factories that grant
DEFAULT_ADMIN_ROLEto the creator while relying on a role they hold on the created contract. A positive result is that the creator can revoke the factory's role and the factory's admin function then reverts. - Look for upgrade guards that check only a role on the token, with no separate check that the caller is the factory. A positive result is that the creator can grant themselves the upgrade role and call the upgrade entry point directly, bypassing any whitelist enforced by the factory.
- Look for admin functions that validate provenance and whitelisting but assume the downstream call will succeed. A positive result is a revert inside the downstream authorisation check after all the factory's own checks have passed.
Hunting notes
This kind of bug hides in role assignment code at deployment or creation time, especially where a broad admin role is handed to an external party and the protocol later depends on a narrower role on the same contract. During review, the signal is a grantRole block that gives the caller DEFAULT_ADMIN_ROLE alongside roles the protocol itself needs. The second signal is an upgrade or privileged function whose success depends on a role held by the protocol on a contract the user administers.
The proof of concept walks the full lifecycle: creation, role grants, revocation by the creator, the resulting revert in the factory's upgrade path, and the creator's ability to upgrade to an arbitrary implementation.
Glossary
- AccessControl: a standard permission system for smart contracts where named roles are granted to addresses, and each role has an admin role that can grant or revoke it.
- Address: the identifier of an account or contract on a blockchain, similar to an account number.
- Admin role: the role that controls who holds a particular role; it can grant and revoke it.
- Blockchain: a shared, replicated ledger maintained by many computers, on which smart contracts run.
- Bug bounty: a programme that pays people for responsibly reporting security problems instead of exploiting them.
- Call: a message sent to a smart contract asking it to run one of its functions.
- Contract provenance check: a check that an item was created by a particular contract, here that the token came from this factory.
DEFAULT_ADMIN_ROLE: the top-level role in AccessControl, which by default administers every other role.- Event: a log entry a contract writes to the blockchain so that the action is visible and can be tracked.
- External function: a function that can be called from outside the contract.
- Factory: a contract whose purpose is to create other contracts, here new tokens.
- Hash / code hash: a short fingerprint computed from data, used to identify code without storing all of it.
- High severity: a rating meaning a serious issue that should be fixed promptly.
- Immunefi: a platform where blockchain projects publish bug bounties and receive security reports.
- Implementation: the contract that holds the actual logic behind an upgradeable contract's address.
- Modifier: a keyword in Solidity attached to a function that adds a check or behaviour before the function body runs.
msg.sender: in a smart contract, the address that made the current call.- OpenZeppelin: a widely used library of reusable smart contract components, including AccessControl and upgradeable contracts.
- Proxy: the contract at the stable address that forwards calls to an implementation contract.
- Revert: aborting a call, undoing its changes and returning an error because a rule was not met.
- Role: a named permission in a smart contract that can be granted to addresses.
- Smart contract: a program stored on a blockchain that anyone can call and that runs as written.
- Solidity: the programming language used to write smart contracts on Ethereum-style blockchains.
- Storage: the persistent data a smart contract keeps on the blockchain.
- Token: a smart contract representing a digital asset with balances and rules.
- Upgrade: replacing the implementation behind an upgradeable contract so its behaviour changes while its address stays the same.
UPGRADER_ROLE: the role that a token's upgrade guard checks for before allowing an upgrade.- UUPS: an upgrade pattern where the upgrade authorisation check lives in the implementation contract, in a function called
_authorizeUpgrade. - Whitelist: a list of approved items, here approved implementation contracts.
- Yield: the returns or rewards a token is designed to produce.