Skip to content
Access control Audit finding Intermediate

Asset Manager can update existing _assetAggregator

The addAsset function allows an asset manager to change the price aggregator for an existing asset, which affects all functions using that asset. An attacker with the asset manager role could replace the aggregator with a malicious one, potentially manipulating prices.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

ChainlinkPriceOracle.sol#L60

Asset Manager can update the aggregator of an existing asset thus impacting all function making use of this asset. Ideally if an aggregator is already set for an asset the function should fail.

Proof of Concept

  1. Asset Manager call function addAsset to adds an asset X with assetAggregator value as Y
  2. This is being utilized across application
  3. Now Asset Manager calls the same function addAsset with asset X with assetAggregator value as Z
  4. Asset aggregator value for asset X gets changed to Z even though it was already set to Y

Recommended Mitigation Steps

addAsset should only work if assetInfoOf[_asset] value is empty.

olivermehr (Phuture Finance) disputed

jn-lp (Phuture Finance) commented:

Aggregators often break or are updated to new logic, the manager tracks these changes and sets the value to the current one.

moose-code (judge) commented:

Have to assume that ASSETMANAGERROLE is behaving honestly in the first place otherwise everything falls apart, so this is a centralization issue.

The big question is who is being given the ASSETMANAGERROLE ? This role has the power to rug everyone in every index.

Given this is unclear who is given this role (can’t see anything in codebase explicitly on it, no deploy scripts, no documentation on it), one can’t know who is given ASSETMANAGERROLE. Given this assumption, this is a valid finding as basically one asset manager could change the oracle for another asset managers index?

Going to give this one to the warden for bringing up a valid point.


The original report as published on Code4rena, by csanuragjain. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Phuture is a protocol whose contracts include a Chainlink-based price oracle, ChainlinkPriceOracle.sol. The finding concerns the function that writes an asset's aggregator, addAsset, and the role allowed to call it, ASSET_MANAGER_ROLE. The finding concerns the function that writes this record, addAsset, and the role that is allowed to call it, ASSET_MANAGER_ROLE.

The report points at a single line of the contract:

Text
ChainlinkPriceOracle.sol#L60

Setup

The only actor involved is the Asset Manager, the holder of ASSET_MANAGER_ROLE. No other accounts, tools or versions are described. The precondition for the issue is simply that an asset has already been registered with an aggregator, and that the same Asset Manager calls the registration function again for that asset.

Finding it

The researcher noticed that addAsset does not check whether an asset is already known. If an aggregator is already set for an asset, the function should fail, but instead it overwrites the stored aggregator. Because every function that uses the asset reads that stored value, a second call silently changes the price source for an asset that is already in use across the application.

Exploitation

Step 1: register asset X with aggregator Y

The Asset Manager calls addAsset to add an asset X with assetAggregator value Y. The asset is now recorded with aggregator Y.

Step 2: the asset is used across the application

Asset X, with aggregator Y, is being utilised across the application. Every function that relies on the asset's aggregator now resolves to Y.

Step 3: register asset X again with aggregator Z

The Asset Manager calls the same function, addAsset, with asset X, this time with assetAggregator value Z.

Step 4: the stored aggregator changes

The aggregator value for asset X is changed to Z, even though it was already set to Y. The aggregator value for asset X gets changed to Z even though it was already set to Y.

Root cause

If an aggregator is already set for an asset, the function should fail, but instead a second call changes the stored aggregator. The report's recommended check is that addAsset should only work if assetInfoOf[_asset] is empty.

The program disputed the finding. Phuture Finance argued that aggregators often break or are updated to new logic, and that the manager tracks these changes and sets the value to the current one, so overwriting is intended behaviour.

The judge took a different view. The judge reasoned that ASSET_MANAGER_ROLE has to be assumed honest, otherwise everything falls apart, which makes this a centralisation issue. The open question was who receives that role: the judge noted that the codebase does not state it explicitly, there are no deploy scripts and no documentation on it, so it cannot be known who holds ASSET_MANAGER_ROLE. On that basis the judge treated the report as a valid finding, because one asset manager could change the oracle for another asset manager's index, and awarded it to the researcher for raising a valid point.

