# Using wrong format of `questionId` for `NegRiskCtfAdapter` leads to loan operations on resolved multi-outcome markets

PredictDotLoan conflates UmaCtfAdapter questionId with NegRiskAdapter questionId format, so resolved multi-outcome markets read as unresolved, enabling loans against worthless positions.

- Payout: Audit contest
- Severity: medium
- Program: Predict Fun
- Found by: kuprum
- Disclosed: 2024-09-19
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2024-09-predict-fun-judging/issues/119
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-09-predict-fun%3AM-4
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** PredictDotLoan lending contract / NegRiskAdapter resolution check
**Root cause:** PredictDotLoan passes UmaCtfAdapter's keccak256(ancillaryData) questionId into NegRiskAdapter.getDetermined via NegRiskIdLib.getMarketId, but NegRiskAdapter questionIds are marketId(248 bits)|index(8 bits); masking the wrong-format id yields an uninitialized marketId, so getDetermined always returns false.
**Steps:**
1. Observe NegRiskOperator.prepareQuestion takes _requestId (UmaCtfAdapter questionId) and generates its own questionId = marketId|index via NegRiskIdLib.getQuestionId.
2. Note PredictDotLoan._isNegRiskMarketDetermined calls NEG_RISK_ADAPTER.getDetermined(NegRiskIdLib.getMarketId(questionId)) using the UmaCtfAdapter-format questionId directly.
3. Since getMarketId masks the last 8 bits of the wrong-format id, the resulting marketId is never initialized in marketData, so determined() reads 0x00 and returns false.
4. After a multi-outcome market resolves, submit/accept a loan proposal for a losing outcome position; the resolution guard passes because getDetermined returns false.
**How found:** Code-reading: compared how UmaCtfAdapter and NegRiskAdapter each derive questionId (keccak256 of ancillary data vs marketId|index packing) and noticed PredictDotLoan feeds the former into NegRiskIdLib.getMarketId, which masks bits assuming the latter format.
**Exploitation:** After a multi-outcome market resolves, attacker grabs an open loan proposal or provides a borrow proposal for a position guaranteed to resolve to 0 (or for the winning candidate), since PredictDotLoan treats the market as unresolved; the loan is issued against worthless collateral, causing guaranteed loss to the lender or excess seizure by the borrower.
**Insight:** When integrating two oracle/adapter contracts, verify that identifiers passed between them share the same derivation; a bit-packing scheme (marketId|index) silently misinterprets a hash-based id, and mapping lookups on the wrong key return default values that bypass guards.

