# `ABONDToken::transferFrom` does not work as intended and allows theft of ETH funds from `Treasury`

ABONDToken.transferFrom writes debited state to msg.sender instead of from, letting attacker duplicate userStates and over-redeem ETH from Treasury via redeemYields.

- Payout: Audit contest
- Severity: high
- Program: Autonomint
- Found by: 0xAadi
- Disclosed: 2024-11-26
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/636
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-9
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:access-control vuln:accounting-error vuln:business-logic

**Target:** ABONDToken ERC20 transferFrom / Borrowing.redeemYields / Treasury
**Root cause:** transferFrom debits fromState then assigns it to userStates[msg.sender] instead of userStates[from], so the spender inherits the from-address's ethBacked/cumulativeRate state while the from-address keeps its own.
**Steps:**
1. Account1 holds large ABOND; account2 holds small ABOND.
2. account1 calls `abond.approve(account2, 1)`.
3. account2 calls `abond.transferFrom(account1, account3, 1)` — account2's userStates now equals account1's debited state (high ethBacked, low cumulativeRate).
4. account2 calls `abond.approve(borrow, max)` then `borrow.redeemYields(account2, balanceOf(account2))`, receiving ETH computed from inflated ethBacked.
5. account1 still calls `redeemYields(account1, balanceOf(account1)-1)` and receives its normal yield — double redemption.
**How found:** Code review of transferFrom noticed userStates[msg.sender] assignment after _debit(fromState) instead of userStates[from]; traced how userStates.ethBacked/cumulativeRate feed Treasury.withdrawFromIonicByUser to compute redeem amount.
**Exploitation:** Attacker needs two ABOND-holding accounts (one large, one small). Approve spender from large account, transferFrom 1 token to a third address to copy the large account's userState onto the spender, then redeemYields on the spender using its (small) ABOND balance but the inflated ethBacked/cumulativeRate, draining extra ETH from Treasury via withdrawFromIonicByUser.
**Escalation:** Repeat across many spender accounts to multiply duplicated userStates and drain Treasury ETH at scale.
**Insight:** In ERC20-derived tokens with parallel per-user accounting structs, verify every state write targets the correct address (from vs msg.sender) — a single wrong index silently duplicates yield/backing state that downstream redeem math trusts.

## Proof of concept (copied exactly from the original report)

**Vulnerable transferFrom assigning debit to msg.sender**

```
function transferFrom(
        address from,
        address to,
        uint256 value
    ) public override returns (bool) {
        // check the input params are non zero
        require(from != address(0) && to != address(0), "Invalid User");
        
        // get the sender and receiver state
        State memory fromState = userStates[from];
        State memory toState = userStates[to];
        
        // update receiver state
        toState = Colors._credit(fromState, toState, uint128(value));
        userStates[to] = toState;
        
        // update sender state
        fromState = Colors._debit(fromState, uint128(value));
        userStates[msg.sender] = fromState;
        
        // transfer abond
        super.transferFrom(from, to, value);
        return true;
    }
```

