Lack of slippage protection in GMX order execution
The system currently executes orders without proper safeguards against slippage, which could lead to unfavorable execution prices and significant financial losses for users.
The function _createIncreasePosition in the provided code has an issue related to slippage protection.
The minOutputAmount parameter is hardcoded to 0, allowing the order to execute at any price, even if it's significantly worse than expected.
There is no mechanism to limit the maximum acceptable price slippage, which could result in orders executing at unfavorable rates.
To demonstrate the issue, consider this test scenario:
This test shows how the lack of slippage protection could result in large losses for users if prices move unfavorably before execution.
Users are at risk of incurring unexpected and substantial losses due to poor execution prices.
The protocol is vulnerable to market manipulation, as attackers could exploit this weakness to force unfavorable order executions.
Repeated instances of bad execution prices could harm user trust and the overall reputation of the protocol.
manual review
Foundry testing framework
To mitigate this issue, implement the following changes:
Introduce a slippage protection system that adjusts based on market conditions.
Calculate minOutputAmount dynamically using the expected execution price and a reasonable slippage threshold (e.g., 1%-3%).
Allow users to set their own acceptable slippage limits when creating orders.
By addressing this vulnerability, the protocol can provide better protection for users and reduce the risk of significant financial losses.
acceptablePrice does that job for increase/decrease positions. https://github.com/gmx-io/gmx-synthetics/blob/caf3dd8b51ad9ad27b0a399f668e3016fd2c14df/contracts/order/BaseOrderUtils.sol#L276C49-L276C66
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.