# Min and maxAnswer never checked for oracle price feed

BakerFi's EthOracle returns raw Chainlink answer without min/maxAnswer bounds, so a crashed asset returns the floor price and lets users borrow against a wrong price.

- Payout: Audit contest
- Severity: medium
- Program: BakerFi
- Found by: t0x1c
- Disclosed: 2024-06-24
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-05-bakerfi-findings/issues/16
- Library page: https://bugbountylibrary.com/r/c4%3A2024-05-bakerfi%3AM-06
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:oracle-manipulation

**Target:** Chainlink ETH price feed consumer (EthOracle.getLatestPrice)
**Root cause:** getLatestPrice reads latestRoundData and only checks answer>0 and timestamps, never validating answer against the aggregator's minAnswer/maxAnswer band, so a price crash below the band returns the stale floor price.
**Steps:**
1. Read contracts/oracles/EthOracle.sol getLatestPrice: `(, int256 answer, uint256 startedAt, uint256 updatedAt,) = _ethPriceFeed.latestRoundData();`
2. Observe only checks `answer<=0` and `startedAt==0 || updatedAt==0`; no min/maxAnswer comparison
3. When underlying aggregator price falls below minAnswer, latestRoundData returns minAnswer instead of true price
4. Protocol consumes this inflated price for borrow/collateral logic
**How found:** Code review of the oracle wrapper against known Chainlink circuit-breaker behavior; compared to prior audit findings (USSD, Blueberry) where missing minAnswer checks caused mispricing.
**Exploitation:** If the collateral asset crashes below the aggregator's minAnswer band, the oracle keeps returning minAnswer; users continue borrowing against an overvalued asset, leaving the protocol with bad debt (as in the Venus/LUNA incident).
**Insight:** When auditing any Chainlink consumer, check that latestRoundData is validated against the aggregator's minAnswer/maxAnswer band, not just positivity and staleness — a crash below the band silently returns the floor price.

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

**EthOracle getLatestPrice missing min/max check**

```
function getLatestPrice() public view override returns (IOracle.Price memory price) {
@-->    (, int256 answer, uint256 startedAt, uint256 updatedAt,) = _ethPriceFeed.latestRoundData();
        if ( answer<= 0 ) revert InvalidPriceFromOracle();        
        if ( startedAt ==0 || updatedAt == 0 ) revert InvalidPriceUpdatedAt();    

        price.price = uint256(answer);
        price.lastUpdate = updatedAt;
    }
```

