Open code423n4 opened 1 year ago
Picodes marked the issue as duplicate of #407
Picodes marked the issue as selected for report
Picodes changed the severity to 3 (High Risk)
JeeberC4 marked the issue as not a duplicate
JeeberC4 marked the issue as primary issue
Lines of code
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/PirexERC4626.sol#L156-L165 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/PirexERC4626.sol#L167-L176
Vulnerability details
Impact
pxGMX and pxGLP tokens can be stolen from depositors in
AutoPxGmx
andAutoPxGlp
vaults by manipulating the price of a share.Proof of Concept
ERC4626 vaults are subject to a share price manipulation attack that allows an attacker to steal underlying tokens from other depositors (this is a known issue of Solmate's ERC4626 implementation). Consider this scenario (this is applicable to
AutoPxGmx
andAutoPxGlp
vaults):AutoPxGmx
vault;in the
deposit
function (PirexERC4626.sol#L60), the amount of shares is calculated using thepreviewDeposit
function:convertToShares
function:19e18 * 1 / 10e18 == 1
;Tools Used
Manual review
Recommended Mitigation Steps
Consider either of these options:
deposit
function ofPirexERC4626
, consider requiring a reasonably high minimal amount of assets during first deposit. The amount needs to be high enough to mint many shares to reduce the rounding error and low enough to be affordable to users.