Title: Cozzetto&#8217;s TOCTOU Guard
Author: carlocozzetto
Published: <strong>November 30, 2026</strong>
Last modified: November 30, 2026

---

Search plugins

![](https://s.w.org/plugins/geopattern-icon/cozzetto-toctou-guard.svg)

# Cozzetto’s TOCTOU Guard

 By [carlocozzetto](https://profiles.wordpress.org/carlocozzetto/)

[Download](https://downloads.wordpress.org/plugin/cozzetto-toctou-guard.2.0.3.zip)

 * [Details](https://wordpress.org/plugins/cozzetto-toctou-guard/#description)
 * [Reviews](https://wordpress.org/plugins/cozzetto-toctou-guard/#reviews)
 *  [Installation](https://wordpress.org/plugins/cozzetto-toctou-guard/#installation)
 * [Development](https://wordpress.org/plugins/cozzetto-toctou-guard/#developers)

 [Support](https://wordpress.org/support/plugin/cozzetto-toctou-guard/)

## Description

Cozzetto’s TOCTOU Guard protects the site against a class of TOCTOU
 (time-of-check/
time-of-use) attacks and against accidental double execution.

When several identical POST requests arrive at the same moment — from a user
 double-
clicking, or from an attack firing many twin requests — the first request wins and
the others are rejected. The decision is made atomically by the database through
a unique key, so the race that a TOCTOU attack relies on does not exist.

Problems it avoids: duplicate orders, duplicate sign-ups, double votes, a
 coupon
used twice.

Email alerts: when a block is triggered, the site administrator receives an
 immediate
email (at most one per IP per hour, to avoid flooding the mailbox). A periodic report(
daily, weekly or monthly) lists the blocked IP addresses with full details. A button
lets you send the report on demand.

Optional IP geolocation: you can enable geolocation of blocked IP addresses
 (off
by default). See “External services” below.

Lightweight: two small tables, no external library, no paid service. Designed
 not
to break legitimate traffic (different submissions have different content and always
pass; on an internal error the request is allowed through).

### External services

This plugin can optionally use the geolocation service ip-api.com.

The service is used ONLY when the “IP geolocation” option is enabled on the
 settings
screen. This option is OFF by default, so by default the plugin contacts no external
service at all.

When the option is enabled, and only when a request is blocked, the plugin
 sends
the blocked visitor’s IP address to ip-api.com in order to obtain the country, city
and network provider of that IP. This information is then shown in the administrator’s
alert email and in the periodic report. The result is cached for up to 12 hours 
per IP to limit the number of calls. No data is sent while the option is disabled.

Service provider: ip-api.com (endpoint http://ip-api.com/json/).
 Terms of use and
privacy notice: https://ip-api.com/docs/legal

## Installation

 1. Upload the `cozzetto-toctou-guard` folder to `/wp-content/plugins/`, or
     install
    the zip from the Plugins screen.
 2. Activate the plugin.
 3. Go to Settings -> Cozzetto’s TOCTOU Guard to turn protection on or off, set
     the
    block window in seconds, enable email alerts, choose the report frequency and, 
    if you want it, enable IP geolocation.

## FAQ

### Can it block a normal user?

No. Two different submissions have different content, so they pass. Only the
 identical
copy arriving within a few seconds is rejected.

### Who receives the email alerts?

The site administrator address by default. You can set a different address on
 the
settings screen.

### Does the plugin contact any external service?

Only if you turn on the optional IP geolocation. It is off by default. See the
 “
External services” section above.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Cozzetto’s TOCTOU Guard” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ carlocozzetto ](https://profiles.wordpress.org/carlocozzetto/)

[Translate “Cozzetto’s TOCTOU Guard” into your language.](https://translate.wordpress.org/projects/wp-plugins/cozzetto-toctou-guard)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/cozzetto-toctou-guard/),
check out the [SVN repository](https://plugins.svn.wordpress.org/cozzetto-toctou-guard/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/cozzetto-toctou-guard/)
by [RSS](https://plugins.trac.wordpress.org/log/cozzetto-toctou-guard/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 2.0.3

 * Author set to the WordPress.org account (carlocozzetto); brand on Author URI.

#### 2.0.2

 * Top-level admin menu (own entry with a shield icon) instead of a Settings
    submenu.
 * The settings screen now shows the log of the latest blocks (date, IP,
    location,
   page, user).

#### 2.0.1

 * “Tested up to” set to the current WordPress release (7.1).

#### 2.0.0

 * Renamed to “Cozzetto’s TOCTOU Guard” (slug cozzetto-toctou-guard) and
    reprefixed
   all internal names, functions, options, tables and hooks.
 * IP geolocation via ip-api.com is now an opt-in option, OFF by default, and is
   
   documented under “External services”.
 * Settings screen updated accordingly.

#### 1.1.3

 * Minimum WordPress set to a current release.

#### 1.1.2

 * Minimum WordPress raised to 6.2 (required by the %i identifier placeholder and
   
   wp_date). Passes Plugin Check with no errors.

#### 1.1.1

 * Code cleanup to pass Plugin Check (prepared identifiers, input sanitizing,
    wp_parse_url).
   English readme.

#### 1.1.0

 * Immediate email alert to the administrator when a block is triggered (one
    email
   per IP per hour, to avoid flooding the mailbox).
 * Periodic report (daily / weekly / monthly) listing the blocked IP addresses
    
   with full details. “Send report now” button.

#### 1.0.0

 * First release: atomic TOCTOU / double-submit protection on front-end POST
    requests,
   settings page, automatic cleanup.

## Meta

 *  Version **2.0.3**
 *  Last updated **10 hours ago**
 *  Active installations **Fewer than 10**
 *  WordPress version ** 6.2 or higher **
 *  Tested up to **7.1.5**
 *  PHP version ** 7.4 or higher **
 * Tag
 * [security](https://wordpress.org/plugins/tags/security/)
 *  [Advanced View](https://wordpress.org/plugins/cozzetto-toctou-guard/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/cozzetto-toctou-guard/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/cozzetto-toctou-guard/reviews/)

## Contributors

 *   [ carlocozzetto ](https://profiles.wordpress.org/carlocozzetto/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/cozzetto-toctou-guard/)