---
title: "Unchecked return values and non-standard tokens"
url: https://dontgetrekt.today/dev/unchecked-call
section: "What does it trust?"
owasp: SC06:2026
---

# Unchecked return values and non-standard tokens

The contract ignores a failed transfer, or assumes every ERC-20 behaves the same. A token that returns false, takes a fee or rebases breaks the accounting.

## How the attack works

1. The contract calls `token.transfer()` or a low-level `call` and does not check the result.
2. Some tokens return `false` on failure instead of a revert, and some (USDT) return nothing.
3. The transfer fails, but the contract records it as done. The attacker gets credit for a deposit that never arrived.
4. Variants: fee-on-transfer tokens deliver less than the amount, rebasing tokens change balances, ERC-777 hooks call back.

## Vulnerable code

```solidity
function deposit(uint256 amt) external {
    token.transferFrom(msg.sender, address(this), amt); // result ignored
    balance[msg.sender] += amt;                          // credited anyway
}

function pay(address to, uint256 amt) external onlyOwner {
    to.call{value: amt}("");                             // failure ignored
}
```

## Fixed code

```solidity
using SafeERC20 for IERC20;

function deposit(uint256 amt) external {
    uint256 before = token.balanceOf(address(this));
    token.safeTransferFrom(msg.sender, address(this), amt);  // reverts on false
    balance[msg.sender] += token.balanceOf(address(this)) - before;
}

function pay(address to, uint256 amt) external onlyOwner {
    (bool ok,) = to.call{value: amt}("");
    require(ok, "ETH transfer failed");
}
```

## Review checklist

- Use OpenZeppelin `SafeERC20` for every token call.
- Check the `bool` of every low-level `call`, `send` and `delegatecall`.
- Write down which tokens you support. If you accept any token, test fee-on-transfer, rebasing, no-return and 6-decimal tokens.
- Credit the measured balance change, not the amount in the call.

## How to test for it

- Use the Weird ERC20 mocks (github.com/d-xo/weird-erc20) in your test suite.
- Slither detectors `unchecked-transfer`, `unchecked-lowlevel` and `unchecked-send`.

## Real exploits (4)

- 2020-06-28 Balancer ($500K): Balancer pool lost about $500K (figure from general knowledge, not this write-up) because it did not handle the deflationary STA token, which burns a fee on every transfer, so its recorded balances were wrong. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2020-06/Balancer_20200628_exp.sol)
- 2021-06-28 SafeDollar ($248K): SafeDollar on Polygon lost about $248k when a fee-on-transfer token (PLX) broke its farm reward accounting, inflating accSdoPerShare and allowing an infinite SDO mint. [rekt.news](https://rekt.news/safedollar-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2021-06/SafeDollar_exp.sol)
- 2021-04-04 Force DAO: Force DAO's xFORCE vault let a white hat mint 347M xFORCE for free because it ignored the false return of transferFrom on the MiniMeToken-based FORCE token; the FORCE price fell about 90% and the funds were later returned. [rekt.news](https://rekt.news/force-rekt)
- 2021-09-12 ZABU Finance: ZABU Finance's farm on Avalanche was drained of ZABU rewards because it did not handle the deflationary SPORE token, which burns a fee on each transfer. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2021-09/ZABU_exp.sol)

## References

- [OWASP SC06:2026](https://scs.owasp.org/sctop10/SC06-UncheckedExternalCalls/)
- [SWC-104: Unchecked call return value](https://swcregistry.io/docs/SWC-104/)
- [Weird ERC20 tokens](https://github.com/d-xo/weird-erc20)
- [OpenZeppelin: SafeERC20](https://docs.openzeppelin.com/contracts/5.x/api/token/erc20#SafeERC20)
