安全软件
点击放大

A TOCTOU (time-of-check-to-time-of-use) research and education toolkit. TOCTOU
bugs happen when code checks something about a file — that it exists, that it's
owned by the right user, that it's safe to open — and then, some time later, acts
on that same path as if the check still holds. If an attacker can swap the file
in the gap between the check and the use (usually with a symlink), the check
that was meant to protect the operation ends up protecting nothing. This repo
has and patched example programs, a CLI that actually races them to
measure how exploitable each pattern is, a static analyzer that catches the
pattern by reading source instead of running it, and a demo site that ties the
three together.
samples/ — six small Python programs, three /patched
pairs, one per classic TOCTOU pattern: check-then-open, insecure temp file
creation, and a pri race. Every script is self-contained, sandboxes
itself to a local ./sandbox/ directory it creates, and refuses to touch
anything outside it.
exploiter/ — a CLI race harness. It spawns a
sample repeatedly and races it with attacker threads trying to land a symlink
swap inside the check-to-use window, then reports how often the race actually
lands. exploiter runs the same procedure against a /patched
pair side by side so you can see the hit rate drop to zero.
scanner/ — a static analyzer built on Python's ast module.
It walks source files looking for a check call (os.access, os.path.exists,os.stat, ...) followed by a use call (open, os.remove, shutil.move, ...)
on the same within the same function, without a reassignment in
between. No execution, no sandbox needed — it just reads the code.
docs/ — a static demo site (plain HTML/CSS/JS, no build step)
that explains TOCTOU, runs an illustrati simulation, and renders
real captured output from both the exploiter and the scanner.
E here is stdlib-only Python 3 — no dependencies to install.
Race a sample:
Compare a /patched pair:
Scan the samples for the pattern statically:
Both tools also work as python3 exploiter/cli.py ... / python3 scanner/cli.py ...
if you'd rather not rely on the shebang. See each subfolder's README for the
full command reference and how the detection actually works.
E here operates only on the sample programs in this repo, inside a
sandbox directory those scripts create and manage themselves — the exploiter
and the samples both refuse to touch a path outside that sandbox. This project
exists to teach how TOCTOU bugs work and how to catch them, not as a tool for
attacking anything else.
Do not point any of this at a system, file, or process you don't own or don't
ha authorization to test. That's true even if you tweak the code to
target a different path — the sandboxing is a safety rail, not a permission
system, and it's on you to stay inside the bounds you're actually allowed to
touch.
MIT — see LICENSE.
开发语言:Python
Star 数:32
该项目属于安全软件方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕TOCTOU race condition research toolkit: vulnerable/patched samples, a CLI race harness, an AST-based scanner, and a live demo展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | race-condition-exploiter - TOCTOU race condition research toolkit: vulnerable |
| 所属分类 | 安全软件 |
| 发布作者 | admin |
| 发布时间 | 2026-10-05 22:49:44 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 449 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |