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.
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-1055the_getHfInfo()helper setshfInfo_.hf = type(uint256).maxwheneverhfInfo_.debtValue == 0. - In
contracts/contracts/protocols/moneyMarket/core/liquidateModule/main.sol:622-627theliquidate()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()loadshfLimit_from_moneyMarketVariablesand 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, sethf = 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
debtValuebecomes0) will make_getHfInfo()returnhf = type(uint256).max. - Since
hfLimitForLiquidationis a finite value,type(uint256).max > hfLimitForLiquidationwill 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):
- 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.
- 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 tohf = type(uint256).max. - 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.
- 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.
Attack Path
Attack path 1: Any liquidation that clears all remaining debt reverts at the end
- A liquidator calls
liquidate()on an NFT that is liquidatable (hf < 1e18at function entry) and targets the last remaining debt position aspaybackPositionIndex. - The liquidator specifies “repay all” for that debt position (e.g., using
type(uint256).maxwhere supported), so the payback deletes the final debt amount from storage. - After payback and collateral withdrawal steps, the NFT now has
debtValue == 0. liquidate()evaluates the post-liquidation constraint:_getHfInfo(...).hfreturnstype(uint256).maxbecausedebtValue == 0(helpers.sol:1051-1055).type(uint256).maxexceeds any finitehfLimitForLiquidation, soliquidate()reverts withLiquidateModule__HfLimitExceeded(liquidateModule/main.sol:622-627).
- The entire liquidation (including repayment and collateral transfer) is reverted.
Attack path 2: “Only-full-payback” unhealthy positions become unliquidatable (liquidation DoS)
- 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 >= 1e16inliquidateModule/main.sol:235-236, and/or by “payback exceeds borrow” checks during payback storage updates). - 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. - Repaying the full remaining debt makes
debtValue == 0, which makes HF becometype(uint256).max. - 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
- Liquidators can partially liquidate a position but cannot clear the final remaining debt due to attack path 1 (full clearance always reverts).
- If the borrower does not (or cannot) voluntarily repay the residual debt, the protocol is forced to carry that open debt indefinitely.
- 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
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
- A liquidator calls liquidate on a liquidatable NFT and targets the last remaining debt position.
- The liquidator specifies repay-all for that debt position, so the final debt is removed from storage.
- After payback and collateral withdrawal, the NFT has zero debt value.
- The health factor helper returns the maximum unsigned integer because debt is zero.
- 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.