# Anyone who is approving `BlueprintV5` contract to spend ERC20 can get drained because `Payment::payWithERC20`

Public payWithERC20 in Payment.sol lets anyone pull tokens from any address that approved BlueprintV5, draining victim allowances to attacker.

- Payout: Audit contest
- Severity: high
- Program: Crestal Network
- Found by: 0x180db
- Disclosed: 2025-03-10
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-03-crestal-network-judging/issues/260
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-03-crestal-network%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** Payment.sol payWithERC20 on BlueprintV5 proxy
**Root cause:** payWithERC20 is declared public with caller-supplied fromAddress/toAddress, so any caller can move tokens from any address that granted allowance to the BlueprintV5 contract.
**Steps:**
1. Admin enables a payment token via Blueprint::addPaymentAddress
2. Victim approves BlueprintV5 proxy to spend the ERC20 (allowance > agent cost)
3. Attacker calls `payWithERC20(usdc, victimBalance, victim, attacker)`
4. safeTransferFrom pulls victim tokens to attacker
**How found:** Code reading: noticed payWithERC20 lacked access control and accepted arbitrary fromAddress, combined with the fact that users must approve the BlueprintV5 contract to pay for agent creation.
**Exploitation:** Attacker needs no capital or role; just calls the public function with the victim's address as fromAddress and their own address as toAddress, extracting the full remaining allowance.
**Insight:** When a contract is the spender in user approvals, audit every function that calls transferFrom for missing access control and caller-controlled fromAddress — approval to a contract is an implicit trust boundary.

