Reproduced Exploit

Gondi — refinanceFromLoanExecutionData missing tokenId check

1. Refinance re-uses the NFT already in escrow (no transfer out/in). 2. Offer validation uses attacker-controlled executionData.tokenId. 3. No check that it matches the escrowed loan.nftCollateralTokenId. 4. Lender accepts a blue-chip id; escrow still holds junk → undercollateralized loan.

Apr 2024Otheruntagged3 min read

Chain

Other

Category

untagged

Date

Apr 2024

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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 35206-h-04-function-refinancefromloanexecutiondata-does-not-check. Standalone Foundry PoC and full write-up: 35206-h-04-function-refinancefromloanexecutiondata-does-not-check_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/wrong-condition · vuln/direct-drain · vuln/access-roles

Reproduction: self-contained Foundry PoC with only forge-std — no fork, no RPC. Full trace: output.txt. PoC: test/35206-h-04-function-refinancefromloanexecutiondata-does-not-check.sol.


Key info#

ImpactHIGH — borrower refinances a junk-NFT loan using a blue-chip-only offer by spoofing executionData.tokenId; lender funds principal while only the junk NFT remains in escrow
ProtocolGondi — NFT multi-source lending
Vulnerable coderefinanceFromLoanExecutionData passes executionData.tokenId into _processOffersFromExecutionData without requiring equality to loan.nftCollateralTokenId
Bug classMissing collateral-id consistency check on refinance
FindingCode4rena — Gondi, 2024-04 · #35206 · reporter minhquanym
Reportcode4rena.com/reports/2024-04-gondi
SourceAuditVault
StatusAudit finding — confirmed and mitigated (tokenIdCheck added)
Compiler^0.8.24 (PoC)

TL;DR#

  1. Refinance re-uses the NFT already in escrow (no transfer out/in).
  2. Offer validation uses attacker-controlled executionData.tokenId.
  3. No check that it matches the escrowed loan.nftCollateralTokenId.
  4. Lender accepts a blue-chip id; escrow still holds junk → undercollateralized loan.

The vulnerable code#

SOLIDITY
// FIX would be: require(executionData.tokenId == loan.nftCollateralTokenId);
uint256 newLoanId = _processOffersFromExecutionData(
    loan,
    executionData.principalReceiver,
    executionData.tokenId, // @> VULN: unmatched with loan.nftCollateralTokenId
    newOfferId
);

Fix: require(executionData.tokenId == loan.nftCollateralTokenId).

Root cause#

Refinance optimizes by not moving the NFT, but still lets the borrower name a different token id for offer validation. Lenders' collateral constraints are checked against the spoofed id, not the asset actually secured by the protocol.

Attack walkthrough#

  1. Open loan against junk NFT #999.
  2. Post refinance offer requiring blue-chip #1.
  3. Call refinance with executionData.tokenId = 1.
  4. Offer validates; principal paid out; escrow still #999.

Diagrams#

flowchart LR A["Escrowed NFT #999 junk"] --> B["refinance executionData.tokenId = #1"] B --> C["Offer validators check #1"] C --> D["Principal paid to borrower"] D --> E["Escrow still #999"] E --> F["Lender undercollateralized"]

Impact#

Lenders can be forced into loans secured by collateral they never accepted. Principal is at risk of total loss relative to the blue-chip they thought they underwrote.

Taxonomy#

  • genome: wrong-condition, direct-drain, access-roles, liquidation-underwater, oracle-freshness, reward-accounting
  • sector: lending, nft, nft-lending, staking
  • severity: high
  • platform: code4rena

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.