Reproduced Exploit
OpenTrade: initiateRollover trusts an arbitrary prior loan
initiateRollover is onlyPoolController and passes priorLoan into calculateRollover with no check. That function adds principal() and interest() from whatever address it was given. The active loan would report 110. The controller passes a contract whose principal() is the pool's token balance. The p…
Loss
1000 USDC moves from the pool to the controller's loan. The active loan was only 110
Chain
Ethereum
Category
input-validation
Date
Sep 2023
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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: 47890-loan-address-validation-ottersec-none-opentrade-pdf. Standalone Foundry PoC and full write-up: 47890-loan-address-validation-ottersec-none-opentrade-pdf_exp in the
evm-hack-registrymirror.
Vulnerability classes:
vuln/input-validation/missing·vuln/logic/missing-validation
Key info#
| Field | Value |
|---|---|
| Loss | 1000 USDC moves from the pool to the controller's loan. The active loan was only 110 |
| Vulnerable contract | Pool.initiateRollover |
| Attacker EOA | 0x1111111111111111111111111111111111111111 |
| Attack contract | Exploit |
| Attack tx | Exploit.run() |
| Chain / block / date | Ethereum model · block 0 · 2023-09 |
| Compiler | solc 0.8.27, cancun, via IR |
| Bug class | priorLoan is not the active loan |
TL;DR#
initiateRollover is onlyPoolController and passes priorLoan into calculateRollover with no check. That function adds principal() and interest() from whatever address it was given. The active loan would report 110. The controller passes a contract whose principal() is the pool's token balance. The pool transfers 1000 USDC to the controller's new loan and is left empty.
The vulnerable code#
function initiateRollover(address loan, address priorLoan) external onlyPoolController {
(assetsFromPriorToNextLoan) = calculateRollover(priorLoan); // @> VULN: priorLoan is not required to be the active loan
liquidity.transfer(loan, assetsFromPriorToNextLoan);
}
OtterSec's patch requires priorLoan == activeLoan before the call.
Root cause#
calculateRollover trusts the loan for the numbers that size a token transfer. The only caller gate is the pool controller. The controller is supposed to roll the active loan, not to choose the oracle for how much cash leaves the pool. Without the equality check, the controller picks both the number and the recipient.
Preconditions#
- The pool holds 1000 of the liquidity asset.
- The active loan's principal plus interest is 110.
- The caller is the pool controller and can deploy a contract with
principal()andinterest().
Attack walkthrough#
- Read the honest rollover: 110.
- Call
initiateRollover(adminLoan, fakeLoan). fakeLoan.principal()returnstoken.balanceOf(pool), which is 1000. Interest is 0.- The pool transfers 1000 to
adminLoan. - The pool balance is 0. The excess over the honest figure is 890.
Diagrams#
Impact#
Lenders' 1000 USDC is pulled out in one call. A rollover that passes the real active loan moves 110 and leaves 890 in the pool. The controller is a privileged role, and the missing check is what turns that role into an unbounded withdrawal.
Remediation#
Require priorLoan == activeLoan (and the destination loan to be the requested loan) before calculateRollover, as in the OtterSec patch.
How to reproduce#
cd 47890-loan-address-validation-ottersec-none-opentrade-pdf_exp
forge test -vv
Sources#
- AuditVault finding: https://github.com/Auditware/AuditVault/blob/main/findings/47890-loan-address-validation-ottersec-none-opentrade-pdf.md
- OpenTrade: https://www.open-trade.io/
- Fix noted in the finding: commit
e20b41a
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 47890-loan-address-validation-ottersec-none-opentrade-pdf_exp (evm-hack-registry mirror).
- AuditVault finding: 47890-loan-address-validation-ottersec-none-opentrade-pdf.
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.