Reproduced Exploit

pullTokensWithPermit lets any caller spend a user's permit

pullTokensWithPermit calls permit and then transferFrom and never checks that msg.sender is the token owner. A victim signs a permit that lets the router pull 1000 BAKER. An attacker submits that signature first, the tokens land on the router, and sweepTokens sends them to the attacker. The victim'…

Dec 2024•Ethereum•access-control•3 min read

Loss

1000 BAKER taken from the victim. The attacker EOA ends holding all of it

Chain

Ethereum

Category

access-control

Date

Dec 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

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: 49644-h-05-the-implementation-of-pulltokenswithpermit-poses-a-risk. Standalone Foundry PoC and full write-up: 49644-h-05-the-implementation-of-pulltokenswithpermit-poses-a-risk_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control/permit-frontrun

Key info#

FieldValue
Loss1000 BAKER taken from the victim. The attacker EOA ends holding all of it
Vulnerable contractVaultRouter.pullTokensWithPermit
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit at 0x15452EC016c4dc8c549E7fe6Ff4b26324Ea8b7A4
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2024-12
Compilersolc 0.8.27, cancun, via IR
Bug classPermit signature is not bound to the caller

TL;DR#

pullTokensWithPermit calls permit and then transferFrom and never checks that msg.sender is the token owner. A victim signs a permit that lets the router pull 1000 BAKER. An attacker submits that signature first, the tokens land on the router, and sweepTokens sends them to the attacker. The victim's own transaction then sees a used nonce. If the victim pulls and deposits instead, the router credits the victim and the attacker balance stays 0.

The vulnerable code#

SOLIDITY
function pullTokensWithPermit(address owner, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
    external
{
    pulls = amount;
    token.permit(owner, address(this), amount, deadline, v, r, s);
    bool ok = token.transferFrom(owner, address(this), amount); // @> VULN: any caller spends the owner's permit and pulls the tokens
    require(ok, "pull");
}

Root cause#

The permit names the owner, the router, and the amount. It does not name the caller or the action that follows. The router applies the signature for whoever submitted it, then holds a bare token balance that sweepTokens pays to msg.sender.

Preconditions#

  • The victim holds 1000 BAKER and has signed a permit for the router, value 1000, nonce 0.
  • pullTokensWithPermit and sweepTokens are permissionless.
  • The attacker sees the signature before the victim's transaction is mined.

Attack walkthrough#

  1. The victim is minted 1000 BAKER.
  2. The attacker calls pullTokensWithPermit with the victim's v, r, and s.
  3. permit sets the router allowance and burns the nonce.
  4. transferFrom moves 1000 from the victim to the router.
  5. sweepTokens sends that balance to the exploit, which forwards it to the attacker EOA.
  6. The control uses the same signature from the victim, then deposit. The victim's share balance is 1000 and the attacker still has 0.

Diagrams#

flowchart TD A["Victim signs a permit for 1000 BAKER"] --> B["Attacker calls pullTokensWithPermit"] B --> C["permit sets the router allowance"] C --> D["VULN: transferFrom pulls 1000 into the router"] D --> E["sweepTokens forwards 1000 to the attacker"] A --> F["Control: victim pulls and deposits"] F --> G["Victim is credited 1000 and the attacker has 0"]

Impact#

The victim loses 1000 BAKER. The attacker EOA receives the full amount. The victim cannot replay the same permit, because the nonce has already been consumed.

Remediation#

Do not expose a free-standing pull. Bind the permit to the caller's action, or require msg.sender == owner, and move the tokens straight into the user's deposit in the same call so they are never a bare router balance.

How to reproduce#

BASH
cd 49644-h-05-the-implementation-of-pulltokenswithpermit-poses-a-risk_exp
forge test -vv

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.