NestedFactory: Ensure zero msg.value if transferring from user and inputToken is not ETH
A user who calls create() or addToken() with an ERC20 token as input but also sends native ETH will have that ETH permanently locked in the contract. The contract does not check that msg.value is zero when the input token is not ETH.
Submitted by GreyArt
Impact
A user that mistakenly calls either create() or addToken() with WETH (or another ERC20) as the input token, but includes native ETH with the function call will have his native ETH permanently locked in the contract.
Recommended Mitigation Steps
It is best to ensure that msg.value = 0 in _transferInputTokens() for the scenario mentioned above.
} else if (address(_inputToken) == ETH) {
...
} else {
require(msg.value == 0, "NestedFactory::_transferInputTokens: ETH sent for non-ETH transfer");
_inputToken.safeTransferFrom(_msgSender(), address(this), _inputTokenAmount);
}
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 function _transferInputTokens() does not verify that msg.value is zero when the input token is not ETH, so any native ETH sent alongside an ERC20 transfer remains in the contract.
Impact
Native ETH sent by mistake with an ERC20 input token is permanently locked in the contract, with no recovery path described.
What the attacker needed
User calls create() or addToken(); input token is an ERC20 (e.g. WETH); user also sends native ETH
The fix
The function _transferInputTokens() should require msg.value to be zero when the input token is not ETH, as shown in the recommended mitigation.
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.
When you call a function that accepts a token, you might accidentally also send some of the network's native currency (like ETH) along with it. The contract only expects native currency when the token is ETH itself, so any extra native currency sent with a different token gets stuck in the contract with no way to get it back. This report suggests adding a check to reject such calls.
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.