Reproduced Exploit

CAP Labs: VaultAdapter.rate stores an arbitrary vault's utilization and charges 5000 instead of 100

rate(vault, asset) calls currentUtilizationIndex and utilization on the address it was given and writes the results into utilizationData. A contract that returns index 9 and utilization 5 becomes the stored slope for that asset. Accrual on a 1000 principal then charges 1000 * 5 = 5000 and transfers…

May 2025•Ethereum•oracle•4 min read

Loss

5000 collateral seized from a borrower. An honest 10% utilization charges 100 on a 1000 principal

Chain

Ethereum

Category

oracle

Date

May 2025

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

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.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 61535-unvalidated-vault-address-in-vaultadapter-allows-interest-r. Standalone Foundry PoC and full write-up: 61535-unvalidated-vault-address-in-vaultadapter-allows-interest-r_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/oracle/missing-validation · vuln/oracle/price-manipulation

AuditVault taxonomy: severity/high · has/github · has/poc · lang/solidity · sector/oracle · sector/lending · platform/trailofbits · genome: oracle-manipulation-resistance · extcall-return-validation · oracle/price-manipulation · defi/price-manipulation · known-pattern · single-tx · add-check · precondition/privileged-caller · misassumption/external-call-is-safe · blast-radius/protocol-wide

Key info#

FieldValue
Loss5000 collateral seized from a borrower. An honest 10% utilization charges 100 on a 1000 principal
Vulnerable contractVaultAdapter.rate
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-05
Compilersolc 0.8.27, cancun, via IR
Bug class_vault is not checked before its index and utilization are stored

TL;DR#

rate(vault, asset) calls currentUtilizationIndex and utilization on the address it was given and writes the results into utilizationData. A contract that returns index 9 and utilization 5 becomes the stored slope for that asset. Accrual on a 1000 principal then charges 1000 * 5 = 5000 and transfers that much of the borrower's collateral to the caller. The same call against a vault that reports 0.1 charges 100 and leaves 5900 of the 6000 collateral in the adapter.

Background#

Trail of Bits' May 2025 review of the CAP Labs Covered Agent Protocol, Benjamin Samuels, figure 12.1, contracts/oracle/libraries/VaultAdapter.sol lines 26 to 49. The function is permissionless in the quoted snippet. The short-term recommendation is an allowlist or access control. The long-term recommendation is input validation on every external address the adapter trusts.

The vulnerable code#

SOLIDITY
uint256 index = IVault(_vault).currentUtilizationIndex(_asset);
// ...
utilization = IVault(_vault).utilization(_asset);
// @> VULN: index, lastUpdate, and the slope input come from an unvalidated _vault
utilizationData[_asset].index = index;
utilizationData[_asset].lastUpdate = block.timestamp;

Because lastUpdate starts at 0, elapsed equals block.timestamp, and the branch that reads utilization() is the one that runs. Both return values are still attacker-controlled. The stored index is 9 either way.

Root cause#

_vault is an argument, not a storage slot that was set by an admin. The adapter treats its return values as the market's utilization index and writes them into the rate state other functions read.

Preconditions#

  • VaultAdapter.rate can be called by the attacker with any vault address.
  • The adapter holds 6000 of borrower collateral against a 1000 principal.
  • The attacker's vault returns currentUtilizationIndex = 9e18 and utilization = 5e18. An honest vault returns utilization 0.1e18.

Attack walkthrough#

  1. rate(evil, asset) reads index 9 and utilization 5.
  2. Storage for that asset becomes index 9, lastUpdate equal to the block timestamp, and utilization multiplier 5.
  3. accrue computes interest as 1000 * 5 and transfers 5000 collateral to the caller.
  4. 1000 collateral remains. The control vault reports 0.1, charges 100, and leaves 5900.

Diagrams#

flowchart TD A["Attacker calls rate with their own vault"] --> B["Vault returns index 9 and utilization 5"] B --> C["VULN adapter stores both"] C --> D["Accrual charges 1000 times 5"] D --> E["5000 collateral moves to the lender"] A --> F["Honest vault reports utilization 0.1"] F --> G["The same principal is charged 100"]

Impact#

The caller receives 5000 collateral tokens. The fair interest at 10% utilization is 100. The borrower who posted the 6000 is left with 1000 instead of 5900. The stored index and multiplier stay corrupted for later readers of utilizationData.

Remediation#

Allowlist the vault, or restrict rate to a trusted role, before any external call. Do not write index, lastUpdate, or utilizationMultiplier from an unchecked return value.

How to reproduce#

BASH
cd 61535-unvalidated-vault-address-in-vaultadapter-allows-interest-r_exp
forge test -vv

test_evil_vault_charges_5000_instead_of_100 asserts a 5000 seizure and a fair value of 100. test_control_honest_vault_charges_100 asserts the 0.1 vault charges 100. Captured output is output.txt.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

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.