> For the complete documentation index, see [llms.txt](https://docs.ironblocks.com/firewall/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ironblocks.com/firewall/policies/non-reentrant.md).

# 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)
