Open code423n4 opened 2 years ago
All deployable contracts in Perennial have been built to comply with the OZ upgrades plugin.
This deployment library handles cases such as preventing malicious front-running. Further, we will be validating that all params are correctly initialized as part of the deployment scripts.
Given that this information was not specified in the documentation, we're comfortable with calling this a 0 (Non-critical) issue
.
Agree with finding and severity
See Poc from warden for mitigation
Given that this information was not specified in the documentation I think this finding should be rewarded.
Handle
broccolirob
Vulnerability details
The
Factory
,Collateral
, andIncentivizer
contracts haveinitialize
functions that can be front-run, allowing an attacker to initialize the contracts with incorrect values.Impact
If the malicious intialization call is not detected immediately, the attacker can steal funds once the protocol is up and running.
Proof of Concept
Perennial deploys their
Collateral
contract. Eve front-runs itsinitialize
function, and sets the factory address to a malicious contract of her own design.factory.treasury()
andfactory.treasury(product)
now return Eve's address, allowing her to steal all fees from all products across the protocol.Tools Used
Manual Analysis and Hardhat.
Recommended Mitigation Steps
Use OpenZeppelin's
TransparentUpgradeableProxy
contract to deploy these contracts. That way theinitialize
function and its arguments can be passed in as calldata to the Proxy's third constructor argument and run in the same transaction as the deployment.