Reproduced Exploit
Excluded-deposit FEI is reported as user-circulating
pcvStats skips deposits in excludedDeposits, then sets userCirculatingFei to fei.totalSupply() - protocolControlledFei. FEI that sits in an excluded deposit is not protocol-controlled and is not removed from supply, so it is reported as user-circulating. With supply 10_000e18, an included deposit o…
Loss
userCirculatingFei is 6000e18. The fair amount is 3000e18. Protocol equity is 0 instead of 3000e18. The 3000e…
Chain
Ethereum
Category
oracle
Date
Sep 2021
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack replays in your browser. Step through it by Solidity line or by opcode.
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 13297-collateralizationoracle-fei-in-excluded-deposits-contributes. Standalone Foundry PoC and full write-up: 13297-collateralizationoracle-fei-in-excluded-deposits-contributes_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/oracle/collateralization · vuln/logic/accounting
Reproduction: self-contained synthetic Foundry reduction; see output.txt.
Key info#
| Field | Value |
|---|---|
| Loss | userCirculatingFei is 6000e18. The fair amount is 3000e18. Protocol equity is 0 instead of 3000e18. The 3000e18 gap is FEI inside the excluded deposit |
| Vulnerable contract | CollateralizationOracle.pcvStats |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2021-09 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | Supply minus only non-excluded FEI treats excluded-deposit FEI as free |
TL;DR#
pcvStats skips deposits in excludedDeposits, then sets userCirculatingFei to fei.totalSupply() - protocolControlledFei. FEI that sits in an excluded deposit is not protocol-controlled and is not removed from supply, so it is reported as user-circulating. With supply 10_000e18, an included deposit of 4_000e18 FEI, and an excluded deposit of 3_000e18 FEI, circulating is 6_000e18 instead of 3_000e18. Equity is 0 instead of 3_000e18. The control subtracts the excluded FEI and does not count it as circulating.
Background#
ConsenSys Diligence reviewed Fei Protocol V2 phase 1 in September 2021. CollateralizationOracle.pcvStats walks every PCV deposit, adds resistant balances and resistant FEI, prices the balances, and treats the rest of the FEI supply as user-circulating. A guardian or governor can exclude a deposit that is reporting bad numbers. The exclusion drops that deposit's collateral out of PCV. It also, incorrectly, leaves that deposit's FEI inside userCirculatingFei. The report notes that if every deposit is excluded, the entire supply is reported as user-circulating.
The vulnerable code#
if (!_excluded[d]) {
(uint256 b, uint256 f) = Deposit(d).resistantBalanceAndFei();
balSum += b;
controlled += f;
}
userCirculatingFei = fei.totalSupply() - controlled; // @> VULN: excluded FEI counts as circulating.
protocolEquity = int256(protocolControlledValue) - int256(userCirculatingFei);
The audited function is CollateralizationOracle.pcvStats around lines 278-328, as quoted in the finding.
Root cause#
The skip and the supply subtraction do not match. Collateral of an excluded deposit is left out of PCV, which is the point of the exclusion. The FEI in that same deposit is then treated as if a user held it. Circulating is too high by that FEI balance, and equity is too low by the same amount. validityStatus stays true.
Preconditions#
- FEI supply is
10_000e18. The price of the PCV token is1e18($1). - Included deposit: resistant balance
6_000e18, resistant FEI4_000e18. - Excluded deposit: resistant FEI
3_000e18. Its collateral is not added to PCV. - Buggy circulating is
6_000e18. Fair circulating is3_000e18. - Buggy equity is
0. Fair equity is3_000e18.
Attack walkthrough#
pcvStatscounts the included deposit and skips the excluded one.- PCV is
6_000e18. Circulating is10_000e18 - 4_000e18 = 6_000e18. Equity is0. - The overstatement,
3_000e18, is minted to the sink. - The control still ignores the excluded collateral, but it subtracts the excluded FEI. Circulating is
3_000e18and equity is3_000e18. No marker is minted.
Diagrams#
Impact#
Downstream consumers of userCirculatingFei and protocolEquity see 3_000e18 more free FEI than exists, and equity that is 3_000e18 too low. The collateralization ratio is skewed by that amount. The control shows the same balances with the excluded FEI removed from circulating, so the 3_000e18 is not reported as user-held.
Remediation#
Do not treat FEI inside an excluded deposit as user-circulating. Subtract it from supply as well, and do not add that deposit's collateral to PCV:
- if (!excludedDeposits[deposit]) {
- (balance, feiBal) = deposit.resistantBalanceAndFei();
- totalTokenBalance += balance;
- protocolControlledFei += feiBal;
- }
- userCirculatingFei = fei().totalSupply() - protocolControlledFei;
+ (balance, feiBal) = deposit.resistantBalanceAndFei();
+ if (!excludedDeposits[deposit]) {
+ totalTokenBalance += balance;
+ protocolControlledFei += feiBal;
+ } else {
+ excludedFei += feiBal;
+ }
+ userCirculatingFei = fei().totalSupply() - protocolControlledFei - excludedFei;
How to reproduce#
cd 13297-collateralizationoracle-fei-in-excluded-deposits-contributes_exp
forge test -vv
Sources#
- AuditVault finding: 13297-collateralizationoracle-fei-in-excluded-deposits-contributes
- ConsenSys Diligence, Fei Protocol V2 phase 1, September 2021: https://consensys.net/diligence/audits/2021/09/fei-protocol-v2-phase-1/
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 13297-collateralizationoracle-fei-in-excluded-deposits-contributes_exp (evm-hack-registry mirror).
- AuditVault finding: 13297-collateralizationoracle-fei-in-excluded-deposits-contributes.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.