setReserve() can be front-run
The reserve address in NestedFactory.sol is zero until an owner calls setReserve(), so any transfer or comparison involving reserve before that call may behave incorrectly. An attacker could front-run the setReserve() transaction to exploit the uninitialised state.
Submitted by palina
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(): NestedFactory.sol L89
Tools Used
Manual Analysis
Recommended Mitigation Steps
Consider initializing the value for the reserve variable in the constructor.
maximebrugel (Nested) commented:
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.
The fact that the call to
setReservecan be front-run is not being taken into account by the sponsor. I’m marking this one as not a duplicate.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the reserve variable is not initialised in the constructor and is only set later by an owner-callable function, leaving a window where it is zero and the setter can be front-run.
Impact
Before setReserve() is called, token transfers or comparisons involving reserve may be incorrect, and an attacker could front-run the setReserve() call to exploit the zero value.
What the attacker needed
Owner has not yet called setReserve(); attacker can front-run transactions
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract has a setting called reserve that should point to a token address, but it starts as zero. Until the owner sets it, the contract may send tokens to the wrong place or make wrong comparisons. An attacker can watch for the owner's setting transaction and get theirs processed first, taking advantage of the zero value.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.