Skip to content
DoS Audit finding Intermediate

Liquidation reverts when repaying the final remaining debt due to HF being set to type(uint256).max and compared against hfLimitForLiquidation

The health factor helper returns the maximum unsigned integer when debt is zero, and the liquidation function reverts if the post-liquidation health factor exceeds a finite limit. A liquidator repaying the final remaining debt therefore always triggers a revert, making full liquidation impossible and leaving some unhealthy positions unliquidatable.

Audinarey Follow with LeoGold, Pelz and 6 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2026-01-fluid-dex-v2-judging/issues/1183

Found by

Audinarey, LeoGold, Pelz, Silvermist, fuzious, iamephraim, maigadoh, p1ramide, xiaoming90

Summary

Defining the health factor as type(uint256).max when debtValue == 0 will cause a liquidation denial-of-service and prevent full debt clearance for the protocol and its liquidity providers as a liquidator will repay the last remaining debt (making debtValue == 0) and the liquidation will always revert on the post-liquidation hf > hfLimitForLiquidation check.

Root Cause

  • In contracts/contracts/protocols/moneyMarket/core/other/helpers.sol:1051-1055 the _getHfInfo() helper sets hfInfo_.hf = type(uint256).max whenever hfInfo_.debtValue == 0.
  • In contracts/contracts/protocols/moneyMarket/core/liquidateModule/main.sol:622-627 the liquidate() flow unconditionally reverts if _getHfInfo(...).hf > hfLimitForLiquidation.

Internal Pre-conditions

External Pre-conditions

Attack Path

FluidMoneyMarketLiquidateModule.liquidate() performs a liquidation (pay back debt + seize collateral), and then enforces a post-condition that the resulting health factor (HF) must not exceed the configured hfLimitForLiquidation:

  • liquidate() loads hfLimit_ from _moneyMarketVariables and checks:
    • if (_getHfInfo(params_.nftId, IS_LIQUIDATE).hf > hfLimit_) revert ...HfLimitExceeded; (liquidateModule/main.sol:622-627).

Separately, HF is computed in _getHfInfo() as:

  • If debtValue == 0, set hf = type(uint256).max.
  • Else, set hf = normalizedCollateralValue * 1e18 / debtValue.
    • (other/helpers.sol:1051-1055)

This combination creates a hard failure mode:

  • Any liquidation that repays the final remaining debt (so total debtValue becomes 0) will make _getHfInfo() return hf = type(uint256).max.
  • Since hfLimitForLiquidation is a finite value, type(uint256).max > hfLimitForLiquidation will always be true.
  • Therefore, the liquidation always reverts at the end, undoing the debt repayment and collateral transfer.

This is not limited to a specific position type: it applies whenever the liquidation action results in zero total debt for the NFT (i.e., the last remaining debt position is fully repaid), regardless of whether the payback/withdraw positions are NORMAL or D3/D4.

Practical consequences (all stemming from the same root cause):

  1. Full liquidations are impossible Even if a liquidatable account has sufficient collateral to cover all debt (including liquidation penalty), liquidators cannot fully repay the account’s last remaining debt. The transaction will always revert at the final HF limit check.
  2. Some unhealthy positions can become practically unliquidatable Liquidations enforce a minimum payback value (v_.paybackValue >= 1e16, i.e., $0.01) (liquidateModule/main.sol:235-236). For positions whose remaining debt is small enough that any valid liquidation necessarily clears all remaining debt (e.g., because paying less violates the minimum payback value or because any non-max payback amount would exceed the remaining borrow and revert in storage updates), liquidation becomes impossible: the only viable liquidation attempt is “repay all”, and “repay all” always reverts due to hf = type(uint256).max.
  3. Residual debt must be repaid by the borrower, not enforceable by liquidators Liquidation is the mechanism meant to handle uncooperative borrowers. This bug forces liquidators to leave a non-zero remainder (or revert), meaning the protocol cannot rely on liquidation to fully settle positions even when it should be able to.
  4. Increased exposure to future insolvency and bad debt When a position could have been fully closed via liquidation but cannot be, the protocol stays exposed to ongoing interest accrual and collateral price movement on the remaining debt. A position that would have been fully resolved can later become undercollateralized, turning the remaining debt into bad debt that impacts liquidity providers.

