Reproduced Exploit

Term Structure: borrowTokenFromGt spends a victim GT id

A user approves the router for an existing GT id so the router can call issueFtByExistedGt. borrowTokenFromGt never checks that msg.sender owns that id. An attacker who holds XT front-runs the call, names themselves as recipient, and receives 80e8 debt tokens while the victim's position takes the d…

Feb 2025•Ethereum•logic•3 min read

Loss

Attacker receives 80e8 debt tokens. The victim's GT owes that debt

Chain

Ethereum

Category

logic

Date

Feb 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: 54894-an-attacker-can-steal-debt-tokens-by-using-the-user-s-gtid-c. Standalone Foundry PoC and full write-up: 54894-an-attacker-can-steal-debt-tokens-by-using-the-user-s-gtid-c_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/logic/missing-check

Key info#

FieldValue
LossAttacker receives 80e8 debt tokens. The victim's GT owes that debt
Vulnerable contractRouter.borrowTokenFromGt
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · local · 2025-02
Compilersolc 0.8.27, cancun
Bug classMissing ownerOf(gtId) == msg.sender check

TL;DR#

A user approves the router for an existing GT id so the router can call issueFtByExistedGt. borrowTokenFromGt never checks that msg.sender owns that id. An attacker who holds XT front-runs the call, names themselves as recipient, and receives 80e8 debt tokens while the victim's position takes the debt.

Background#

Cantina's February 2025 Term Structure review, reported by Nyksx. The proof logs the attacker's debt balance moving from 0 to 8000000000. The fix, in pull requests 4 and 5, checks GT ownership.

The vulnerable code#

SOLIDITY
(ERC20 ft, ERC20 xt,,,) = market.tokens();
uint128 debtAmt = uint128((borrowAmt * DECIMAL_BASE) / (DECIMAL_BASE - issueFtFeeRatio));
uint256 ftOutAmt = market.issueFtByExistedGt(address(this), debtAmt, gtId); // @> VULN: victim gtId, no owner check
DIFF
+ require(gt.ownerOf(gtId) == msg.sender);
  uint256 ftOutAmt = market.issueFtByExistedGt(address(this), debtAmt, gtId);

Root cause#

The market checks that the router is approved for the GT. It does not see the original caller. The router, which does see the caller, never compares that caller with ownerOf.

Preconditions#

  • The victim owns a GT and has approved the router for that id.
  • The attacker holds enough XT to pair with the issued FT. Here that is 80e8, obtained by locking 100e8 of their own debt.
  • issueFtFeeRatio is 0, so debtAmt equals borrowAmt.

Attack walkthrough#

  1. The attacker mints 100e8 debt, spends it in market.mint, and receives XT. Their debt balance is back to 0.
  2. The victim opens gtId 1 and approves the router.
  3. The attacker calls borrowTokenFromGt(attacker, market, 1, 80e8).
  4. The router issues FT against the victim's GT. The victim's debt becomes 80e8.
  5. The router pulls 80e8 XT from the attacker and burns FT plus XT.
  6. The market mints 80e8 debt tokens to the attacker.

Diagrams#

flowchart TD A["Victim owns gtId 1 and approves the router"] --> B["Attacker holds XT from their own mint"] B --> C["Attacker calls borrowTokenFromGt with their own recipient"] C --> D["VULN issueFtByExistedGt adds debt to the victim GT"] D --> E["Router burns FT and the attacker XT"] E --> F["Attacker receives 80e8 debt tokens"]

Impact#

The attacker ends the call holding 80e8 debt tokens. gtId 1 is still owned by the victim and now records 80e8 of debt. The attacker did not post the victim's collateral.

Remediation#

Require gt.ownerOf(gtId) == msg.sender at the start of borrowTokenFromGt.

How to reproduce#

BASH
cd 54894-an-attacker-can-steal-debt-tokens-by-using-the-user-s-gtid-c_exp
forge test -vv

test_exploit_attacker_receives_80e8_debt_against_victim_gt asserts the attacker debt balance, the victim debt, and the unchanged owner. 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.