Reproduced Exploit

Crestal Network: public payWithERC20 spends any Blueprint allowance

payWithERC20 is public. It checks that from and to differ, that to is not zero, and that amount is positive, then safeTransferFroms amount from fromAddress to toAddress. Anyone who approved Blueprint — the normal step before paying to create an agent — can be drained by a third party. The admin has…

Mar 2025•Other•access-control•3 min read

Loss

1000 USDC pulled from a user who approved Blueprint

Chain

Other

Category

access-control

Date

Mar 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: 55092-h-1-anyone-who-is-approving-blueprintv5-contract-to-spend-er. Standalone Foundry PoC and full write-up: 55092-h-1-anyone-who-is-approving-blueprintv5-contract-to-spend-er_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/access-control/missing-auth

Key info#

FieldValue
Loss1000 USDC pulled from a user who approved Blueprint
Vulnerable contractPayment.payWithERC20
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateLocal synthetic · 2025-03
Compilersolc 0.8.27, cancun, via IR
Bug classPublic transferFrom with a caller-chosen payer

TL;DR#

payWithERC20 is public. It checks that from and to differ, that to is not zero, and that amount is positive, then safeTransferFroms amount from fromAddress to toAddress. Anyone who approved Blueprint — the normal step before paying to create an agent — can be drained by a third party. The admin has enabled USDC. The victim approved 1000 USDC. The attacker names the victim as from and receives the 1000.

The vulnerable code#

SOLIDITY
function payWithERC20(address erc20TokenAddress, uint256 amount, address fromAddress, address toAddress) public {
    require(fromAddress != toAddress, "Cannot transfer to self address");
    require(toAddress != address(0), "Invalid to address");
    require(amount > 0, "Amount must be greater than 0");
    IERC20 token = IERC20(erc20TokenAddress);
    token.safeTransferFrom(fromAddress, toAddress, amount); // @> VULN
}

The inlined pull is transferFrom(from, to, amount) inside SafeERC20. Crestal's fix makes payWithERC20 internal. A caller-bound function that always pulls msg.sender cannot name the victim, and the attacker's own empty balance reverts.

Root cause#

The payment helper was left public with an arbitrary fromAddress. The token allowance is to the Blueprint contract, so any external caller of that contract spends it.

Preconditions#

  • The admin has enabled the token with addPaymentAddress.
  • The victim has approved Blueprint for at least the amount taken (1000 USDC here).

Attack walkthrough#

  1. USDC is an enabled payment token. The victim's balance and allowance to Blueprint are both 1000.
  2. The attacker calls payWithERC20(usdc, 1000, victim, attacker).
  3. transferFrom succeeds because the allowance names Blueprint, which is msg.sender of the token call.
  4. The victim's balance is 0. The attacker holds 1000 USDC.

Diagrams#

flowchart TD A["Victim approves Blueprint for 1000 USDC"] --> B["Attacker calls public payWithERC20"] B --> C["from is the victim and to is the attacker"] C --> D["transferFrom spends the Blueprint allowance"] D --> E["Victim balance is 0 and attacker holds 1000 USDC"]

Impact#

Every user who approved Blueprint for a payment token can lose the full allowance. This run takes the 1000 USDC the victim approved. The judging report fixed it by making the function internal (crestal-omni-contracts pull 16).

How to reproduce#

BASH
cd 55092-h-1-anyone-who-is-approving-blueprintv5-contract-to-spend-er_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.