TL;DR: TOCTOU attacks exploit the gap between time of check and time of use, so scanners, admission gates, and userspace guards can validate a safe snapshot while the resource changes underneath them, according to AccuKnox. Runtime enforcement at the syscall, using eBPF and Linux Security Module hooks, collapses that window and is the control that actually holds.
NHIMG editorial — based on content published by AccuKnox: TOCTOU Attacks Beat the Scanner by Design and Why Runtime Enforcement Stops Them
Questions worth separating out
Q: What breaks when a security check and the real file use happen at different times?
A: The check can still be correct and the control can still fail.
Q: Why do scanners and admission controllers miss TOCTOU attacks?
A: They evaluate a snapshot.
Q: How should teams reduce TOCTOU risk in privileged workflows?
A: Prioritise runtime enforcement for any workflow that resolves a path and then acts on it, especially in setuid code, CI jobs, container mounts, and file-handling automation.
Practitioner guidance
- Enforce controls at the syscall boundary Move policy decisions to file_open, bprm_check_security, and related kernel hooks so the resolved object is checked at use time, not in a preflight scanner.
- Audit privileged code for split-check patterns Find any access-then-open, stat-then-write, or validate-then-execute workflow in setuid programs, scripts, and automation jobs, then remove the time gap.
- Restrict writable substitution paths Lock down shared volumes, CI workspaces, and other mutable paths that let an attacker redirect a trusted filename to a different object.
What's in the full article
AccuKnox's full article covers the operational detail this post intentionally leaves for the source:
- How the eBPF and BPF-LSM hooks are used to enforce policy at the kernel boundary
- The specific file-open, execute, and symlink hooks that matter for TOCTOU prevention
- A comparison table showing scanner, admission, and runtime enforcement decisions
- Hands-on walkthrough content for KubeArmor deployment across Kubernetes, VMs, and bare metal
👉 Read AccuKnox's analysis of TOCTOU attacks and runtime enforcement →
TOCTOU attacks and runtime enforcement: are your controls keeping up?
Explore further
TOCTOU is really an authorisation timing problem, not a detection problem. The article is correct that scanners and admission checks can only speak for the object they saw at a point in time. That is a poor fit for privileged workflows where the object can change before use. For IAM and PAM teams, the deeper lesson is that the control must bind to the object at the moment of execution, not to the request that named it.
A question worth separating out:
Q: What is the difference between time-of-check and time-of-use enforcement?
A: Time-of-check enforcement approves a resource before execution, while time-of-use enforcement evaluates the resolved object at the moment the operation actually runs. The first can be bypassed by substitution, the second closes that window. In mutable environments, that difference determines whether a check is advisory or binding.
👉 Read our full editorial: TOCTOU attacks bypass scanners by design, not by chance