Platform: Code4rena
Start Date: 15/12/2022
Pot Size: $128,000 USDC
Total HM: 28
Participants: 111
Period: 19 days
Judge: GalloDaSballo
Total Solo HM: 1
Id: 194
League: ETH
Rank: 111/111
Findings: 1
Award: $3.73
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xdeadbeef0x
Also found by: 0xLad, 0xNazgul, 0xSmartContract, 0xbepresent, Arbor-Finance, Breeje, HE1M, IllIllI, Qeew, Rolezn, SEVEN, SamGMK, SmartSek, TomJ, WatchDogs, ak1, btk, ck, datapunk, dic0de, eierina, fs0c, hansfriese, koxuan, ladboy233, peanuts, rvierdiiev, sces60107, tonisives, unforgiven, yongskiws
3.7263 USDC - $3.73
Using the previewRedeem
function of ERC4626Upgradeable
, it is possible to manipulate the price.
An attacker can increase or decrease the price to carry out various attacks against the protocol.
The previewRedeem
function will call the convertToAssets
function, in the convertToAssets
the share is calculated on the basis of totalAsset
and supply which can be increased or decreased within a single transaction by calling the deposit
functions, This allows the attacker to inflate or deflate the price within a single transaction.
function previewRedeem(uint256 shares) public view virtual returns (uint256) { return convertToAssets(shares); }
function convertToAssets(uint256 shares) public view virtual returns (uint256) { uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero. return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply); }
Code inspection
Price in ERC4626 vault should not be calculated using previewReedem
function.
#0 - GalloDaSballo
2023-01-03T23:14:21Z
In contrast to other reports, this is missing the specific attack, I think I'll award a % vs the full finding
#1 - c4-judge
2023-01-10T07:57:10Z
GalloDaSballo marked the issue as duplicate of #209
#2 - c4-judge
2023-01-10T07:57:20Z
GalloDaSballo marked the issue as partial-25
#3 - GalloDaSballo
2023-01-10T07:57:43Z
25% because:
#4 - c4-judge
2023-01-29T18:38:59Z
GalloDaSballo changed the severity to 3 (High Risk)
#5 - c4-judge
2023-02-08T09:45:14Z
GalloDaSballo marked the issue as satisfactory
#6 - c4-judge
2023-02-08T09:45:27Z
GalloDaSballo marked the issue as partial-25