Skip to content
Business logic Audit finding Intermediate

Contracts are vulnerable to fee-on-transfer accounting-related issues

The smart contracts use transferFrom to move tokens but do not verify that the received amount matches the transferred amount, which can cause balance inconsistencies with fee-on-transfer tokens. An attacker could exploit leftover funds to gain unjustified credit.

ChaseTheLight Follow

Originally disclosed on Code4rena

Submitted by ChaseTheLight

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.

There are 4 instances of this issue.

Resolution

The below-listed functions use transferFrom() to move funds from the sender to the recipient but fail to verify if the received token amount matches the transferred amount. This could pose an issue with fee-on-transfer tokens, where the post-transfer balance might be less than anticipated, leading to balance inconsistencies. There might be subsequent checks for a second transfer, but an attacker might exploit leftover funds (such as those accidentally sent by another user) to gain unjustified credit. A practical solution is to gauge the balance prior and post-transfer, and consider the differential as the transferred amount, instead of the predefined amount.

Findings are labeled with <= FOUND.

https://github.com/code-423n4/2023-07-axelar/tree/main/contracts/cgp/AxelarGateway.sol#L542-L546

529:     function _burnTokenFrom(
530:         address sender,
531:         string memory symbol,
532:         uint256 amount
533:     ) internal {
534:         address tokenAddress = tokenAddresses(symbol);
535:
536:         if (tokenAddress == address(0)) revert TokenDoesNotExist(symbol);
537:         if (amount == 0) revert InvalidAmount();
538:
539:         TokenType tokenType = _getTokenType(symbol);
540:
541:         if (tokenType == TokenType.External) {
542:             IERC20(tokenAddress).safeTransferFrom(sender, address(this), amount); // <= FOUND
543:         } else if (tokenType == TokenType.InternalBurnableFrom) {
544:             IERC20(tokenAddress).safeCall(abi.encodeWithSelector(IBurnableMintableCappedERC20.burnFrom.selector, sender, amount));
545:         } else {
546:             IERC20(tokenAddress).safeTransferFrom(sender, IBurnableMintableCappedERC20(tokenAddress).depositAddress(bytes32(0)), amount); // <= FOUND
547:             IBurnableMintableCappedERC20(tokenAddress).burn(bytes32(0));
548:         }
549:     }

https://github.com/code-423n4/2023-07-axelar/tree/main/contracts/its/interchain-token-service/InterchainTokenService.sol#L451-L451

439:     function expressReceiveToken(
440:         bytes32 tokenId,
441:         address destinationAddress,
442:         uint256 amount,
443:         bytes32 commandId
444:     ) external {
445:         if (gateway.isCommandExecuted(commandId)) revert AlreadyExecuted(commandId);
446:
447:         address caller = msg.sender;
448:         ITokenManager tokenManager = ITokenManager(getValidTokenManagerAddress(tokenId));
449:         IERC20 token = IERC20(tokenManager.tokenAddress());
450:
451:         SafeTokenTransferFrom.safeTransferFrom(token, caller, destinationAddress, amount); // <= FOUND
452:
453:         _setExpressReceiveToken(tokenId, destinationAddress, amount, commandId, caller);
454:     }

https://github.com/code-423n4/2023-07-axelar/tree/main/contracts/its/interchain-token-service/InterchainTokenService.sol#L482-L482

467:     function expressReceiveTokenWithData(
468:         bytes32 tokenId,
469:         string memory sourceChain,
470:         bytes memory sourceAddress,
471:         address destinationAddress,
472:         uint256 amount,
473:         bytes calldata data,
474:         bytes32 commandId
475:     ) external {
476:         if (gateway.isCommandExecuted(commandId)) revert AlreadyExecuted(commandId);
477:
478:         address caller = msg.sender;
479:         ITokenManager tokenManager = ITokenManager(getValidTokenManagerAddress(tokenId));
480:         IERC20 token = IERC20(tokenManager.tokenAddress());
481:
482:         SafeTokenTransferFrom.safeTransferFrom(token, caller, destinationAddress, amount); // <= FOUND
483:
484:         _expressExecuteWithInterchainTokenToken(tokenId, destinationAddress, sourceChain, sourceAddress, data, amount);
485:
486:         _setExpressReceiveTokenWithData(tokenId, sourceChain, sourceAddress, destinationAddress, amount, data, commandId, caller);
487:     }

deanamiel (Axelar) commented:

Invalid, we have a dedicated token manager for fee-on-transfer tokens that takes this into account. Here is TokenManagerLockUnlockFee for reference.

berndartmueller (judge) commented:

Agree with the sponsor that there is a special token manager for such fee-on-transfer tokens. However, the identified instances in the report are still affected by the issue. Consequently, I consider Medium severity to be appropriate.


The original report as published on Code4rena, by ChaseTheLight. 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 assume that the amount specified in transferFrom is exactly the amount received, without checking the actual balance change.

Impact

An attacker could exploit leftover funds to gain unjustified credit, though the sponsor notes a dedicated token manager exists for fee-on-transfer tokens; the judge still considers the identified instances affected and rates it Medium.

What the attacker needed

Fee-on-transfer token; leftover funds in contract

The fix

The contracts should measure the balance before and after the transfer and use the difference as the transferred amount, rather than the predefined amount.

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 take a small fee when transferred, so the receiver gets less than the sender sent. If a contract assumes it received the full amount, its internal accounting can be wrong. An attacker might then use extra tokens that were accidentally sent to the contract to get credit they should not have.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by ChaseTheLight

View all

8 more disclosed reports, best first.

More from Axelar Network

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.