Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialized storage variables are set again in the initializer function #45

Open
code423n4 opened this issue Nov 27, 2021 · 6 comments
Open
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

sabtikw

Vulnerability details

Impact

storage variables are initialized in the contract and overwritten in the initializer function.

Proof of Concept

Auction.sol L#89 L#164 auctionLength
AuctionBurnReserveSkew.sol L#25 auctionAverageLookback
MaltDataLab.sol L#69 priceTarget

Tools Used

manual review

Recommended Mitigation Steps

remove initialization outside of initializer function

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 27, 2021
code423n4 added a commit that referenced this issue Nov 27, 2021
@0xScotch 0xScotch added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 10, 2021
@GalloDaSballo
Copy link
Collaborator

This could be even worse @0xScotch , please note that for upgradeable contracts, default values set inline will default to 0 / false / 0x as the proxy you'll be using won't go through setting those default values

@GalloDaSballo
Copy link
Collaborator

@0xScotch after careful review, I believe you need to urgently change the initialize function to set the default values.
If you use any proxy, those values will be set to 0.
Because initialize doesn't set them again, this can be dramattic

@GalloDaSballo
Copy link
Collaborator

The warden didn't catch the higher severity finding so am leaving this as gas

@0xScotch
Copy link
Collaborator

0xScotch commented Jan 3, 2022

Hey @GalloDaSballo sorry for the late reply. The contracts are not meant to be upgradeable, the use of initializable was a habitual one. We plan on completely removing initializable and just use contructors instead due to the contracts not being upgradeable.

@GalloDaSballo
Copy link
Collaborator

@0xScotch Thank you for the clarification
Because of this, I'll be re-evaluating some of the findings.

@0xScotch Please note that because you are not using a proxy for deploying, your contract initialize may get frontrun, switching to constructor solves as well as enabling the usage of immutable

@0xScotch
Copy link
Collaborator

0xScotch commented Jan 3, 2022

Yes we are aware of the frontrunning issue too. We will absolutely be switching to constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants