Collateral can already be seized even when negRiskMarket is not fully resolved
The loan contract allowed collateral to be seized once the UMA oracle reported an outcome, even if that outcome was still subject to challenge by the negRiskAdapterOperator. An attacker could exploit this to take a borrower's collateral before the market was fully resolved, causing loss of funds if the outcome later changed.
Source: https://github.com/sherlock-audit/2024-09-predict-fun-judging/issues/113
Found by
PUSH0
Summary
NegRiskMarket has a two step verification process, in order to ensure reported outcomes are correct. First the UMA oracle has the possibility to flag the answer and after this there is a period of time in which the negRiskAdapterOperator can flag the result.
View following code for negRiskOperator: NegRiskOperator.sol View following code for UMA report: UmaCtfAdapter.sol
The negRiskOperator can still change the answer in case he deems it to be incorrect, even after the UMA oracle has reported a valid outcome.
This leads to following problem: Currently the loan can be seized even if the negRiskAdapterOperator has flagged the result / the result is not yet determined.
In case the answer changes, it will lead to loss of collateral for the borrower.
Root Cause
Currently the _isQuestionPriceAvailable function checks if the UMA oracle OR the Market is determined. In case the UMA oracle returns a result, but this result is flagged and the market is not determined yet, the function will return true regardless.
function _isQuestionPriceAvailable(
QuestionType questionType,
bytes32 questionId
) private view returns (bool isAvailable) {
if (questionType == QuestionType.Binary) {
(isAvailable, ) = _isBinaryOutcomeQuestionPriceAvailable(UMA_CTF_ADAPTER, questionId);
} else {
(isAvailable, ) = _isBinaryOutcomeQuestionPriceAvailable(NEG_RISK_UMA_CTF_ADAPTER, questionId);
isAvailable = isAvailable || _isNegRiskMarketDetermined(questionId);
}
}
Internal pre-conditions
- Lender creates loan on difficult market
- The loan time ends and it becomes sizable
External pre-conditions
- UMA Oracle returns an Answer
- The UMA Oracles answers gets flagged / changed by the negRiskAdapterOperator.
Attack Path
- Create loan on difficult market that ends shortly after the market resolves
- Take unrightfully collateral in case outcome changes
Impact
Lender can take borrowers collateral even if the answer has not fully resolved. Breaking invariant and leading to loss of funds.
Mitigation
It should be sufficient to check only _isNegRiskMarketDetermined(questionId). From our research it can only return true in case the UMA oracle and the negRiskAdapter are correctly resolved.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/PredictDotFun/predict-dot-loan/pull/45
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The _isQuestionPriceAvailable function returns true if either the UMA oracle has reported an outcome or the market is determined, without requiring both conditions to be satisfied.
Impact
A lender could take the borrower's collateral before the outcome is final, leading to loss of funds if the answer changes.
What the attacker needed
Loan on a difficult market; Loan time ends and becomes sizable; UMA oracle returns an answer; Answer flagged or changed by operator
The fix
The protocol team fixed this issue by changing the check to only consider whether the negRisk market is determined.
How it was found
- Create a loan on a difficult market that ends shortly after the market resolves.
- Wait for the UMA oracle to return an answer.
- The negRiskAdapterOperator flags or changes the answer.
- The lender seizes the collateral even though the market is not fully resolved.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In prediction markets, a result must be confirmed by two steps: first an oracle reports it, then an operator can challenge it. The loan contract only checked the first step, so a lender could take the borrower's collateral too early. If the result later changed, the borrower would lose their collateral unfairly.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.