Impact

A holder of ASSET_MANAGER_ROLE can change the aggregator of an asset that is already registered and in use, which affects every function that makes use of that asset. The judge framed the role as one that has the power to rug everyone in every index, and described the scenario in which one asset manager changes the oracle for another asset manager's index. The judge noted it cannot be known who holds ASSET_MANAGER_ROLE, since the codebase, deploy scripts and documentation do not state it.

Fix

The report recommends making addAsset work only when assetInfoOf[_asset] is empty. The report's recommendation is to make addAsset work only when assetInfoOf[_asset] is empty, so that a second registration for an existing asset fails instead of overwriting its aggregator. The program's position was that overwriting is deliberate, to keep the aggregator current when it breaks or changes logic.

Variants to test

  1. Registration functions for other record types (oracles, tokens, vaults, strategies) that write without checking for an existing entry. A positive result is a second call for the same key that succeeds and changes the stored value.
  2. Privileged setters that update a dependency (price source, router, implementation) for an object already in use by other users. A positive result is one role holder changing configuration that another user's position depends on.
  3. Role assignment and documentation gaps: look for privileged roles whose holders are not defined in code, deploy scripts or docs. A positive result is a role with broad configuration power and no stated owner.

Hunting notes

This kind of bug tends to hide in privileged registration and configuration functions, especially where the same function serves both first-time setup and later updates. During review, look for writes to a mapping keyed by an asset or identifier with no emptiness check before the write, and trace which other functions read that mapping. The signal is a setter that succeeds on a second call and changes state that other users already rely on.

On impact, the report shows the value of naming the exact role, the exact stored field and the downstream consumers, and of being explicit about the trust assumption. The judge gave the finding to the warden for raising a valid point, noting the role holder is undefined and one manager could change the oracle for another manager's index.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Phuture is a set of programs (called smart contracts) that run on a blockchain and together form a financial protocol. One of those programs is a price oracle: a piece of software whose job is to tell the rest of the system what an asset is worth. Phuture's oracle is in a contract file called ChainlinkPriceOracle.sol.

For each asset the oracle stores an aggregator value, which the report calls assetAggregator. The asset is utilised across the application, so functions making use of it are affected when its aggregator changes.

The report is about the function that writes this record, addAsset, and about the role that is allowed to call it, ASSET_MANAGER_ROLE. A "role" in this kind of contract is a permission label: only an account that has been given the label may run the function. The person or account holding it is called the Asset Manager.

The problem the researcher describes is simple to state. addAsset does not check whether the asset it is being asked to register is already known. If an asset already has an aggregator, the function should refuse the call, but instead it quietly replaces the stored aggregator with the new one. Since everything else reads that stored value, a second call silently changes where the price for an asset that is already in use comes from.

Context

Phuture is a protocol whose contracts include a Chainlink-based price oracle, ChainlinkPriceOracle.sol. An oracle, in this setting, is a contract that answers the question "what is this asset worth right now?" for other contracts. The oracle is a Chainlink-based price oracle, as the report's file reference indicates.

The oracle keeps an aggregator value for each asset, stored in the assetInfoOf mapping. The rest of the application reads that record whenever it needs a price for the asset, the same way you would look up a phone number in the address book rather than memorising it.

The finding concerns the function that writes this record, addAsset, and the role that is allowed to call it, ASSET_MANAGER_ROLE. Writing the record means creating or changing the address-book line. The role is the permission that decides who may do that writing.

The report points at a single line of the contract:

Text
ChainlinkPriceOracle.sol#L60

This is not code to run; it is a pointer. It names the file ChainlinkPriceOracle.sol and says that line 60 is where the behaviour at the heart of the report lives. Giving a file and line number lets a reader open the same contract and land on the exact spot, instead of searching through the whole file.

Setup

The only actor involved is the Asset Manager, the holder of ASSET_MANAGER_ROLE. No other accounts, tools or versions are described. The precondition for the issue is simply that an asset has already been registered with an aggregator, and that the same Asset Manager calls the registration function again for that asset.

In other words, you do not need an attacker with special tools or a complicated chain of steps. You need one account that already has permission to register assets, and you need it to register the same asset twice. The first call is normal setup. The second call is the one that reveals the behaviour.

Finding it

The researcher noticed that addAsset does not check whether an asset is already known. If an aggregator is already set for an asset, the function should fail, but instead it overwrites the stored aggregator. Because every function that uses the asset reads that stored value, a second call silently changes the price source for an asset that is already in use across the application.

A useful comparison is a form that is supposed to be filled in once. If the form is submitted a second time, you would expect the system to say "this already exists". Here, the second submission is accepted and the old answers are replaced. Nothing warns anyone, and anything that relied on the old answers now gets the new ones.

Exploitation

Step 1: register asset X with aggregator Y

The Asset Manager calls addAsset to add an asset X with assetAggregator value Y. The asset is now recorded with aggregator Y.

This is the ordinary, intended use of the function: a new asset arrives, and the manager tells the oracle which aggregator supplies its price. After this step, the address book contains one line: asset X points at aggregator Y.

Step 2: the asset is used across the application

Asset X, with aggregator Y, is being utilised across the application. Every function that relies on the asset's aggregator now resolves to Y.

This step matters because it establishes that other parts of the system depend on the record. They do not keep their own copy of the aggregator address; they look it up each time. So whatever the record says becomes the truth for all of them.

Step 3: register asset X again with aggregator Z

The Asset Manager calls the same function, addAsset, with asset X, this time with assetAggregator value Z.

Nothing about this call is unusual from the contract's point of view. It is the same function, the same asset, the same kind of argument, only a different aggregator address. The manager is not doing anything the function forbids, because the function forbids nothing here.

Step 4: the stored aggregator changes

The aggregator value for asset X is changed to Z, even though it was already set to Y. The aggregator value for asset X gets changed to Z even though it was already set to Y.

The address book line for asset X now points at Z. Every function that looks up the price of asset X follows the new address. The aggregator value for asset X is now Z instead of Y.

Root cause

If an aggregator is already set for an asset, the function should fail, but instead a second call changes the stored aggregator. The report's recommended check is that addAsset should only work if assetInfoOf[_asset] is empty.

assetInfoOf is the mapping, a lookup table inside the contract, that holds each asset's record. The recommendation is to look in that table before writing: if there is already something there for this asset, stop. An everyday comparison is a cloakroom that hands out a ticket per coat. If someone arrives with a second coat and the same ticket number, the attendant should refuse rather than hang the new coat on the same hook and lose the first one.

The program disputed the finding. Phuture Finance argued that aggregators often break or are updated to new logic, and that the manager tracks these changes and sets the value to the current one, so overwriting is intended behaviour.

In plain terms, the team said the overwrite is a feature, not a bug: price suppliers do get replaced in the real world, and the manager needs a way to point the asset at the working supplier when the old one stops working.

The judge took a different view. The judge reasoned that ASSET_MANAGER_ROLE has to be assumed honest, otherwise everything falls apart, which makes this a centralisation issue. The open question was who receives that role: the judge noted that the codebase does not state it explicitly, there are no deploy scripts and no documentation on it, so it cannot be known who holds ASSET_MANAGER_ROLE. On that basis the judge treated the report as a valid finding, because one asset manager could change the oracle for another asset manager's index, and awarded it to the researcher for raising a valid point.

Centralisation, here, means that power sits with one party rather than being spread out or constrained by code. A deploy script is the automated set of instructions used to put the contracts on the blockchain; it often records which accounts get which roles. Documentation is the written explanation of the system. The judge's point is that none of these sources say who ends up with the role, so a reader cannot tell how much trust the design assumes.

Impact

A holder of ASSET_MANAGER_ROLE can change the aggregator of an asset that is already registered and in use, which affects every function that makes use of that asset. The judge framed the role as one that has the power to rug everyone in every index, and described the scenario in which one asset manager changes the oracle for another asset manager's index. The impact therefore depends entirely on who holds the role and on how far the role is trusted; the report itself does not establish who that is.

"Rug" is informal slang for pulling the value out from under users, for example by changing something they depend on so that their position loses value. The judge described the role as having the power to rug everyone in every index. If the price source for an asset can be swapped, the numbers shown for any index containing that asset can change with it.

