Position fees are still assessed even if the ability to decrease positions is disabled
Config keepers can disable order creation and execution, but position fees (borrowing and funding) keep accruing based on elapsed time regardless of the pause. Users who want to close positions cannot do so and may be liquidated through no fault of their own.
Source: https://github.com/sherlock-audit/2023-02-gmx-judging/issues/157
Found by
IllIllI
Summary
Position fees (borrowing and funding) are still assessed even if the ability to decrease positions is disabled
Vulnerability Detail
Config keepers have the ability to disable order placement and order execution, and them doing so does not pause the state of position fees.
Impact
Users will be assessed position fees even if they wished to close their positions, and can be liquidated through no fault of their own.
Code Snippet
Order creation (to close a position) may be disabled:
// File: gmx-synthetics/contracts/exchange/OrderHandler.sol : OrderHandler.createOrder() #1
43: FeatureUtils.validateFeature(dataStore, Keys.createOrderFeatureDisabledKey(address(this), uint256(params.orderType)));
As may execution of orders prior to the disabling of creation:
// File: gmx-synthetics/contracts/exchange/OrderHandler.sol : OrderHandler._executeOrder() #2
207: FeatureUtils.validateFeature(params.contracts.dataStore, Keys.executeOrderFeatureDisabledKey(address(this), uint256(params.order.orderType())));
But position fees are tracked based on time and do not account for pauses:
// File: gmx-synthetics/contracts/market/MarketUtils.sol : MarketUtils.updatedAt #3
1759 function getSecondsSinceCumulativeBorrowingFactorUpdated(DataStore dataStore, address market, bool isLong) internal view returns (uint256) {
1760 uint256 updatedAt = getCumulativeBorrowingFactorUpdatedAt(dataStore, market, isLong);
1761 if (updatedAt == 0) { return 0; }
1762 @> return block.timestamp - updatedAt;
1763: }
// File: gmx-synthetics/contracts/market/MarketUtils.sol : MarketUtils.getSecondsSinceFundingUpdated() #4
1658 function getSecondsSinceFundingUpdated(DataStore dataStore, address market) internal view returns (uint256) {
1659 uint256 updatedAt = dataStore.getUint(Keys.fundingUpdatedAtKey(market));
1660 if (updatedAt == 0) { return 0; }
1661 @> return block.timestamp - updatedAt;
1662: }
Tool used
Manual Review
Recommendation
Track and account for disabling, and adjust position fees based on whether things were paused or not.
Discussion
xvi10
this is a valid concern, but we do not think this logic should be added
orders should only be disabled if there is an emergency issue, we do not think the additional complexity is worth adding for this case
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 fee accrual is computed purely from elapsed block time and does not check whether order creation or execution has been disabled.
Impact
Users are charged position fees while unable to close, and could be liquidated through no fault of their own; the project acknowledged the concern but declined to add pause-aware fee logic.
What the attacker needed
Config keeper disables order creation/execution; user has an open position
The fix
The project decided not to fix it, arguing orders should only be disabled in emergencies and the added complexity is not worth it; the reporter suggested tracking pauses and adjusting fees accordingly.
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 trading platform charges ongoing fees for as long as a position stays open. Administrators can switch off the ability to place or execute orders, for example during an emergency. The problem is that the fee clock keeps running during that switch-off, so a trader who cannot close their position still pays fees and could be liquidated.
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.