Passing multiple ETH deposits in orders array will use the same msg.value many times
The contract's deposit logic reuses the same msg.value across multiple orders in a batch, allowing a user to account for more ETH than actually deposited. An attacker could potentially drain the contract's ETH holdings by depositing once and withdrawing multiple times.
Submitted by hyh, also found by jayjonah8
Impact
Contract holdings can be emptied as malicious user will do deposit/withdraw to extract value. This is possible because after transferInputTokens system uses contract balance for user’s operations, assuming that equivalent value was transferred.
Proof of Concept
msg.value persist over calls, so passing 'Order[] calldata _orders' holding multiple ETH deposits will use the same msg.value in each of them, resulting in multiple deposits, that sums up to much bigger accounted value than actually deposited value, up to contract’s ETH holdings.
create / addTokens -> submitInOrders -> transferInputTokens
sellTokensToWallet -> submitOutOrders -> transferInputTokens
sellTokensToNft -> submitOutOrders -> transferInputTokens
NestedFactory.solL152transferInputTokensuses msg.value:
Recommended Mitigation Steps
Controlling ETH to be only once in orders will not help, as NestedFactory inherits from Multicall, whichmulticall(bytes\[] calldata data) function allows same reusage of msg.value, which will persist over calls.
So, it is recommended to treat ETH exclusively, not allowing ETH operations to be batched at all.
adrien-supizet (Nested) disagreed with severity:
Multicall is not currently used, and the funds exposed would be the NestedFactory’s which should hold no funds.
To avoid future bugs, we’re going to remove the multicall library, but we don’t think this is a high severity issue.
Downgrading severity to 2 because the NestedFactory is not expected to hold funds, and therefore there is no risk of a loss. You can’t deposit the same Ether twice in the WETH contract.
Also keeping this as the main over #13.
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 contract does not track how much ETH has already been accounted for within a single transaction, so each order in a batch sees the full msg.value.
Impact
The contract's ETH holdings could be emptied, but the team says the factory should hold no funds and the judge downgraded severity because there is no risk of loss.
What the attacker needed
Contract holds ETH; ability to submit batched orders
The fix
The team planned to remove the multicall library and treat ETH exclusively so that ETH operations cannot be batched.
How it was found
- Create or add tokens to a portfolio.
- Submit multiple orders that each include an ETH deposit.
- The contract processes each order using the same msg.value.
- The total accounted deposit exceeds the actual ETH sent.
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 send cryptocurrency to a smart contract, the amount is attached to the transaction. If the contract processes several actions in one transaction, it might mistakenly count that same amount for each action. This report says that could let someone pretend to have deposited more than they did and then withdraw the extra.
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.