I solved all levels of Ethernaut game except level 20 Denial: https://ethernaut.openzeppelin.com/level/0xcE1BB92eeb71AF5Fec09D38B0c854d55285f6e04
Eventually, I gave up and looked up the solution on the author's blog: https://github.com/sigp/solidity-security-blog#dos-vuln
I deployed the following contract on Rinkeby Test Network using Remix:
pragma solidity ^0.8.7;
contract DenialAttack {
fallback() external payable {
assert(false);
}
}
The address of this contact is: 0x828F2073947a6d3De9caeEf48c7eCa989436a14B
Then I created a fresh instance of Denial on Ethernaut. Next I called (from dev tools):
contract.setWithdrawPartner("0x828F2073947a6d3De9caeEf48c7eCa989436a14B")
I made sure that partner
is successfully set to my attack contract. I submitted my instance but it told me that I haven't completed the level yet. Then I run (in dev tools in my Brave browser):
contract.withdraw()
And the transaction successfully completed. Here is how it looks on Etherscan.
Expected behavior is that I complete the level after submitting the instance and call to withdraw
fails with out of gas error.
Ok, so this should be enough to reproduce the issue.
The idea here is that partner.call.value(amountToSend)("");
passes all (or most?) gas to the callee contract (in my case to DenialAttack
), then the callee contract burns all the gas and the execution of the whole transaction fails because the Denial
contract has no gas left to finish the execution of withdraw()
. Therefore we have achieved denial of service.
However, it seems that what actually happened is that call
didn't pass all the gas to callee contract and enough gas was left to finish execution of withdraw()
.
I've also tried other ways to burn all gas like iterating many times over a loop or doing something similar to described here. Nothing works.
My hypothesis is that this solution used to work but something has changed in Ethereum with how gas is passed when using call
without specified gas limit and this level is no longer solvable. Maybe https://github.com/ethereum/EIPs/issues/114 is related?
My questions are: am I right? Is this level still solvable? If not, why? What did exactly change? When?
Thanks!