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

initialize function in basket.sol can be front-run #3

Open
code423n4 opened this issue Sep 16, 2021 · 1 comment
Open

initialize function in basket.sol can be front-run #3

code423n4 opened this issue Sep 16, 2021 · 1 comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Warden finding

Comments

@code423n4
Copy link
Contributor

Handle

jah

Vulnerability details

Impact

As the initialize function is pubic it can be called by anyone and it can be front run by a hacker

Proof of Concept

https://github.com/code-423n4/2021-09-defiProtocol/blob/52b74824c42acbcd64248f68c40128fe3a82caf6/contracts/contracts/Basket.sol#L36

Tools Used

Manual analysis

Recommended Mitigation Steps

call the initialize function in the constructor

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Warden finding labels Sep 16, 2021
code423n4 added a commit that referenced this issue Sep 16, 2021
@GalloDaSballo
Copy link
Collaborator

The function can be frontrun, a typical way to avoid that is to have a constructor which sets the msg.sender to the only account that can call initialize

An alternative mitigation is to use UpgradeableProxies (from OZ) which allow to deploy and initialize in the same tx, making it impossible to be frontrun.

Will downgrade to low severity

@GalloDaSballo GalloDaSballo added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Warden finding
Projects
None yet
Development

No branches or pull requests

2 participants