Adversary can break deposit queue and cause loss of funds
The deposit queue in Carousel.sol uses ERC1155 _mint which calls the receiver's acceptance check, allowing a malicious user to make their receiver revert and block all subsequent deposits. Since deposits cannot be cancelled, users whose deposits are blocked lose their funds.
Source: https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/468
Found by
0x52, 0xRobocop, Bauer, HonorLt, Respx, Ruhum, VAD37, bin2chen, immeas, joestakey, jprod15, libratus, ltyu, mstpr-brainbot, nobody2018, roguereddwarf, warRoom, yixxas
Summary
Vulnerability Detail
function _mintShares(
address to,
uint256 id,
uint256 amount
) internal {
_mint(to, id, amount, EMPTY);
_mintEmissions(to, id, amount);
}
When processing deposits for the deposit queue, it _mintShares to the specified receiver which makes a _mint subcall.
function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
The base ERC1155 _mint is used which always behaves the same way that ERC721 safeMint does, that is, it always calls _doSafeTrasnferAcceptanceCheck which makes a call to the receiver. A malicious user can make the receiver always revert. This breaks the deposit queue completely. Since deposits can't be canceled this WILL result in loss of funds to all users whose deposits are blocked. To make matters worse it uses first in last out so the attacker can trap all deposits before them
Impact
Users who deposited before the adversary will lose their entire deposit
Code Snippet
Tool used
Manual Review
Recommendation
Override _mint to remove the safeMint behavior so that users can't DOS the deposit queue
Discussion
3xHarry
agree with this issue, there is no easy solution to this, as by definition when depositing into queue, the user gives up the atomicity of his intended mint. Looking at Openzeppelins 1155 implementation guide it is recommended to ensure the receiver of the asset is able to call safeTransferFrom. By removing the acceptance check in the _mint function, funds could be stuck in a smart contract.
Another alternative would be to do the 1155 acceptance check in the mint function and confiscate the funds if the receiver is not able to hold 1155s. The funds could be retrieved via a manual process from the treasury afterward.
3xHarry
going with Recommendation is prob the easiest way
3xHarry
fix PR: https://github.com/Y2K-Finance/Earthquake/pull/124
IAm0x52
Fix looks good. _mint no longer calls acceptance check so rollover can longer be DOS'd by it
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
The contract uses ERC1155 _mint which performs a safe transfer acceptance check on the receiver, and a malicious receiver can revert that check, blocking the queue.
Impact
Users who deposited before the adversary will lose their entire deposit.
What the attacker needed
Attacker can deposit into the queue; attacker controls a contract that reverts on token receipt
The fix
Override _mint to remove the safeMint behaviour so that users cannot DOS the deposit queue; the fix was applied in a pull request.
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.
When you deposit into a queue, the contract mints shares to you. The standard token contract calls your address to confirm you can receive tokens. An attacker can make that call fail, which stops the queue for everyone behind them. Because deposits cannot be cancelled, those users lose their money.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.