offensive-toctou

offensive-toctou is a skill for Claude Code, Codex from SnailSploit/Claude-Red. It costs 202 tokens per session (3,358 once invoked), scanned C, original, MIT.

A methodology for finding and demonstrating TOCTOU race conditions, where a program checks something and uses it later after it may have changed.

In plain words
What is it for?
Use it to investigate race conditions across filesystems, kernels, binaries, web requests, and containers, and to understand safer atomic handling.
Why use it?
It helps security testers identify cases where an attacker can alter a file, path, request, or other resource between the check and the action.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to investigate race conditions across filesystems, kernels, binaries, web requests, and containers, and to understand safer atomic handling.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/snailsploit/claude-red/offensive-toctou
About the project

claude-red is a library of structured skills that give Claude specialized offensive-security methods for areas such as web vulnerabilities, shellcode, exploit development, and identity systems. It is intended for authorized red-team work, bug-bounty triage, security research, CTF preparation, and operator training. Its catalogue contains the project's skills for loading these security specializations into Claude.

SnailSploit/Claude-Red · 3,040 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add SnailSploit/Claude-Red --skill offensive-toctou
Clone the repo
git clone --depth 1 https://github.com/SnailSploit/Claude-Red

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for offensive-toctou

README.md
[![agentmods](https://agentmods.dev/badge/skills/snailsploit/claude-red/offensive-toctou.svg)](https://agentmods.dev/skills/snailsploit/claude-red/offensive-toctou)
Your own site
<a href="https://agentmods.dev/skills/snailsploit/claude-red/offensive-toctou"><img src="https://agentmods.dev/badge/skills/snailsploit/claude-red/offensive-toctou.svg" alt="Measured on agentmods" height="20"></a>
Per session 202 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,358 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 4 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Privilege Escalation · line 30
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
  • high Privilege Escalation · line 77
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
  • high Privilege Escalation · line 167
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
  • high Privilege Escalation · line 46
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00202 $0.03358
Opus 5 $0.00101 $0.01679
Sonnet 5 $0.00040 $0.00672
Haiku 4.5 $0.00020 $0.00336

Measured 8d ago against content hash 8c7fb9790b18, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade C, and why

offensive-toctou scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reaches for credential fileshighPrivilege escalation

SSH keys, cloud credentials, git-credentials, .npmrc, /etc/shadow: reading these is how a config file becomes a credential leak.

Between `access` and `open`, an attacker replaces `path` with a symlink to `/etc/shadow`. The check sees an attacker-owned file; the use opens shadow as root.
Skills/exploit-dev/offensive-toctou/SKILL.md · 348 lines

How it starts

The opening of the file, as written. The whole thing — 348 lines — stays where its author put it; the contents beside it link to each section on GitHub.

TOCTOU — Time-of-Check / Time-of-Use Exploitation

A TOCTOU bug exists wherever code checks a property (file owner, path target, token validity, balance) and then acts on it as if the property still holds. Between check and use is a window — your job is to widen it and swap the underlying object.

Quick Workflow

  1. Identify the check (syscall, function, validation step) and the use (the privileged action)
  2. Confirm the check and use don't operate on the same kernel object (FD, inode, atomic snapshot)
  3. Build a primitive that swaps the object between check and use (symlink, mount, mv, parallel request)
  4. Widen the window with FUSE, slow filesystems, scheduler tricks, or single-packet HTTP/2
  5. Run a tight loop and confirm the post-use state corresponds to the swapped target

The Core Pattern

// Vulnerable
if (access(path, W_OK) == 0) {     // check  — resolves "path" now
    fd = open(path, O_WRONLY);     // use    — re-resolves "path" later
    write(fd, attacker_data, n);
}

Between access and open, an attacker replaces path with a symlink to /etc/shadow. The check sees an attacker-owned file; the use opens shadow as root.

The fix is always: operate on the kernel object, not the path. Use O_NOFOLLOW, openat with AT_SYMLINK_NOFOLLOW, fstat on the FD, etc.


Filesystem TOCTOU

Symlink Swap (Classic)

# Setup target — privileged binary that writes to user-supplied path after access() check
victim --output /tmp/.attacker/output

# Race loop
while true; do
  ln -sf /etc/passwd /tmp/.attacker/output 2>/dev/null
  ln -sf /tmp/.attacker/legit /tmp/.attacker/output 2>/dev/null
done &

# Run victim repeatedly
while true; do victim --output /tmp/.attacker/output; done

renameat2(RENAME_EXCHANGE) — Atomic Single-Frame Swap

syscall(SYS_renameat2, AT_FDCWD, "good", AT_FDCWD, "bad", RENAME_EXCHANGE);

RENAME_EXCHANGE swaps two paths atomically — combined with FUSE-paused dir lookups, this is a near-deterministic primitive on Linux ≥ 3.15.

Read the full file on GitHub · 348 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 348 lines · 202 tokens per session scan C 8c7fb9790b18

Subscribe to this mod's changes

offensive-toctou is a skill published in the GitHub repository SnailSploit/Claude-Red (3,040 stars, last pushed 8d ago), licensed MIT. It adds 202 tokens to every session and 3,358 once invoked, about $0.0010 per session on Opus 5. A static security scan graded it C with 1 finding (reaches for credential files). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

app-store-opportunity-research

Full-pipeline iOS App Store opportunity research. Discovers underserved niches, analyzes competitor gaps, estimates revenue, produces scored top-3 opportunity reports, and writes MVP PRDs — all through browser and web research. Use when the user wants to find profitable iOS app ideas, research App Store charts…

robertguss/claude-code-toolkit · 130 tokens

code-documenter

Expert documentation generator for coding projects. Analyzes codebases to create thorough, comprehensive documentation for developers and users. Supports incremental updates, multi-audience documentation, architecture decision records, and documentation health tracking. Works with any project type (APIs, CLIs, web…

robertguss/claude-code-toolkit · 87 tokens

paywall-pricing-optimizer

Design effective paywalls, structure subscription tiers, and optimize pricing for mobile apps. Covers monetization model selection, paywall screen design, pricing psychology, A/B testing strategy, and RevenueCat/StoreKit/Google Billing integration. Use when the user wants to monetize an app, design a paywall, choose…

robertguss/claude-code-toolkit · 143 tokens

ghost-writer

Produce first drafts that match a writer's authentic voice using their Voice DNA Document. Consumes DNA documents from writing-dna-discovery skill. Generates 2 meaningfully different drafts with headlines, confidence assessment, decision notes, and DNA refinement suggestions. Collaborative partner that evaluates…

robertguss/claude-code-toolkit · 77 tokens

app-store-listing-optimizer

Optimize iOS App Store and Google Play Store listings for maximum discoverability and conversion. Perform competitive keyword research, craft keyword-optimized titles/subtitles/descriptions, design screenshot sequences, and generate A/B test variants. Use when the user has a built app and needs to write or improve…

robertguss/claude-code-toolkit · 137 tokens

writing-orchestration

This skill should be used when orchestrating complex writing workflows with multiple phases. It provides two-agent orchestration patterns, the two-gate content readiness assessment, 10 baseline writing strategies, 20+ situational strategies, and quality checkpoints. Inspired by the Spiral Writing System.

robertguss/claude-code-toolkit · 60 tokens