The vulnerability emerges when the MarginRouter.crossSwapExactTokensForTokens function is invoked with a counterfeit pair where token[0] is equivalent to token[1]. In the scenario where the function is called as crossSwapExactTokensForTokens(1000 WETH, 0, [ATTACKER_CONTRACT], [WETH, WETH]), the function attempts to compute amounts via UniswapStyleLib.getAmountsOut(amountIn - fees, pairs, tokens); However, this process is manipulated as the attacker's contract returns falsified reserves, yielding zero output.
Code Snippet:
In the _swapExactT4T function, funds are withdrawn and sent to the attacker's contract:
The exact ramifications of this vulnerability are yet to be fully grasped. The registerTrade function may still falter during the process of subtracting inAmount and adding a zero outAmount. This vulnerability closely resembles a withdrawal attack that typically would be restricted by a coolingOffPeriodβa security measure this attack ingeniously sidesteps.