Skip to content
Business logic Audit finding Advanced

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.

ronnyx2017 Follow with 0xA5DF

Originally disclosed on Code4rena

Submitted by ronnyx2017, also found by 0xA5DF

Lines of Code

https://github.com/reserve-protocol/protocol/blob/9ee60f142f9f5c1fe8bc50eef915cf33124a534f/contracts/plugins/assets/cbeth/CBETHCollateral.sol#L67-L69 https://github.com/reserve-protocol/protocol/blob/9ee60f142f9f5c1fe8bc50eef915cf33124a534f/contracts/plugins/assets/ankr/AnkrStakedEthCollateral.sol#L58-L61

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.

Proof of Concept

For example, Now it’s about 17819370 block high on the mainnet, and the CBEth.exchangeRate()(https://etherscan.io/token/0xbe9895146f7af43049ca1c1ae358b0541ea49704#readProxyContract#F12) is 1.045264058480813188, but the chainlink price feed for cbETH/ETH(https://data.chain.link/ethereum/mainnet/crypto-eth/cbeth-eth) is 1.0438.

Recommended Mitigation Steps

Use the cbETH/ETH oracle to get the cbETH/ETH rate.

Or, the ref unit for the collateral should be the staked eth2.

Assessed type

Context

tbrent (Reserve) commented:

This feels like a duplicate of #32. The root cause is an incorrect reference unit. The reference unit should be staked eth2, as indicated here.

pmckelvy1 (Reserve) confirmed

ronnyx2017 (warden) commented:

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.

cccz (judge) increased severity to High

Reserve Mitigated:

Fixes units and price calculations in cbETH, rETH, ankrETH collateral plugins. PR: https://github.com/reserve-protocol/protocol/pull/899

Status: Mitigation confirmed. Full details in reports from ronnyx2017, bin2chen and RaymondFam.


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.

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.

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.

More by ronnyx2017

View all

24 more disclosed reports, best first.

More from Reserve Core

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.