Skip to content
Smart contracts Audit finding Intermediate

Unsafe use of transfer() / transferFrom() with IERC20

The code calls transfer and transferFrom on tokens cast to IERC20 without checking return values, which can revert or silently fail for non-standard tokens like USDT. An attacker could potentially break accounting if such a token is used, though the judge notes lower likelihood on Arbitrum.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI

Note: this finding was reported via the winning Automated Findings report. It was declared out of scope for the audit, but is being included here for completeness.

Some tokens do not implement the ERC20 standard properly but are still accepted by most code that accepts ERC20 tokens. For example Tether (USDT)‘s transfer() and transferFrom() functions on L1 do not return booleans as the specification requires, and instead have no return value. When these sorts of tokens are cast to IERC20, their function signatures do not match and therefore the calls made, revert (see this link for a test case). Use OpenZeppelinundefineds SafeERC20’s safeTransfer()/safeTransferFrom() instead

There are 6 instances of this issue:

File: contracts/amo/UniV3LiquidityAmo.sol

158      IERC20WithBurn(params._tokenA).transferFrom(
159        rdpxV2Core,
160        address(this),
161        params._amount0Desired
162:     );

163      IERC20WithBurn(params._tokenB).transferFrom(
164        rdpxV2Core,
165        address(this),
166        params._amount1Desired
167:     );

283      IERC20WithBurn(_tokenA).transferFrom(
284        rdpxV2Core,
285        address(this),
286        _amountAtoB
287:     );

GitHub: 158, 163, 283

File: contracts/perp-vault/PerpetualAtlanticVaultLP.sol

128:     collateral.transferFrom(msg.sender, address(this), assets);

170:     collateral.transfer(receiver, assets);

GitHub: 128, 170

File: contracts/reLP/ReLPContract.sol

243      IERC20WithBurn(addresses.pair).transferFrom(
244        addresses.amo,
245        address(this),
246        lpToRemove
247:     );

GitHub: 243

psytama (Dopex) disputed

Alex the Entreprenerd (Judge) commented

I believe this should be Classified as Medium as a no-op here can break accounting, even though on Arbitrum this is lower likelihood.


The original report as published on Code4rena, by IllIllI. 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

Impact

A no-op transfer could break accounting, though the judge considers this lower likelihood on Arbitrum.

What the attacker needed

Non-standard ERC20 token like USDT; token used in affected contracts

The fix

Use OpenZeppelin's SafeERC20 safeTransfer and safeTransferFrom instead of direct transfer calls.

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, like USDT, don't follow the usual ERC20 rule of returning true or false when you send them. If a contract assumes they do, the transfer can fail or revert, which might mess up the contract's internal balance tracking.

What is Smart contracts?

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

More by IllIllI

View all

119 more disclosed reports, best first.

More from Dopex

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.