S2S Transfer from the origin schain to another schain with automatic deploy disabled can cause funds to be frozen
When a user transfers a token native to the origin schain to another schain, the origin contract locks the tokens and sends a message. If the target schain has automatic deploy disabled and no clone exists, the inbound message fails, leaving the tokens frozen in the origin contract.
Submitted by WatchPug
When moving tokens that are native on the origin schain, to another schain, TokenManagerERC20.sol#transferToSchainERC20() will be called, which calls _exit() -> _receiveERC20():
if (isMainChainToken) {
data = _receiveERC20(
chainHash,
address(contractOnSchain),
msg.sender,
amount
);
_saveTransferredAmount(chainHash, address(contractOnSchain), amount);
require(
contractOnSchain.transferFrom(msg.sender, address(this), amount),
"Transfer was failed"
);
}
bool isERC20AddedToSchain = _schainToERC20[chainHash].contains(erc20OnMainChain);
if (!isERC20AddedToSchain) {
_addERC20ForSchain(chainHash, erc20OnMainChain);
data = Messages.encodeTransferErc20AndTokenInfoMessage(
erc20OnMainChain,
to,
amount,
_getErc20TotalSupply(erc20),
_getErc20TokenInfo(erc20)
);
}
However, on the target schain, while handling the inbound message with postMessage() -> _sendERC20(), when contractOnSchain is false, The transaction will fail with "Automatic deploy is disabled" when automaticDeploy == false:
contractOnSchain = clonesErc20[fromChainHash][token];
if (address(contractOnSchain) == address(0)) {
require(automaticDeploy, "Automatic deploy is disabled");
contractOnSchain = new ERC20OnChain(message.tokenInfo.name, message.tokenInfo.symbol);
clonesErc20[fromChainHash][token] = contractOnSchain;
addedClones[contractOnSchain] = true;
emit ERC20TokenCreated(fromChainHash, token, address(contractOnSchain));
}
As a result, any tokens that are locked in the origin schain by the user will be frozen in the contract.
Recommendation
Consider adding a mapping storage to cache whether automaticDeploy is enabled on a certain schain, the cache should be updated once the automaticDeploy is updated.
And only allows S2S transfer when automaticDeploy is enabled on the target schain.
To further avoid the edge case of: right after the user submitted the S2S transfer tx on the from schain, the target schain disabled automaticDeploy and the user’s tokens can be frozen in the from schain. We can introduce a 24 hrs timelock for disabling automaticDeploy.
cstrangedk (SKALE) disputed and commented:
Issue raised is acknowledged and work is assigned on the roadmap. SKALE Chain owners must ensure any mapped assets, either through manual or automatic mapping are compatible with their dApp(s). Manual mapping mode is the default mode for bridge operation.
GalloDaSballo (judge) decreased severity to Medium and commented:
I agree with both sides of the argument, and because this is contingent on configuration and admin privilege, believe Medium Severity to be more appropriate
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
The origin schain does not check whether automatic deploy is enabled on the target schain before locking the user's tokens and sending the transfer message.
Impact
Tokens transferred from the origin schain to a target schain with automatic deploy disabled become frozen in the origin contract; the judge rated this Medium because it depends on configuration and admin privilege.
What the attacker needed
Target schain has automaticDeploy disabled; no clone of the token exists on target schain; user initiates an S2S transfer
The fix
The report recommends caching the target schain's automaticDeploy setting and only allowing S2S transfers when it is enabled, plus a 24-hour timelock before disabling it; the project acknowledged the issue and assigned work on the roadmap.
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 lets you move tokens between two blockchains. Here, the first chain takes your tokens and promises to release them on the second chain, but if the second chain is set up to refuse creating a placeholder token automatically, the promise fails and your tokens stay stuck in the first chain's contract.
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.