Position Risk Management Functionality Missing in Position Manager and dos in certain conditions
The PositionManager contract used by protocol users does not expose the function that lets a user mark a reserve as collateral or not, so users cannot manage the risk of their positions. If an admin later sets the loan-to-value of one collateral reserve to zero, withdrawals of other reserves through the PositionManager revert, denying users the ability to reduce their exposure.
0xc0ffEE Follow with A2-security, almurhasan and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-06-new-scope-judging/issues/398
Found by
0xc0ffEE, A2-security, almurhasan, tallo
Summary
Protocol users who manage their positions through the PositionManager are not able to manage risk of their positions, by setting collateral to on and off. Which is a core functionality of every lending protocol. The missing functionality will doss users from withdrawing also in certain conditions.
Vulnerability Detail
For each collateral resrve the pool tracks whethere the user is using as collateral or not, this is set in the userConfigMap. Any user could set which reserve he is setting as collateral by calling the
function setUserUseReserveAsCollateral(address asset, uint256 index, bool useAsCollateral) external {
_setUserUseReserveAsCollateral(asset, index, useAsCollateral);
}
The PositionManager.sol which the protocol users, are expected to interact with, doesn't implement the setUserUseReserveAsCollateral(), which first of all leads to the inablity of protocol users to manage risk on their Positions. The second impact and the most severe is that Position holders will be dossed, in the protocols if the ltv of one of the reserve token being used, will be set to zero. In such an event, users are required to set the affected collateral to false in order to do operations that lowers the ltv like withdraw to function.
The doss will be done in the function validateHFandLtv() which will be called to check the health of a position is maintend after a withdrawal
function validateHFAndLtv(
mapping(address => mapping(bytes32 => DataTypes.PositionBalance)) storage _balances,
mapping(address => DataTypes.ReserveData) storage reservesData,
mapping(uint256 => address) storage reservesList,
DataTypes.UserConfigurationMap memory userConfig,
DataTypes.ExecuteWithdrawParams memory params
) internal view {
DataTypes.ReserveData memory reserve = reservesData[params.asset];
(, bool hasZeroLtvCollateral) = validateHealthFactor(_balances, reservesData, reservesList, userConfig, params.position, params.pool);
@>> require(!hasZeroLtvCollateral || reserve.configuration.getLtv() == 0, PoolErrorsLib.LTV_VALIDATION_FAILED);
}
In this case, if the user wants to withdraw other reserves that don't have 0 tlv, the transaction will revert.
Impact
- missing core functions, that NFTPositionManager users are not able to use
- NFTPositionManager are unable to manage to risk at all
- Withdrawal operations in NFTPositionManager will be dossed in certain conditions
Code Snippet
Tool used
Manual Review
Recommendation
Implement the missing functionality in the NFTPositionManager.sol, to allow users to manage the risk on their NFTPosition
Discussion
0xjuaan
@nevillehuang The main impact here is that if an admin sets the ltv of a collateral to zero, then users withdrawals from the NFTPositionManager will be DoS'd. If this is valid, shouldn't #166 be valid? Since 166 was invalidated since it required admins to perform actions that lead to issues.
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 PositionManager wrapper contract omits the setUserUseReserveAsCollateral entry point that the underlying pool provides, leaving users unable to clear a zero-LTV collateral flag that the health check requires them to clear.
Impact
Users of the PositionManager cannot manage position risk at all, and withdrawals of unaffected reserves will be denied in certain conditions, such as when an admin sets a collateral's LTV to zero.
What the attacker needed
User holds a position via PositionManager; admin sets a collateral's LTV to zero
The fix
The missing collateral-toggle functionality should be implemented in the PositionManager so users can manage the risk on their positions.
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 lending protocol lets you deposit several kinds of tokens and choose which ones count as security for your loan. If one of those tokens stops counting, you normally switch it off so you can still take other tokens out. Here the contract users interact with has no button for that switch, so in that situation their withdrawal is simply rejected.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.