I have identified another potential vulnerability related to the initiateRedemption function.
Vulnerability:
The initiateRedemption function does not correctly calculate the postFeeAmount when the autoPxEth contract is involved. The _pxEthAmount is calculated based on the apxETH-ETH ratio during the current block. However, the postFeeAmount calculation does not consider the potential impact of the autoPxEth contract on the pxETH supply. If the autoPxEth contract has a large pxETH balance, an attacker can manipulate the pxETH supply and affect the postFeeAmount calculation, potentially leading to unintended consequences.
Impact:
An attacker could potentially manipulate the pxETH supply and affect the fee calculation for redemptions, affecting the expected revenue for the contract owner or causing unintended consequences in the system.
Exploitation:
An attacker can exploit this vulnerability by creating transactions that manipulate the pxETH balance in the autoPxEth contract. By increasing or decreasing the pxETH balance in the autoPxEth contract, the attacker can indirectly affect the postFeeAmount calculation in the initiateRedemption function.
Recommendation:
To mitigate this vulnerability, consider implementing a more robust postFeeAmount calculation in the initiateRedemption function. The calculation should include the pxETH balance from the autoPxEth contract and any other contracts that can influence the pxETH supply.
Here is an example of how to implement the fix:
Update the initiateRedemption function to calculate totalPxEth:
By implementing this fix, you can ensure that the postFeeAmount calculation takes into account the impact of the autoPxEth contract, preventing potential supply manipulation and maintaining a fair fee calculation.
Lines of code
https://github.com/redacted-cartel/pirex-eth-contracts/blob/11f30c7e35b67d45deefe405c22a30f352bc5b21/src/PirexEth.sol#L460
Vulnerability details
I have identified another potential vulnerability related to the
initiateRedemption
function.Vulnerability:
The
initiateRedemption
function does not correctly calculate thepostFeeAmount
when theautoPxEth
contract is involved. The_pxEthAmount
is calculated based on theapxETH-ETH
ratio during the current block. However, thepostFeeAmount
calculation does not consider the potential impact of theautoPxEth
contract on thepxETH
supply. If theautoPxEth
contract has a largepxETH
balance, an attacker can manipulate thepxETH
supply and affect thepostFeeAmount
calculation, potentially leading to unintended consequences.Impact:
An attacker could potentially manipulate the
pxETH
supply and affect the fee calculation for redemptions, affecting the expected revenue for the contract owner or causing unintended consequences in the system.Exploitation:
An attacker can exploit this vulnerability by creating transactions that manipulate the
pxETH
balance in theautoPxEth
contract. By increasing or decreasing thepxETH
balance in theautoPxEth
contract, the attacker can indirectly affect thepostFeeAmount
calculation in theinitiateRedemption
function.Recommendation:
To mitigate this vulnerability, consider implementing a more robust
postFeeAmount
calculation in theinitiateRedemption
function. The calculation should include thepxETH
balance from theautoPxEth
contract and any other contracts that can influence thepxETH
supply.Here is an example of how to implement the fix:
initiateRedemption
function to calculatetotalPxEth
:totalPxEth
in thepostFeeAmount
calculation:By implementing this fix, you can ensure that the
postFeeAmount
calculation takes into account the impact of theautoPxEth
contract, preventing potential supply manipulation and maintaining a fair fee calculation.