Can deposit native token for free and steal funds
The depositErc20 function allowed the native token address to be used as an ERC20 token, and because the native token address is an externally owned account, the safeTransferFrom call succeeded without transferring any funds. An attacker could deposit infinite native tokens for free and receive real native funds on the destination chain.
Submitted by cmichel, also found by CertoraInc
The depositErc20 function allows setting tokenAddress = NATIVE and does not throw an error.
No matter the amount chosen, the SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(tokenAddress), sender, address(this), amount); call will not revert because it performs a low-level call to NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, which is an EOA, and the low-level calls to EOAs always succeed.
Because the safe* version is used, the EOA not returning any data does not revert either.
This allows an attacker to deposit infinite native tokens by not paying anything.
The contract will emit the same Deposit event as a real depositNative call and the attacker receives the native funds on the other chain.
Recommended Mitigation Steps
Check tokenAddress != NATIVE in depositErc20.
ankurdubey521 (Biconomy) confirmed and commented:
HP-25: C4 Audit Fixes, Dynamic Fee Changes bcnmy/hyphen-contract#42
Great find, definitely deserves a severity of high.
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 depositErc20 function did not reject the native token address, and the safeTransferFrom call to that address (an EOA) always succeeds without transferring funds.
What the attacker needed
None
The fix
The depositErc20 function should check that tokenAddress is not the native token address.
How it was found
- Call depositErc20 with tokenAddress set to the native token address and any amount.
- The safeTransferFrom call to the native token address succeeds without transferring funds.
- The contract emits a Deposit event as if a real deposit occurred.
- The attacker receives native funds on the other chain.
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 smart contract let people deposit a special 'native token' address as if it were a regular token. But that address is just a normal account, so the transfer check always passed without moving any money. The attacker could pretend to deposit tokens and get real funds on another chain.
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.