CBEthCollateral and AnkrStakedEthCollateral _underlyingRefPerTok is incorrect
The collateral plugins for cbETH and ankrETH used an exchange rate that converts to staked ETH2 rather than ETH, so the reported reference-per-token rate was too high. An attacker could exploit this to issue more rtokens than the collateral should allow, especially when the unstaking premium widened.
The CBEthCollateral._underlyingRefPerTok() function just uses CBEth.exchangeRate() to get the ref/tok rate. The CBEth.exchangeRate() can only get the conversion rate from cbETH to staked ETH2 on the coinbase. However as the docs https://github.com/reserve-protocol/protocol/blob/9ee60f142f9f5c1fe8bc50eef915cf33124a534f/contracts/2023-07-reserve/protocol/contracts/plugins/assets/cbeth/README.md the ref unit should be ETH. The staked ETH2 must take a few days to unstake, which leads to a premium between ETH and cbETH.
And the AnkrStakedEthCollateral and RethCollateral has the same problem. According to the ankr docs, unstake eth by Flash unstake have to pay a fee, 0.5% of the unstaked amount. https://www.ankr.com/docs/liquid-staking/eth/unstake/
Impact
The _underlyingRefPerTok will return a higher ref/tok rate than the truth. And the premium is positively correlated with the unstake delay of eth2. When the unstake queue suddenly increases, the attacker can uses cbeth to issue more rtokens. Even if the cbETH has defaulted, the CBEthCollateral will never mark the state as DISABLED because the CBEth.exchangeRate() is updated by coinbase manager and it only represents the cbETH / staked eth2 rate instead of the cbETH/ETH rate.
This issue and 32 explain the misuse of tar unit and ref unit in staked eth related assets from different perspectives. The root cause is same, that 1 staked eth2 != 1 eth. This issue assumes that the ref token and target is all eth, which is referred to in the docs. So the error should be in the function _underlyingRefPerTok. But issue 32 assumes that the ref unit should be staked eth2 and the target unit is eth. So it needs to modify function targetPerRef. I also have mentioned this mitigation in the Recommended Mitigation Steps section of the current issue:
Or, the ref unit for the collateral should be the staked eth2.
The original report as published on Code4rena, by ronnyx2017. 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 reference unit was defined as ETH while the exchange rate used returns the rate to staked ETH2, and the two are not equal.
Impact
The inflated rate could let an attacker issue more rtokens than the collateral justifies, and the collateral would not be marked DISABLED even if cbETH defaulted, because the exchange rate only tracks cbETH/staked ETH2.
What the attacker needed
Ability to issue rtokens against collateral
The fix
The units and price calculations in the cbETH, rETH and ankrETH collateral plugins were fixed.
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
These contracts accept liquid staking tokens (like cbETH) as collateral and calculate how much they are worth. They used a conversion rate that measures the token in staked ETH2, not in ordinary ETH, and staked ETH2 is worth slightly less because it takes days to unstake. That made the collateral look more valuable than it really was, so more tokens could be minted against it.
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.