# Neither sellCreditMarket() nor compensate() checks whether the credit position to be sold is allowed for sale

Size's sellCreditMarket() and compensate() ignore a credit position's forSale flag, letting owners dump non-sellable positions onto passive buyers who cannot resell them.

- Payout: Audit contest
- Severity: medium
- Program: Size
- Found by: 0xpiken
- Disclosed: 2024-09-16
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-06-size-findings/issues/184
- Library page: https://bugbountylibrary.com/r/c4%3A2024-06-size%3AM-06
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:access-control vuln:business-logic

**Target:** Size protocol credit market contracts (SellCreditMarket.sol, Compensate.sol)
**Root cause:** validateSellCreditMarket() and validateCompensate() check transferability but never verify the credit position's forSale flag or the lender's allCreditPositionsForSaleDisabled setting, so a not-for-sale position can still be sold or used to compensate debt.
**Steps:**
1. Bob creates a credit position via sellCreditMarket() to lender alice, then marks it not for sale via _setUserConfiguration (forSale=false).
2. Alice calls `sellCreditMarket(SellCreditMarketParams({lender: candy, creditPositionId: CREDIT_POSITION_ID_START, amount: 120e6, tenor: 365 days, ...}))` — succeeds despite forSale=false.
3. Candy now owns the position with forSale=false; james calling `buyCreditMarket(...)` reverts with `Errors.CREDIT_NOT_FOR_SALE`.
4. Candy must manually flip forSale=true via _setUserConfiguration before anyone can buy it, else she is stuck holding it.
**How found:** Code review of the sell/compensate validation paths: noticed validateSellCreditMarket and validateCompensate enforce transferability but omit the forSale check that buyCreditMarket enforces, then wrote a Foundry PoC to confirm the asymmetry.
**Exploitation:** A credit position owner marks a position not-for-sale, then sells it (or uses it in compensate()) to an unsuspecting passive buyer. The buyer receives a position flagged forSale=false and cannot resell it, losing arbitrage/liquidity opportunity until they manually toggle the flag.
**Insight:** When a protocol has a 'for sale' / listing flag enforced on the buy path, check whether the sell and compensate paths enforce the same flag — asymmetric validation lets owners push restricted assets onto passive counterparties.

