# User's can seize more assets during liquidation by using type(uint).max

Liquidator double-counts debt repayment by passing a partial amount plus type(uint256).max for the same pool, letting them seize excess borrower collateral.

- Payout: Audit contest
- Severity: high
- Program: Sentiment
- Found by: A2-security
- Disclosed: 2024-08-07
- Write-up quality: 8/10
- Original: https://github.com/sherlock-audit/2024-08-sentiment-v2-judging/issues/556
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-sentiment-v2%3AH-2
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:chained technique:source-review vuln:accounting-error vuln:business-logic vuln:liquidation

**Target:** RiskModule liquidation validation (Solidity lending protocol)
**Root cause:** _validateSeizedAssetValue resolves type(uint256).max to pool.getBorrowsOf at validation time, but the actual repay loop processes entries sequentially, so an earlier partial repayment reduces the balance before the max entry is resolved, causing the repaid value to be counted twice.
**Steps:**
1. Set up a position with 1e18 debt and 2e18 collateral; drop collateral price so position is unhealthy.
2. Compute max seizable value = debtRepaidValue * 1e18 / (1e18 - discount); confirm a single oversized seize reverts with RiskModule_SeizedTooMuch.
3. Call `positionManager.liquidate(position, debts, assets)` with `debts[0] = {poolId, amt: 0.9e18}` and `debts[1] = {poolId, amt: type(uint256).max}`.
4. Set `assets[0] = {asset2, amt: 2e18}` to seize full collateral.
5. Validation sums 0.9e18 + full borrows (1e18) = 1.9e18 repaid value, but execution only transfers 0.9e18 + 0.1e18 = 1e18, so the seize passes and drains collateral.
**How found:** Noticed that type(uint256).max is resolved to current borrows inside the validation loop, then reasoned that the execution loop repays sequentially, so a prior partial repayment makes the max entry resolve to a smaller amount than validation assumed — a validation/execution mismatch.
**Exploitation:** Liquidator submits a debtData array with two entries for the same pool: a partial amount followed by type(uint256).max. Validation over-counts repaid value, allowing seizure of collateral far beyond the discount-adjusted cap, extracting the borrower's full collateral for less repayment than accounted.
**Insight:** When a sentinel value like type(uint256).max is resolved against live state, check whether the same array is processed sequentially elsewhere; duplicate entries for the same key can make validation and execution see different balances.

