# When opening a position, the collateral of the previous position is used for borrowing, which makes the user more easily liquidated

Rubicon's Position contract reuses existing collateral when opening a new leveraged position, pushing users to the liquidation threshold and enabling easy liquidation.

- Payout: Contest reward
- Severity: high
- Program: Rubicon
- Credited: cccz
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2023-04-rubicon-findings/issues/545
- Library page: https://bugbountylibrary.com/r/c4%3A2023-04-rubicon%3AH-13
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:business-logic vuln:liquidation

**Target:** Position.sol leveraged position opening
**Root cause:** When opening a new position, the contract includes the maximum borrowable amount from existing collateral in the new borrow calculation, effectively double-counting collateral and increasing total debt.
**Steps:**
1. Deploy Rubicon contracts and set up a pool with WBTC collateral factor 0.7.
2. Call `buyAllAmountWithLeverage` with 1e8 WBTC and 1.6x leverage.
3. Call `buyAllAmountWithLeverage` again with 1e8 WBTC and 1.8x leverage.
4. Observe `comptroller.getAccountLiquidity` returns 0, indicating liquidation threshold reached.
**How found:** Code review of the borrowing loop in Position.sol revealed that `_maxBorrow` from previous collateral is added to the new borrow amount, leading to over-borrowing.
**Exploitation:** A user opening consecutive leveraged positions inadvertently borrows against existing collateral, reducing the liquidation buffer to zero; a slight price drop triggers liquidation, causing loss of funds.
**Insight:** In leveraged position protocols, check whether new borrows account for existing collateral; reusing collateral can silently increase leverage and liquidation risk.