https://github.com/sherlock-audit/2026-01-fluid-dex-v2/blob/main/fluid-contracts/contracts/protocols/moneyMarket/core/operateModule/main.sol#L1

Attack Path

Attack path 1: Any liquidation that clears all remaining debt reverts at the end

  1. A liquidator calls liquidate() on an NFT that is liquidatable (hf < 1e18 at function entry) and targets the last remaining debt position as paybackPositionIndex.
  2. The liquidator specifies “repay all” for that debt position (e.g., using type(uint256).max where supported), so the payback deletes the final debt amount from storage.
  3. After payback and collateral withdrawal steps, the NFT now has debtValue == 0.
  4. liquidate() evaluates the post-liquidation constraint:
    • _getHfInfo(...).hf returns type(uint256).max because debtValue == 0 (helpers.sol:1051-1055).
    • type(uint256).max exceeds any finite hfLimitForLiquidation, so liquidate() reverts with LiquidateModule__HfLimitExceeded (liquidateModule/main.sol:622-627).
  5. The entire liquidation (including repayment and collateral transfer) is reverted.

Attack path 2: “Only-full-payback” unhealthy positions become unliquidatable (liquidation DoS)

  1. A borrower ends up with an unhealthy NFT (HF < 1) whose remaining debt is concentrated in a single final debt position and is small enough that partial liquidation is constrained (e.g., by the minimum liquidation payback value check v_.paybackValue >= 1e16 in liquidateModule/main.sol:235-236, and/or by “payback exceeds borrow” checks during payback storage updates).
  2. Liquidators cannot choose a valid partial payback that both passes validation and leaves debtValue > 0, so the only viable attempt is to repay the full remaining debt.
  3. Repaying the full remaining debt makes debtValue == 0, which makes HF become type(uint256).max.
  4. The liquidation reverts on the post-liquidation HF limit check, making the position practically unliquidatable by third parties.

Attack path 3: Forced residual debt keeps risk alive and can later crystallize into losses

  1. Liquidators can partially liquidate a position but cannot clear the final remaining debt due to attack path 1 (full clearance always reverts).
  2. If the borrower does not (or cannot) voluntarily repay the residual debt, the protocol is forced to carry that open debt indefinitely.
  3. Over time, the residual debt accrues interest and remains exposed to collateral price changes, which can turn previously coverable debt into undercollateralized bad debt that the protocol could have avoided by allowing a final “closeout” liquidation.

Impact

The protocol and its liquidity providers cannot fully liquidate and close liquidatable positions, because any liquidation that would repay the last remaining debt always reverts. In the worst case, this creates permanently unresolvable unhealthy positions (liquidation DoS) and/or leaves outstanding debt that cannot be forcibly repaid by liquidators, causing the protocol to accumulate bad debt and exposing liquidity providers to losses up to the full remaining debt value on affected positions, while also breaking liquidation as a core safety mechanism.

PoC

No response

Mitigation

No response

The original report as published on Sherlock, by Audinarey. 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

The health factor helper returns the maximum unsigned integer when debt is zero, and the liquidation flow unconditionally reverts when that value exceeds the finite liquidation health factor limit.

Impact

Liquidators cannot fully repay the last remaining debt, so some unhealthy positions may become practically unliquidatable and the protocol could accumulate bad debt that exposes liquidity providers to losses.

What the attacker needed

A liquidatable NFT position; the final remaining debt is repaid in full; a finite hfLimitForLiquidation is configured

The fix

The health factor calculation or the post-liquidation check should treat a zero-debt position as fully healthy instead of comparing the maximum unsigned integer against the finite liquidation limit.

How it was found

  1. A liquidator calls liquidate on a liquidatable NFT and targets the last remaining debt position.
  2. The liquidator specifies repay-all for that debt position, so the final debt is removed from storage.
  3. After payback and collateral withdrawal, the NFT has zero debt value.
  4. The health factor helper returns the maximum unsigned integer because debt is zero.
  5. The post-liquidation check sees that value exceeds the finite liquidation limit and reverts the whole transaction.

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 health factor is a number that shows how safe a loan is; a very high number means there is little or no debt left. The code sets this number to the largest possible value when debt reaches zero, then a safety check compares it against a normal limit and rejects the transaction. As a result, a liquidator who tries to clear the last bit of debt always fails, so some bad loans cannot be closed.

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 Audinarey

View all

10 more disclosed reports, best first.

More from Fluid DEX v2

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.