Proposer can start a perpetual buyout which can only end if the auction succeeds and is not rejected
A proposer can start a buyout from a malicious contract that re-enters the start function when it receives ETH, making the buyout state permanently live. This prevents the buyout from ending and blocks any new buyout proposals, locking assets in the vault.
A user can start a perpetual buyout that cannot be stopped except by making the buyout succeed. This can be done by creating a malicious contract that will call back to start when it receives ETH via its receive function. The user then starts the perpetual buyout by calling start from the malicious contract.
Assume the rejection period has passed and the auction pool is not large enough (i.e. < 50%). If end is called then the method _sendEthOrWeth will attempt to send ETH to the malicious contract. The contract will simply call back to start sending the ETH it has just received.
The impact is that end can never be called on this buyout proposal if the buyout auction has failed. Worse, no new buyout proposal can be made since the current one is still live, and it is never in a state where it is not live.
The others users will either need to accept that assets are locked inside the vault, or that they will need to sellFractions in order to make the buyout succeed.
Proof of Concept
Each vault can only have one buyoutInfo associated with it as can be seen on line 39.
A new buyout proposal cannot be made unless the buyoutInfo state is State.INACTIVE as can be seen in lines 66-68
A proposer makes a proposal by calling start. They do this from a smart contract that simply calls start again when its receive function is called.
If the proposer fails to get over 50% then, when end is called, _sendEthOrWeth is called using the proposer value which is the smart contract that re-enters. See line 235. _sendETHOrWeth is cleverly written so that if receive were to revert the reversion would not “bubble up”. However, it does not protect against re-entrancy.
This means that buyoutInfo[vault] can never be overwritten. It is permanently stuck in state State.LIVE meaning that start can never be called for vault by anyone else.
The only way out of this conundrum is for the other users of the vault to sellFractions to make the auction succeed or to accept that assets are locked in the vault forever.
A foundry test exhibiting this attack has been written in a private fork of the contest repo.
Note that onERC1155Received needs to be implemented in the malicious contract.
Tools Used
Manual inspection + Foundry
Recommended Mitigation Steps
Prevent re-entrancy in the start function by using the nonReentrant modifier provided by OpenZeppelin’s ReentrancyGuard contract, or use an equivalent custom solution.
This exploit is a duplicate of the others in most respects but there is one key difference. In the other submissions there is at least a chance that someone else will get in their buyout bid after 4 days by carefully submitting a transaction at just the right moment. With the exploit I have outlined they cannot even do this. The call to end will automatically create a new buyout with no chance of anyone else ever getting their transaction in. It is a truly perpetual buyout.
To see an executable PoC of this (using a malicious contract to ensure the perpetual buyout) apply the diff in this gist and run
Thanks for the reply @sseefried! We felt this was the same underlying issue as #87 and others labeled as duplicates while having a more certain path to griefing.
Starting a buyout can result in assets being stuck in a contract. This submission shows how reentrancy can be used to make this even worse resulting in locking the assets up forever. This combination of concerns raises the issue to High risk.
Selecting this submission as the primary for identifying this potential impact and including a coded POC.
The original report as published on Code4rena, by sseefried. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The start function lacks re-entrancy protection, allowing a malicious contract to call it again when receiving ETH during the end function.
Impact
The buyout cannot be ended if it fails, and no new buyout can be started, so assets may be locked in the vault forever unless other users sell fractions to make the auction succeed.
What the attacker needed
Attacker can deploy a malicious contract; Buyout fails to reach 50%
The fix
The start function should be protected against re-entrancy, for example by using OpenZeppelin's nonReentrant modifier.
How it was found
Create a malicious contract that calls start again when it receives ETH.
Call start from the malicious contract to begin a buyout.
If the buyout fails to reach 50%, call end, which sends ETH to the malicious contract.
The malicious contract's receive function re-enters start, creating a new buyout.
The buyout state remains live, preventing new proposals.
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.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A buyout is a way for someone to offer to buy all shares of a vault. The attacker uses a smart contract that automatically starts a new buyout whenever it gets a refund, so the buyout never ends and no one else can start a new one. This leaves the vault's assets stuck.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.