# NoyaValueOracle.getValue returns an incorrect price when a multi-token route is used

NoyaValueOracle._getValue reuses the original asset instead of the intermediate quotingToken across multi-hop routes, returning wrong prices for chained conversions.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: TPSec
- Disclosed: 2025-02-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/1430
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:oracle-manipulation

**Target:** NoyaValueOracle.getValue / _getValue price routing
**Root cause:** In the route loop, _getValue(asset, sources[i], ...) uses the original asset each iteration instead of the running quotingToken, so each hop converts from the source asset rather than the previous hop's output.
**Steps:**
1. Configure a route SOL -> BNB -> ETH -> UNI via updatePriceRoute.
2. Call getValue(SOL, UNI, 100, [BNB, ETH]).
3. Observe loop converts SOL->BNB then SOL->ETH (not BNB->ETH), yielding 1.25 ETH instead of correct intermediate.
4. Final conversion ETH->UNI returns 526 instead of expected 2094.
5. If SOL->ETH or SOL->UNI oracles absent, _getValue reverts with NoyaOracle_PriceOracleUnavailable.
**How found:** Code reading of the _getValue loop: noticed asset passed to recursive _getValue instead of quotingToken, then traced a SOL->BNB->ETH->UNI example to confirm wrong intermediate values.
**Exploitation:** Any protocol logic relying on getValue for multi-hop-routed assets receives a mispriced value, enabling incorrect collateral valuation, borrow/liquidation or accounting decisions; no direct attack sequence described.
**Insight:** In multi-hop oracle routing loops, verify each hop consumes the previous hop's output token, not the original asset; test with a 3+ hop route where intermediate oracles differ to expose stale-variable bugs.

## Proof of concept (copied exactly from the original report)

**Buggy _getValue loop using asset instead of quotingToken**

```
function _getValue(address asset, address baseToken, uint256 amount, address[] memory sources)
        internal
        view
        returns (uint256 value)
    {
        uint256 initialValue = amount;
        address quotingToken = asset;
        for (uint256 i = 0; i < sources.length; i++) {
>           initialValue = _getValue(asset, sources[i], initialValue);
            quotingToken = sources[i];
        }
        return _getValue(quotingToken, baseToken, initialValue);
    }
```

