AfEth deposits could use price data from an invalid Chainlink response
The VotiumStrategy price function calls ethPerCvx(false), which skips validation of the Chainlink price feed response, allowing stale or invalid prices to be used. An attacker could deposit when the price is stale, receiving more AfEth tokens than deserved.
The current price implementation for the VotiumStrategy token uses a potentially invalid Chainlink response. This price is then used to calculate the price of AfEth and, subsequently, the amount of tokens to mint while depositing.
Impact
The price of VotiumStrategy tokens are determined by taking the amount of deposited CVX in the strategy, and multiplied by the current price of CVX in terms of ETH. This price is fetched using Chainlink in the ethPerCvx() function:
As we can see from the previous snippet of code, if the _validate flag is off, then no validation is done, it can even return an uninitialized response from a failed call given the usage of the try/catch structure. This means that it can invalid price, stale price, or even zero when the call fails.
The VotiumStrategy price() function calls ethPerCvx(false), which means it carries forward any invalid CVX/ETH price.
The VotiumStrategy price is first used in line 138 to calculate its TVL (vEthValueInEth). Any invalid price here will also mean an invalid price for AfEth.
Then both the AfEth price (line 151) and again the VotiumStrategy price (line 164) are used in deposit() to calculate the number of minted tokens. Depending on the direction of the wrong price, this means that the user will be minted more or less tokens than it should.
Proof of Concept
Let’s suppose the Chainlink feed is stale and the current price of CVX/ETH has increased since then.
A user calls deposit() to create a new position in AfEth.
The function calculates the current price (priceBeforeDeposit) in order to know how many tokens should be minted.
The price() implementation will calculate the Votium strategy TVL using ethPerCvx(false), which will successfully return the stale price.
The price of AfEth will then be calculated using the old data, which will result in a lower value than the actual “real” price.
The user is minted tokens based on the incorrectly calculated priceBeforeDeposit, since this price is lower than the expected “real” price the user will be minted more tokens than expected.
Recommendation
Change the ethPerCvx() argument to true to make sure prices coming from Chainlink are correctly validated.
Status: Mitigation confirmed. Full details in reports from m_Rassska, d3e4, and adriro.
The original report as published on Code4rena, by adriro. 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
The price function calls ethPerCvx with validation disabled, so it accepts unvalidated Chainlink responses.
Impact
A user could receive more AfEth tokens than they should when depositing during a stale price period, potentially diluting other holders.
What the attacker needed
Chainlink price feed is stale; User calls deposit()
The fix
The mitigation was to validate Chainlink price data by changing the argument to true.
How it was found
A user calls deposit() to create a new position in AfEth.
The function calculates the current price (priceBeforeDeposit) to determine how many tokens to mint.
The price() implementation calculates the Votium strategy TVL using ethPerCvx(false), which returns the stale price.
The AfEth price is calculated using the old data, resulting in a lower value than the actual price.
The user is minted more tokens than expected because priceBeforeDeposit is lower than the real price.
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
A smart contract uses a price feed from Chainlink to value some tokens. The code has a flag that, when off, skips checking if the price is fresh and valid. If the price is old, someone can deposit and get too many tokens because the system undervalues the deposit.