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

setReserve() can be front-run #82

Open
code423n4 opened this issue Nov 16, 2021 · 2 comments
Open

setReserve() can be front-run #82

code423n4 opened this issue Nov 16, 2021 · 2 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

palina

Vulnerability details

Impact

The reserve address variable in NestedFactory.sol remains equal to 0 before the setReserve() function is called by an owner. This may lead to incorrect transfers of tokens or invalid comparison with e.g., the asset reserve (nestedRecords.getAssetReserve(_nftId) == address(reserve)), should they occur before the value for reserve was set.
In addition, the immutabiliy of the reserve variable requires extra caution when setting the value.

Proof of Concept

setReserve(): https://github.com/code-423n4/2021-11-nested/blob/5d113967cdf7c9ee29802e1ecb176c656386fe9b/contracts/NestedFactory.sol#L89

Tools Used

Manual Analysis

Recommended Mitigation Steps

Consider initializing the value for the reserve variable 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 Something isn't working labels Nov 16, 2021
code423n4 added a commit that referenced this issue Nov 16, 2021
@maximebrugel maximebrugel added the duplicate This issue or pull request already exists label Nov 16, 2021
@maximebrugel
Copy link
Collaborator

The main issue is duplicated : #60

The following comment can be considered as a duplicate of #83 if the extra caution is checking the zero address.

In addition, the immutabiliy of the reserve variable requires extra caution when setting the value.

@alcueca
Copy link
Collaborator

alcueca commented Dec 3, 2021

The fact that the call to setReserve can be front-run is not being taken into account by the sponsor. I'm marking this one as not a duplicate.

@alcueca alcueca reopened this Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants