Skip to content
Smart contracts Audit finding Intermediate

Token transfers do not verify that the tokens were successfully transferred

The smart contracts call ERC20 transfer and transferFrom without checking the boolean return value, so tokens that signal failure by returning false instead of reverting are treated as a successful payment. An attacker using such a token could buy sale tokens or NFTs without spending anything, and a user claiming vested tokens could lose them.

prePO contest

Originally disclosed on Code4rena

Some tokens (like zrx) do not revert the transaction when the transfer/transferfrom fails and return false, which requires us to check the return value after calling the transfer/transferfrom function.

In the purchase functions of MiniSales and TokenShop contracts, if _paymentToken is such a token, the user can purchase _saleToken and NFT without spending any tokens.

In the claim function of the Vesting contract, if _token is such a token, the user may lose his vested tokens.

Proof of Concept

https://github.com/prepo-io/prepo-monorepo/blob/9ed5587e557a1189df6c5bb0229ad8c171eaabce/apps/smart-contracts/token/contracts/mini-sales/MiniSales.sol#L25-L26

https://github.com/prepo-io/prepo-monorepo/blob/9ed5587e557a1189df6c5bb0229ad8c171eaabce/apps/smart-contracts/token/contracts/token-shop/TokenShop.sol#L41-L42

https://github.com/prepo-io/prepo-monorepo/blob/9ed5587e557a1189df6c5bb0229ad8c171eaabce/apps/smart-contracts/token/contracts/vesting/Vesting.sol#L66-L67

Recommended Mitigation Steps

Use SafeERC20’s safeTransfer/safeTransferFrom functions

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol

cccz (warden) commented:

Only security-compliant tokens such as USDC and PPO are currently planned to be used in the contracts.

The original report as published on Code4rena. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contracts call the token's transfer and transferFrom functions directly and never inspect the returned boolean, assuming every token reverts on failure.

Impact

With a non-reverting token, a user could obtain sale tokens and NFTs for free, and a user claiming vested tokens could lose them; the warden notes only security-compliant tokens such as USDC and PPO are currently planned for use, which limits the risk in practice.

What the attacker needed

Payment token returns false instead of reverting; contract accepts such a token as payment

The fix

The contracts should use SafeERC20's safeTransfer and safeTransferFrom, which check the return value and revert on failure.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some tokens report a failed transfer by quietly returning 'false' rather than stopping with an error. The contracts ignored that answer and carried on as if the payment had worked, so someone could receive goods without paying. The fix is to use a helper that checks the answer and stops the transaction when it is false.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from prePO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.