# Non Reentrant

## Overview

This policy prevents a consumer from re-entering the same method of a your smart contracts in a single transaction - which is a well-known attack vector called Reentrancy.

## Protected Attack Vector

This policy protects agains reentrancy attacks.

## How It Works

1. When a transaction reaches the policy, it keeps track of the fact that the consumer has visited the method currently being executed.<br>
2. If the method is called again by the consumer before exiting, the policy will block the transaction.<br>
3. If not, once the currently-executing method has finished, we clear the visitation count for the consumer.

## Properties

<table><thead><tr><th width="234">Name</th><th width="256.3333333333333">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>hasEnteredConsumer</code></td><td><p><code>mapping</code></p><p><code>(address => bool)</code></p></td><td>a mapping of consumers that have visited the currently-executing method</td></tr></tbody></table>

## **Security Lifecycle**

This policy runs during both the Firewall's [Pre Execution](/firewall/glossary.md#pre-execution) and the [Post Execution](/firewall/glossary.md#post-execution) hooks.

## Source Code

On our GitHub repository: [NonReentrantPolicy.sol](https://github.com/ironblocks/onchain-firewall/blob/main/packages/onchain-firewall/contracts/policies/NonReentrantPolicy.sol)


---

# Agent Instructions: 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:

```
GET https://docs.ironblocks.com/firewall/policies/non-reentrant.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
