Index managers can rug user funds
The ORDERER_ROLE role allows arbitrary transfer of user funds and is also required for rebalancing indices. A malicious manager with this role could steal user funds.
Submitted by IllIllI, also found by Kenshin
The ORDERER_ROLE role has the ability to arbitrarily transfer user funds, and this role is shared between both the orderer and people who can rebalance the index.
Even if the owner is benevolent the fact that there is a rug vector available may negatively impact the protocol’s reputation. See this example where a similar finding has been flagged as a high-severity issue. I’ve downgraded this instance to be a medium since it requires a malicious manager.
Proof of Concept
The role is given to the orderer so it has the ability to add/remove funds during Uniswap operations: File: contracts/vToken.sol (lines 80-87)
/// @inheritdoc IvToken
function transferFrom(
address _from,
address _to,
uint _shares
) external override nonReentrant onlyRole(ORDERER_ROLE) {
_transfer(_from, _to, _shares);
}
The role is also required to initiate rebalances: File: contracts/TopNMarketCapIndex.sol (lines 67-68)
/// @notice Reweighs index assets according to the latest market cap data for specified category
function reweight() external override onlyRole(ORDERER_ROLE) {
File: contracts/TrackedIndex.sol (lines 56-57)
/// @notice Reweighs index assets according to the latest market cap data
function reweight() external override onlyRole(ORDERER_ROLE) {
It is not necessary for the person/tool initiating reweights to also have the ability to arbitrarily transfer funds, so they should be separate roles. If the orderer also needs to be able to reweight, the orderer should also be given the new role.
Recommended Mitigation Steps
Split the role into two, and only give the ORDERER_ROLE role to the orderer.
olivermehr (Phuture Finance) disputed
jn-lp (Phuture Finance) commented:
ORDERER_ROLErole is only given to Orderer contract by multisig, which must have the ability toreweightindices as well as totransferFromon vToken contract
I agree with the warden at the very least there is only benefit in splitting this role out appropriately into two roles. There is likely a case where the ordered and index rebalancers aren’t the same.
Context
Phuture is a protocol for index products. An index holds a basket of assets, and the protocol periodically reweights those assets according to the latest market cap data. Two contracts are central to this report: vToken, which represents shares in a vault and supports transfers between accounts, and the index contracts TopNMarketCapIndex and TrackedIndex, which expose a reweight() function that rebalances the index.
Access to both of these operations is gated by a single role, ORDERER_ROLE. The report argues that this single role bundles two very different capabilities: moving user funds and triggering rebalances.
Setup
The finding concerns the role configuration rather than a specific account or tool. The relevant precondition is that ORDERER_ROLE is held by the orderer and by the people or tools that can rebalance the index. The report notes that the role is shared between both the orderer and the rebalancers.
Finding it
The researcher noticed that ORDERER_ROLE is required for two operations that do not need to be performed by the same party:
- Transferring shares of the vault token from one address to another.
- Initiating a reweight of an index.
The orderer needs the transfer capability so it can add or remove funds during Uniswap operations. The rebalancers need the reweight capability. Because both are guarded by the same role, anyone who can reweight can also arbitrarily transfer user funds.
The researcher points out that even if the owner is benevolent, the existence of a rug vector may negatively impact the protocol's reputation, and cites a similar finding that was flagged as high severity in another Code4rena audit. This instance was downgraded to medium because it requires a malicious manager.
Exploitation
Step 1: Confirm the transfer capability is gated by ORDERER_ROLE
In contracts/vToken.sol (lines 80-87), transferFrom is restricted to the orderer role:
/// @inheritdoc IvToken
function transferFrom(
address _from,
address _to,
uint _shares
) external override nonReentrant onlyRole(ORDERER_ROLE) {
_transfer(_from, _to, _shares);
}
The onlyRole(ORDERER_ROLE) modifier restricts transferFrom to holders of the role. The nonReentrant modifier only prevents reentrancy; it does not restrict who the role holder can move funds for.
Step 2: Confirm the same role is required to reweight
In contracts/TopNMarketCapIndex.sol (lines 67-68):
/// @notice Reweighs index assets according to the latest market cap data for specified category
function reweight() external override onlyRole(ORDERER_ROLE) {
And in contracts/TrackedIndex.sol (lines 56-57):
/// @notice Reweighs index assets according to the latest market cap data
function reweight() external override onlyRole(ORDERER_ROLE) {
Both index contracts gate reweight() on the same ORDERER_ROLE. A party that is trusted only to trigger rebalances therefore also holds the ability to call transferFrom on the vault token.
Step 3: Combine the two capabilities
Because the role is shared, a malicious manager who is authorised to reweight can call transferFrom to move user shares to an address of their choosing. The report does not show a concrete transaction or response; the proof of concept is the role overlap demonstrated by the two code excerpts above.
Root cause
The design uses a single role, ORDERER_ROLE, for two operations with different trust requirements. The orderer legitimately needs to add and remove funds during Uniswap operations, which is why it holds the transfer capability. The rebalancers only need to call reweight(). Granting both the same role means the rebalancers inherit the transfer capability, and the transferFrom function has no additional check that would limit which shares the role holder can move.
nonReentrant addresses a different class of issue.
Impact
A holder of ORDERER_ROLE can arbitrarily transfer user funds through vToken.transferFrom. The report frames this as a rug vector: it requires a malicious manager, which is why the researcher rated it medium rather than high. Even without a malicious actor, the availability of the vector may negatively affect the protocol's reputation.
Fix
The recommended mitigation is to split the role into two and only give ORDERER_ROLE to the orderer. If the orderer also needs to be able to reweight, the orderer should be given the new role as well.
Phuture disputed the finding. In a comment, jn-lp (Phuture Finance) stated that ORDERER_ROLE is only given to the Orderer contract by multisig, which must have the ability to reweight indices as well as to transferFrom on the vToken contract. The judge, moose-code, agreed with the warden that there is at least benefit in splitting the role appropriately into two roles, noting that there is likely a case where the orderer and index rebalancers are not the same.
Variants to test
Hunting notes
The researcher showed impact by tying the role overlap to a concrete fund-moving function (transferFrom) and citing a comparable finding that had been rated high severity, while acknowledging the precondition of a malicious manager, which is why the severity was set to medium.
What happened, in plain words
Phuture is a protocol for index products. If you have ever seen a fund that holds a basket of shares rather than a single share, that is the idea: an index holds a basket of assets, and the protocol periodically adjusts the contents of the basket according to the latest market cap data. That adjustment is called a reweight.
Two pieces of the system matter here. The first is vToken, a contract that represents shares in a vault and supports transfers between accounts. The second is the pair of index contracts TopNMarketCapIndex and TrackedIndex, which each expose a reweight() function that rebalances the index.
Both of those operations are unlocked by the same key, a role called ORDERER_ROLE. The researcher's point is simple: that one key opens two doors that should not be opened by the same person. One door moves user funds. The other door starts a rebalance. Anyone trusted only to start rebalances therefore also holds the power to move user funds wherever they like.
A quick comparison: imagine a building where the cleaner's keycard opens both the cleaning cupboard and the safe. The cleaner may be perfectly honest, but the design is still wrong, because the day the cleaner is not honest, the safe is gone. The report calls this a rug vector, meaning a way for an insider to pull the rug out from under users.
The concepts you need first
Before the details, a few plain definitions, because the report leans on them constantly.
- A smart contract is a program that lives on a blockchain. It runs automatically, and its behaviour is fixed by its code unless the contract itself provides a way to change it.
- A protocol here means a set of smart contracts that together offer a financial product. Phuture's product is index products.
- A role is a named permission inside a smart contract. Instead of naming individual people, the contract says "only addresses holding this role may call this function". It is like a badge that a door checks before it opens.
- A modifier is a small piece of code attached to a function that runs a check before the function body executes.
onlyRole(ORDERER_ROLE)is a modifier: it checks that the caller holds the role and refuses the call otherwise. - A token is a digital asset recorded on the blockchain. A vault token or share token represents a claim on assets held by the vault, much like a share in a fund.
- Uniswap is a decentralised exchange, a place where tokens are swapped for other tokens without a central operator. The
ordererinteracts with it to add or remove funds. - Reentrancy is a classic bug where a contract calls out to another contract, and that other contract calls back into the first one before the first call has finished, confusing its bookkeeping. The
nonReentrantmodifier blocks that pattern. - A multisig is a wallet that requires several signatures before it can do anything, like a safe that needs two keys turned at once.
- Severity is how serious a finding is judged to be. Medium means real but not the worst case; high means serious.
Setting the scene
The finding is not about a particular account, tool or version. It is about how the contracts are configured. The precondition is that ORDERER_ROLE is held by the orderer and also by the people or tools that can rebalance the index. The report states plainly that the role is shared between both the orderer and the rebalancers.
That sharing is the whole story. Everything below is evidence for it.
Finding it
The researcher noticed that ORDERER_ROLE is required for two operations that do not need to be performed by the same party:
- Transferring shares of the vault token from one address to another.
- Initiating a reweight of an index.
The orderer needs the transfer capability so it can add or remove funds during Uniswap operations. The rebalancers need the reweight capability. Because both are guarded by the same role, anyone who can reweight can also arbitrarily transfer user funds.
The researcher also makes a reputation argument: even if the owner is benevolent, the mere existence of a rug vector may negatively impact the protocol's reputation. A similar finding in another Code4rena audit was flagged as high severity. This instance was downgraded to medium because it requires a malicious manager, that is, someone inside the trusted group has to turn bad.
Walking through the evidence
Step 1: Confirm the transfer capability is gated by ORDERER_ROLE
The first piece of evidence is in contracts/vToken.sol, lines 80 to 87. The transferFrom function, the one that moves shares between accounts, is restricted to the orderer role:
/// @inheritdoc IvToken
function transferFrom(
address _from,
address _to,
uint _shares
) external override nonReentrant onlyRole(ORDERER_ROLE) {
_transfer(_from, _to, _shares);
}
Line by line:
/// @inheritdoc IvTokenis a documentation comment saying this function follows the description given in an interface calledIvToken. It has no effect on behaviour.function transferFrom(starts the declaration of a function namedtransferFrom.address _from,is the first input: the account the shares are taken from.address _to,is the second input: the account the shares go to.uint _sharesis the third input: how many shares to move.) external override nonReentrant onlyRole(ORDERER_ROLE) {is the part that matters.externalmeans the function can be called from outside the contract.overridemeans it replaces a function declared in a parent contract.nonReentrantblocks the reentrancy pattern described above.onlyRole(ORDERER_ROLE)is the access check: the caller must hold the role._transfer(_from, _to, _shares);is the actual movement of shares, performed by an internal helper.}closes the function.
The key observation is that transferFrom is gated by onlyRole(ORDERER_ROLE), so a role holder can call it. The nonReentrant modifier only prevents reentrancy; it does not restrict who the role holder can move funds for. So any holder of the role can move shares from any address to any other address.
Step 2: Confirm the same role is required to reweight
The second piece of evidence is in contracts/TopNMarketCapIndex.sol, lines 67 to 68:
/// @notice Reweighs index assets according to the latest market cap data for specified category
function reweight() external override onlyRole(ORDERER_ROLE) {
And in contracts/TrackedIndex.sol, lines 56 to 57:
/// @notice Reweighs index assets according to the latest market cap data
function reweight() external override onlyRole(ORDERER_ROLE) {
Line by line:
/// @notice ...is a comment describing what the function does. In the first snippet it says the function reweighs index assets according to the latest market cap data for a specified category; in the second, according to the latest market cap data.function reweight() external override onlyRole(ORDERER_ROLE) {declares a function namedreweightthat takes no inputs, can be called from outside, overrides a parent declaration, and requires the caller to holdORDERER_ROLE.
Both index contracts gate reweight() on the same ORDERER_ROLE. That is the overlap: a party trusted only to trigger rebalances also holds the ability to call transferFrom on the vault token.
Step 3: Combine the two capabilities
Because the role is shared, a malicious manager who is authorised to reweight can call transferFrom to move user shares to an address of their choosing. The report does not show a concrete transaction or response; the proof of concept is the role overlap demonstrated by the two code excerpts above. In other words, the evidence is the configuration itself, not a recorded attack.
Why it happens
The design uses a single role, ORDERER_ROLE, for two operations with different trust requirements. The orderer legitimately needs to add and remove funds during Uniswap operations, which is why it holds the transfer capability. The rebalancers only need to call reweight(). Granting both the same role means the rebalancers inherit the transfer capability, and the transferFrom function has no additional check that would limit which shares the role holder can move.
A badge check only keeps out people without the badge; it says nothing about what a badge holder may do. nonReentrant addresses a different class of issue entirely.
What the impact is
A holder of ORDERER_ROLE can arbitrarily transfer user funds through vToken.transferFrom. The report frames this as a rug vector: it requires a malicious manager, which is why the researcher rated it medium rather than high. Even without a malicious actor, the availability of the vector may negatively affect the protocol's reputation.
The fix
The recommended mitigation is to split the role into two and only give ORDERER_ROLE to the orderer. If the orderer also needs to be able to reweight, the orderer should be given the new role as well. In the building comparison, the cleaner gets a keycard for the cupboard, and the safe gets a separate key held by someone else.
Phuture disputed the finding. In a comment, jn-lp (Phuture Finance) stated that ORDERER_ROLE is only given to the Orderer contract by multisig, which must have the ability to reweight indices as well as to transferFrom on the vToken contract. The judge, moose-code, agreed with the warden that there is at least benefit in splitting the role appropriately into two roles, noting that there is likely a case where the orderer and index rebalancers are not the same.
Other places to look
How to spot it during recon
The researcher showed impact by tying the role overlap to a concrete fund-moving function (transferFrom) and citing a comparable finding that had been rated high severity, while acknowledging the precondition of a malicious manager, which is why the severity was set to medium.
Glossary
- Smart contract: a program deployed on a blockchain that runs automatically and exposes functions anyone (or any permitted address) can call.
- Protocol: a set of smart contracts that together provide a financial product.
- Role: a named permission inside a contract; addresses holding the role are allowed to call functions that check for it.
ORDERER_ROLE: the role in this report that unlocks both share transfers and index reweights.- Modifier: a code fragment attached to a function that runs a check before the function body, such as
onlyRoleornonReentrant. onlyRole(ORDERER_ROLE): the modifier that refuses a call unless the caller holdsORDERER_ROLE.nonReentrant: a modifier that blocks reentrancy attacks.- Reentrancy: a bug where a contract is called back into before it has finished its own work, corrupting its bookkeeping.
- Token: a digital asset recorded on a blockchain.
- Vault token / share token: a token representing a claim on assets held by a vault, similar to a share in a fund.
vToken: the contract in this report that represents shares in a vault and supports transfers.transferFrom: a function that moves tokens from one address to another.- Index: a basket of assets tracked as a single product.
- Reweight: the periodic adjustment of an index's contents according to the latest market cap data.
reweight(): the function on the index contracts that triggers a reweight.TopNMarketCapIndex/TrackedIndex: the two index contracts in this report, both gatingreweight()onORDERER_ROLE.orderer: the party that needs to add and remove funds during Uniswap operations.- Uniswap: a decentralised exchange where tokens are swapped without a central operator.
- Multisig: a wallet that requires several signatures before it can act.
- Rug vector: a way for an insider to take users' funds, named after pulling the rug out from under someone.
- Severity: the seriousness rating of a finding, such as medium or high.
- Warden: the term Code4rena uses for the security researcher who submits a finding.
- Judge: the person at Code4rena who assesses the validity and severity of submitted findings.
- Recon: the exploratory phase of a security review, where you map out what the system does and who holds which permissions.