Fix

The report recommends making addAsset work only when assetInfoOf[_asset] is empty. The report's recommendation is to make addAsset work only when assetInfoOf[_asset] is empty, so that a second registration for an existing asset fails instead of overwriting its aggregator. The program's position was that overwriting is deliberate, to keep the aggregator current when it breaks or changes logic.

So there are two coherent designs on the table. One treats registration as a one-time act and forces any later change through a separate, explicit path. The other treats the same function as both setup and maintenance. The report argues for the first; the team says it built the second on purpose.

Variants to test

  1. Registration functions for other record types (oracles, tokens, vaults, strategies) that write without checking for an existing entry. A positive result is a second call for the same key that succeeds and changes the stored value.
  2. Privileged setters that update a dependency (price source, router, implementation) for an object already in use by other users. A positive result is one role holder changing configuration that another user's position depends on.
  3. Role assignment and documentation gaps: look for privileged roles whose holders are not defined in code, deploy scripts or docs. A positive result is a role with broad configuration power and no stated owner.

A setter is simply a function whose job is to set a value. A vault is a contract that holds funds on behalf of users, and a strategy is the logic that decides what those funds do. The common thread across these three checks is the same question: can one permitted account change something that other people are already relying on, and does anyone say who that account is?

Hunting notes

This kind of bug tends to hide in privileged registration and configuration functions, especially where the same function serves both first-time setup and later updates. During review, look for writes to a mapping keyed by an asset or identifier with no emptiness check before the write, and trace which other functions read that mapping. The signal is a setter that succeeds on a second call and changes state that other users already rely on.

Idempotent means that repeating an action has the same result as doing it once. Here the repetition looks harmless, because the function succeeds both times, yet the second run destroys the earlier value. That gap between how harmless the call looks and what it actually does is what makes the issue easy to miss.

On impact, the report shows the value of naming the exact role, the exact stored field and the downstream consumers, and of being explicit about the trust assumption. The judge gave the finding to the warden for raising a valid point, noting the role holder is undefined and one manager could change the oracle for another manager's index.

Glossary

  • Smart contract: a program that runs on a blockchain and executes automatically according to its code.
  • Protocol: a set of smart contracts that together provide a service, here a financial one.
  • Oracle: a contract or service that supplies outside data, such as prices, to other contracts.
  • Chainlink: an external service that collects and delivers price data to blockchains.
  • Aggregator: the component, identified by an address, that actually supplies the price for an asset.
  • Address: a short identifier for an account or contract on the blockchain, comparable to an account number.
  • Asset: a thing whose price is tracked, such as a token.
  • Function: a named block of code in a contract that can be called to do something.
  • addAsset: the function that registers an asset and stores its aggregator address.
  • Role: a permission label in a contract; only accounts given the label may call the functions that require it.
  • ASSET_MANAGER_ROLE: the role that is allowed to call addAsset.
  • Asset Manager: the account holding ASSET_MANAGER_ROLE.
  • Mapping: a lookup table inside a contract that stores a value for each key, such as a record per asset.
  • assetInfoOf: the mapping that holds each asset's stored record.
  • Guard: a check at the start of a function that stops it when conditions are not met.
  • Overwrite: replacing an existing stored value with a new one.
  • Idempotent: an action whose repetition has the same effect as doing it once.
  • Centralisation: a design where important power sits with one party instead of being spread out or limited by code.
  • Deploy script: the automated instructions used to put contracts on the blockchain, often recording which accounts receive which roles.
  • Index: a basket of assets whose combined value is tracked using the protocol's prices.
  • Rug: informal slang for pulling value away from users, for example by changing something their position depends on.
  • Setter: a function whose purpose is to set a stored value.
  • Vault: a contract that holds funds on behalf of users.
  • Strategy: the logic that decides what funds in a vault are used for.
  • Judge: in a bug-finding contest, the person who decides whether a submitted report is valid.
  • Warden: in a bug-finding contest, the researcher who submits a report.

More by Anurag Jain

View all

63 more disclosed reports, best first.

More from Phuture

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.