The ClearingHouse contract uses a hard-coded maximum loan-to-collateral ratio (maxLTC) that assumes a fixed DAI/gOHM exchange rate. If the actual price of gOHM deviates from that assumption, the contract may approve under-collateralised loans, allowing borrowers to default profitably.
The maxLTC variable is a constant which implies a specific DAI/gOHM echange rate. The exchange rate has already changed so the current value in use will be wrong, and any value chosen now will eventually be out of date.
Vulnerability Detail
The ClearingHouse allows any loan to go through (assuming the operator approves it, and the operator is likely some sort of keeper program), and decides whether the terms are fair based on the hard-coded maxLTC, which will be (and is already - gOHM is currently worth $2,600) out of date.
If the code had been using a Chainlink oracle, this issue would be equivalent to not checking whether the price used to determine the loan-to-collateral ratio was stale, which is a Medium-severity issue.
It's not clear who or what exactly will be in control of the operator address which will make the clear() calls, but it will likely be a keeper which, unless programmed otherwise, would blindly approve such loans. Even if the operator is an actual person, the fact that there are coded checks for the maxLTC, means that the person/keeper can't be fully trusted, or that the code is attempting to protect against mistakes, so this category of mistake should also be added.
Impact
Under-collateralized loans will be given, and borrowers will purposely take loans default, since they can use the loan amount to buy more collateral than they would lose during default.
Code Snippet
The maximum loan-to-collateral is hard-coded, rather than being based on an oracle price:
If the gOHM price drops below $2500 to say $2000, a loan for 2500 DAI will only require 1 gOHM of collateral, even though it should require at least 1.2 gOHM in order to be fully-collateralized:
Solidity
// File: src/Cooler.sol : Cooler.collateralFor() #2
236 function collateralFor(uint256 amount, uint256 loanToCollateral) public pure returns (uint256) {
237 @> return amount * decimals / loanToCollateral;
238: }
Use a chainlink oracle to determine the right prices to use when coming up with the maximum loan-to-collateral, for each loan
Discussion
hrishibhat
Sponsor comment:
Not intended to be updated in real time. Set via gov; computed relative to backing (far less volatile than pricing).
IllIllI000
The values are stored in constant variables, so once they're set they cannot change
hrishibhat
Considering this issue as a valid medium, as a request placed with an ltc based on the exchange rate would result in incorrect maxltc calculated. Could render the contract useless since the maxLTC is fixed.
If the gOHM price drops below $2500 to say $2000, a loan for 2500 DAI will only require 1 gOHM of collateral, even though it should require at least 1.2 gOHM in order to be fully-collateralized:
0x00052
Escalate for 11 USDC
If the gOHM price drops below $2500 to say $2000, a loan for 2500 DAI will only require 1 gOHM of collateral, even though it should require at least 1.2 gOHM in order to be fully-collateralized:
I disagree with this statement. It doesn't use the maxLTC when creating the loan, it uses the value specified by the loan request. maxLTC is just the max value it can't exceed. There's nothing forcing the operator to accept every loan at/under the maxLTC. The operator would have discretion and wouldn't clear bad loans that are undercollateralized from the start. The only thing it's doing it providing a hard stop for the ltc.
We see in the above lines that it pulls the requested LTC from the cooler and compares it to maxLTC to confirm it isn't too high. It doesn't use the maxLTC value, it simply functions as a guardrail to make sure it doesn't accidentally clear a bad loan to gives way too much DAI. Technically if the price of gOHM was to increase dramatically the contract would become useless, but it wouldn't lead to any lost/stuck funds and it would be easy enough to just deploy a new contract with different bounds.
This should be low severity.
sherlock-admin
Escalate for 11 USDC
If the gOHM price drops below $2500 to say $2000, a loan for 2500 DAI will only require 1 gOHM of collateral, even though it should require at least 1.2 gOHM in order to be fully-collateralized:
I disagree with this statement. It doesn't use the maxLTC when creating the loan, it uses the value specified by the loan request. maxLTC is just the max value it can't exceed. There's nothing forcing the operator to accept every loan at/under the maxLTC. The operator would have discretion and wouldn't clear bad loans that are undercollateralized from the start. The only thing it's doing it providing a hard stop for the ltc.
We see in the above lines that it pulls the requested LTC from the cooler and compares it to maxLTC to confirm it isn't too high. It doesn't use the maxLTC value, it simply functions as a guardrail to make sure it doesn't accidentally clear a bad loan to gives way too much DAI. Technically if the price of gOHM was to increase dramatically the contract would become useless, but it wouldn't lead to any lost/stuck funds and it would be easy enough to just deploy a new contract with different bounds.
This should be low severity.
You've created a valid escalation for 11 USDC!
To remove the escalation from consideration: Delete your comment.
To change the amount you've staked on this escalation: Edit your comment (do not create a new comment).
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
hrishibhat
Escalation rejected
After careful consideration & internal discussion. Sherlock did not have full context on the intent of the contract. Based on certain assumptions, & as pointed out by the escalation,
in case of price change, the contract does not seem to serve its purpose and is rendered useless with the same bounds, making this issue a valid medium.
sherlock-admin
Escalation rejected
After careful consideration & internal discussion. Sherlock did not have full context on the intent of the contract. Based on certain assumptions, & as pointed out by the escalation,
in case of price change, the contract does not seem to serve its purpose and is rendered useless with the same bounds, making this issue a valid medium.
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
The original report as published on Sherlock, by IllIllI. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The maximum loan-to-collateral ratio is hard-coded as a constant instead of being fetched from a price oracle, so it cannot adapt to market changes.
Impact
Under-collateralised loans could be approved, and borrowers could deliberately default because the loan amount exceeds the value of the collateral they lose.
What the attacker needed
GOHM price deviates from assumed rate; operator approves a loan within maxLTC
The fix
The contract should use a Chainlink oracle to determine the maximum loan-to-collateral ratio for each loan, rather than relying on a hard-coded constant.
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.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A smart contract for loans uses a fixed number to decide if a loan has enough collateral. If the real price of the collateral changes, that fixed number becomes wrong, and people might get loans that are too big for their collateral. They could then take the money and never repay, leaving the system with a loss.