Skip to content
DoS Audit finding Intermediate

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

Solidity
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

Solidity
  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

https://github.com/sherlock-audit/2024-06-new-scope/blob/c8300e73f4d751796daad3dadbae4d11072b3d79/zerolend-one/contracts/core/pool/Pool.sol#L175C1-L177C4

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.

The original report as published on Sherlock, by 0xc0ffEE. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More by 0xc0ffEE

View all

27 more disclosed reports, best first.

More from ZeroLend One

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.