Understanding the Denial Smart Contract: How an External Call Can Block Withdrawals
1. Introduction The Denial contract is a simplified version of the Denial of Service (DoS) vulnerability demonstrated in OpenZeppelin's Ethernaut Level 20 challenge. The contract allows an owner to withdraw funds from the contract. However, before sending funds to the owner, it also sends a portion of the contract's balance to an external address called partner . At first glance, this seems like a reasonable design. The contract distributes funds between two parties: the partner and the owner. However, there is a security issue in the withdrawal mechanism. Because the contract uses an unrestricted low-level call to interact with the partner, a malicious partner can deliberately prevent the owner from withdrawing funds. This article explains how the contract works, identifies the vulnerability, and demonstrates how an attacker can exploit it. 2. Understanding the Contract Structure Let's begin by examining the contract's state variables. // SPDX-Lice...