Malicious pausing the contract
The auction contract's _createAuction function calls token.mint() inside a try/catch; if the mint runs out of gas, the catch block pauses the contract. An attacker could deliberately supply a gas amount that causes the mint to fail from out-of-gas, thereby pausing the contract and causing a denial of service.
Submitted by V_B
Auction.sol#L204 Auction.sol#L206 Auction.sol#L235
There is a function _createAuction in Auction contract.
It consists of the following logic:
/// @dev Creates an auction for the next token
function _createAuction() private {
// Get the next token available for bidding
try token.mint() returns (uint256 tokenId) {
**creating of the auction for token with id equal to tokenId**
// Pause the contract if token minting failed
} catch Error(string memory) {
_pause();
}
}
According to the EIP-150 call opcode can consume as most 63/64 of parrent calls’ gas. That means token.mint() can fail since there will be no gas.
All in all, if token.mint() fail on gas and the rest gas is enough for pausing the contract by calling _pause in catch statement the contract will be paused.
Please note, that a bug can be exploitable if the token.mint() consume more than 1.500.000 of gas, because 1.500.000 / 64 > 20.000 that need to pause the contract. Also, the logic of token.mint() includes traversing the array up to 100 times, that’s heavy enough to reach 1.500.000 gas limit.
Impact
Contract can be paused by any user by passing special amount of gas for the call of settleCurrentAndCreateNewAuction (which consists of two internal calls of _settleAuction and _createAuction functions).
Recommended Mitigation Steps
Add a special check for upper bound of gasLeft at start of _createAuction function.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
Honestly I’m really impressed by the submission, however I think the quote:
Please note, that a bug can be exploitable if the token.mint() consume more than 1.500.000 of gas, because 1.500.000 / 64 > 20.000 that need to pause the contract. Also, the logic of token.mint() includes traversing the array up to 100 times, that's heavy enough to reach 1.500.000 gas limit.shows that the likelihood of this happening is extremely small, the base mint will cost between 20k and 40k gas, and each instance of the loop should roughly cost 5k, with the minting instance costing around 5k + up to 50kFrom basic napkin math this is actually surprisingly possible
However I believe the odds of this happening are extremely low as you’d need to have at least 20 tokens being minted to founders
I think Med is more appropriate for now, I really like the catch of the OOG exploit, however I may have to downgrade further as the worst case scenario being pausing is not impactful.
Alex the Entreprenerd (judge) commented:
I believe the finding to be valid and Medium Severity as the conditions are non-trivial, but the impact is Denial of Service which can be triggered predictably given the circumnstances.
iainnash (Nouns Builder) confirmed
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 catch block unconditionally pauses the contract on any mint failure, including out-of-gas, without checking whether the failure was due to insufficient gas or other reasons.
Impact
An attacker could pause the contract, causing a denial of service, but this requires specific conditions (token.mint() consuming over 1.5 million gas) and the judge noted the likelihood is extremely low.
What the attacker needed
Token.mint() consumes >1.5M gas; attacker can choose gas amount
The fix
Add a check for an upper bound of gasLeft at the start of _createAuction function.
How it was found
- Call settleCurrentAndCreateNewAuction with a carefully chosen gas amount.
- The internal call to token.mint() consumes enough gas to fail due to out-of-gas.
- The catch block executes _pause(), pausing the contract.
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 a smart contract calls another contract, it can run out of gas if the call is expensive. Here, if the token minting runs out of gas, the code catches the error and pauses the whole auction. An attacker can choose how much gas to send so that the mint fails but there is still enough gas left to run the pause function, effectively stopping the auction.
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.