A cap is needed on the amount of Note than can be borrowed
The lending market has no cap on how much Note can be borrowed, so an attacker who manipulates the price of a collateral token against USDC could borrow unlimited Note and drain all Note-related value. The judge noted that the price of cNOTE itself is fixed at 1, but other tokens' prices can be manipulated, and rated the issue Medium.
The fact that there is no cap on the amount of Note that can be borrowed makes the Oracle Extractable Value unlimited. But as you intend to rely on TWAP, you need to make sure the cost of oracle manipulation is lower than the Oracle Extractable Value.
Proof of Concept
By manipulating the TWAPs of the designated proxy used for Note (USDC ?) and its relative price to a given collateral(which would be highly costly), an attacker could borrow Note without limit, and empty all pools related to Note and all Note-related value, instantly killing the stablecoin.
The value extractable by Oracle Manipulations is usually easily computable as it is the size of the lending market, but here, it’s more difficult to evaluate as it could potentially be any value linked to Note. This makes risk management harder and increase significantly the risk of attack.
Therefore a cap on how many Notes can be borrowed needs to be added to mitigate this risk.
The attack would be:
Manipulate the USDC / Collateral TWAP to be able to borrow Note with less than 1$ of collateral, which would be costly.
Extract all the value possible linked to Note, for example:
by buying all the tokens from pools Note / token at a discount
by supplying Notes to the lending platform and borrow collaterals for which the Note price is still at 1$
etc
Essentially as you have no cap on the amount of Note that could be borrowed in such a scenario, you cannot be sure that the potential attack profits are lower than the attack cost.
Recommended Mitigation Steps
The governance needs to set a limit on how much Note can be borrowed to mitigate risks, or add for example an “hourly” borrowing limit.
Easiest way to do this would be able to mint / burn from the accountant.
//set price statically to 1 when the Comptroller is retrieving Price
else if (compareStrings(ctoken.symbol(), "cNOTE") && msg.sender == Comptroller) {
return 1; // Note price is fixed to 1
}
However, you can manipulate the price of another token against USDC
else {
stablePair = (stable == 0) ? false : true;
pair = IBaseV1Pair(pairFor(USDC, underlying, stablePair)); //get the pair for the USDC/underlying pool
price = pair.quote(underlying, 1, 8); //how much USDC is this token redeemable for
}
The attack outlined by the warden would require an imbalance in the price of an asset against the given above code.
It would also require oracle manipulation, which requires no external arbitrage nor intervention It would require some value to be extractable from the system.
For those reasons, I think Medium Severity is more appropriate.
The original report as published on Code4rena, by Picodes. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
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 30 seconds. 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
Likely the absence of any borrowing cap on Note, combined with reliance on a manipulable TWAP for collateral pricing, allows unlimited borrowing when the oracle is skewed.
Impact
An attacker could borrow unlimited Note and drain all Note-related value, potentially killing the stablecoin, though the judge noted that cNOTE's price is fixed at 1 and the attack would require oracle manipulation and extractable value, so the severity was reduced to Medium.
What the attacker needed
Ability to manipulate a TWAP oracle; sufficient capital to move the price; no arbitrage intervention
The fix
The governance should set a limit on how much Note can be borrowed, for example an hourly borrowing limit, possibly by allowing mint and burn from the accountant.
How it was found
Manipulate the USDC/Collateral TWAP so that Note can be borrowed with less than $1 of collateral.
Extract all value linked to Note, for example by buying tokens from Note/token pools at a discount or by supplying Notes and borrowing collaterals still priced at $1.
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 30 seconds. 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
This is a lending system where you can borrow a stablecoin called Note by putting up other tokens as collateral. The price of that collateral is taken from a TWAP, which is an average price over time. If someone can push that average price up, they can borrow far more Note than their collateral is really worth, and since there is no limit on how much Note can be borrowed, they could take everything.