Reproduced Exploit

Regnum Aurum: a repaid loan stays insured, so the next borrow skips the fee

The insurance fee is 1 percent of principal, charged only when isInsured is false. A full repay sets rawInsuredBalance down to the new debt, which is 0, and leaves isInsured true. The comment in the report says that reset is supposed to force the next loan to buy insurance again. It does not. The s…

May 2025•Ethereum•logic•4 min read

Loss

The second 10,000 loan pays 0 of the 100 token insurance fee. The vault holds 100 instead of 200

Chain

Ethereum

Category

logic

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: 66182-h-20-users-can-avoid-insurance-fee-when-reborrowing-debt-pas. Standalone Foundry PoC and full write-up: 66182-h-20-users-can-avoid-insurance-fee-when-reborrowing-debt-pas_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/incorrect-state-transition · vuln/defi/fee-manipulation

Key info#

FieldValue
LossThe second 10,000 loan pays 0 of the 100 token insurance fee. The vault holds 100 instead of 200
Vulnerable contractLendingPool._repay
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2025-05
Compilersolc 0.8.27, cancun, via IR
Bug classisInsured is not cleared when debt is fully repaid

TL;DR#

The insurance fee is 1 percent of principal, charged only when isInsured is false. A full repay sets rawInsuredBalance down to the new debt, which is 0, and leaves isInsured true. The comment in the report says that reset is supposed to force the next loan to buy insurance again. It does not. The second 10,000 borrow disburses principal and charges nothing. The insurance vault holds 100. Clearing the flag when debt hits zero charges 200.

Background#

Pashov Audit Group, Regnum Aurum review dated 2025-05-06, finding H-20. The quoted repay caps rawInsuredBalance to rawDebtBalance and does not assign isInsured = false. This run uses a 1 percent fee so the skipped charge is 100 tokens on a 10,000 principal. The report does not publish the production fee rate. The skipped charge scales with that rate.

The vulnerable code#

SOLIDITY
if (position.rawInsuredBalance > position.rawDebtBalance) {
    // @> VULN: insured balance is capped to remaining debt, but isInsured stays true
    position.rawInsuredBalance = position.rawDebtBalance;
}
// FIX: if (position.rawDebtBalance == 0) position.isInsured = false;

borrow charges only in the !position.isInsured branch, then sets the flag.

Root cause#

Two fields describe the same insurance. Repay updates the balance and not the flag. The next borrow reads the flag.

Preconditions#

  • The fee is 100 basis points of principal.
  • The borrower pays the fee from a separate token balance, then receives principal.
  • The first loan is repaid in full, so rawInsuredBalance is greater than the remaining debt.

Attack walkthrough#

  1. The borrower opens 10,000. The pool pulls 100 into the insurance vault, sets isInsured, and disburses 10,000.
  2. The borrower repays 10,000. Debt is 0. Insured balance is still 10,000, so the cap writes 0.
  3. isInsured is still true.
  4. The borrower opens 10,000 again. The fee branch is skipped. feesCharged stays 1.
  5. The insurance vault holds 100. The borrower holds the new 10,000 principal and did not pay a second 100.
  6. The control uses the same pool with the flag cleared on zero debt. Two borrows charge 200.

Diagrams#

flowchart TD A["Borrow 10000 while isInsured is false"] --> B["Insurance vault receives the 100 fee"] B --> C["Repay the full 10000"] C --> D["VULN rawInsuredBalance becomes 0 and isInsured stays true"] D --> E["Second borrow of 10000 skips the fee"] E --> F["Vault holds 100 instead of 200"] D --> G["Control clears isInsured when debt hits 0"] G --> H["Second borrow pays another 100 and the vault holds 200"]

Impact#

The insurance vault is short the second fee: 100 tokens on this 10,000 reborrow, which is the entire 1 percent premium. The borrower keeps that 100 and still draws a 10,000 principal with the insured flag set. The control vault collects 200 for the same two loans.

Remediation#

When rawDebtBalance reaches 0, set position.isInsured to false, which is the fix the report recommends.

How to reproduce#

BASH
cd 66182-h-20-users-can-avoid-insurance-fee-when-reborrowing-debt-pas_exp
forge test -vv

test_exploit_reborrow_skips_insurance_fee asserts one fee, an insurance balance of 100, and the flag still set. test_control_full_repay_clears_the_flag asserts two fees and an insurance balance of 200. 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.