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.
npx agentmods add skills/antgroup/adversarial-ai-coding-plugin/prevent-c-cpp-security-bugsnpx skills add antgroup/adversarial-ai-coding-plugin --skill prevent-c-cpp-security-bugsgit clone --depth 1 https://github.com/antgroup/adversarial-ai-coding-pluginWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00163 | $0.01304 |
| Opus 5 | $0.00081 | $0.00652 |
| Sonnet 5 | $0.00033 | $0.00261 |
| Haiku 4.5 | $0.00016 | $0.00130 |
Grade A, and why
prevent-c-cpp-security-bugs scanned grade A with 0 findings 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 2d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
C/C++ 安全代码生成规范
技能目标
在代码生成阶段消除安全漏洞,而非依赖事后审查。
代码生成是拦截安全风险成本最低的时机——一旦漏洞代码进入生产环境,修复代价急剧上升。因此,在生成代码前完成威胁识别和规范查阅,能从根本上降低安全风险。
工作流程
按以下三步执行安全代码生成。每一步都为后续步骤提供安全保障。
第一步:识别安全风险
分析用户需求,判断哪些风险类型适用于当前场景。识别出的每一个风险类型都需要处理。
| 风险类型 | 典型场景 | 参考文档 |
|---|---|---|
| 缓冲区溢出 | 对缓冲区读写时未对用户输入进行长度校验 | references/prevent-buffer-overflow.md |
| UAF | 指针指向的内存在 free/delete 后未置空,后续继续使用 | references/prevent-use-after-free.md |
| Double free | 同一块内存被释放两次,破坏堆管理器数据结构 | references/prevent-double-free.md |
| 格式化字符串漏洞 | 不受信任的输入直接作为格式化函数参数 | references/prevent-format-string-vuln.md |
| 整数溢出/下溢 | 计算结果超出整数范围,常触发缓冲区溢出 | references/prevent-integer-overflow-underflow.md |
| 符号扩展/类型转换 | 有符号数和无符号数混合运算出错 | references/prevent-signedness-bugs.md |
| 条件竞争 | 多线程/进程对共享资源访问未正确同步 | references/prevent-race-condition.md |
| 符号链接攻击 | TOCTOU 时间间隙中被替换文件路径 | references/prevent-race-condition.md |
| 危险函数调用 | 调用设计上存在缺陷的标准库函数 | references/prevent-potential-dangerous-function.md |
| QL 注入 | 拼接 SQL/HQL/NoSQL 查询语句 | references/prevent-ql-injection.md |
| 路径遍历 | 文件路径由用户输入拼接 | references/prevent-path-traversal.md |
| OS 命令执行 | 调用 system、popen、execve 执行系统命令 | references/prevent-os-command-execution.md |
第二步:查阅安全编码规范
对第一步中识别出的每一个风险类型,读取对应的参考文档。
参考文档详细说明了该类漏洞的根因、攻击模式和安全 API 用法,帮助理解如何在代码层面消除风险。
第三步:完成用户需求
在理解安全规范后,遵循以下核心原则生成代码:
- 默认安全:优先使用参数化查询、白名单校验、安全 API 等内置防护机制
- 零信任输入:来自 HTTP 请求、外部接口的数据一律视为不可信
- 失败安全:权限校验或输入验证失败时默认拒绝操作
- 边界防御:所有内存读写、字符串复制、数组遍历必须有显式长度约束
- 初始化与清理:变量诞生时有确定值,敏感数据消亡时彻底擦除
- 算数安全:内存分配、数组索引计算前确保不会溢出、截断或符号错误
- 编译器权限:不需要修改的数据、指针或对象状态用 const 禁止修改
- 并发安全:共享资源访问保证原子性或被正确同步
参考资源
参考文档
references/prevent-buffer-overflow.md— 缓冲区溢出防范详解references/prevent-use-after-free.md— 释放后使用(UAF)防范详解references/prevent-double-free.md— 二次释放防范详解references/prevent-format-string-vuln.md— 格式化字符串漏洞防范详解references/prevent-integer-overflow-underflow.md— 整数溢出/下溢防范详解references/prevent-signedness-bugs.md— 符号扩展/类型转换漏洞防范详解references/prevent-race-condition.md— 条件竞争防范详解references/prevent-potential-dangerous-function.md— 危险函数替换指南references/prevent-ql-injection.md— Query Language 注入防范详解references/prevent-path-traversal.md— 路径遍历防范详解references/prevent-os-command-execution.md— OS 命令执行防范详解
What ships with it
11 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- references/prevent-buffer-overflow.md 12 KB
- references/prevent-double-free.md 11 KB
- references/prevent-format-string-vuln.md 3.6 KB
- references/prevent-integer-overflow-underflow.md 5.9 KB
- references/prevent-os-command-execution.md 6.0 KB
- references/prevent-path-tranversal.md 7.5 KB
- references/prevent-potential-dangerous-function.md 6.0 KB
- references/prevent-ql-injection.md 9.1 KB
- references/prevent-race-condition.md 13 KB
- references/prevent-signedness-bugs.md 5.9 KB
- references/prevent-use-after-free.md 11 KB
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.
- 2d ago First seen · 77 lines · 163 tokens per session scan A c82a33948f18
prevent-c-cpp-security-bugs is a skill published in the GitHub repository antgroup/adversarial-ai-coding-plugin (7 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 163 tokens to every session and 1,304 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
spanify-buffers
Find and fix unsafe buffer operations in a C++ file by removing UNSAFETODO markers and replacing unsafe raw pointers/C-style functions with base::span and standard safe containers. Use when the user asks to fix unsafe buffer warnings or -Wunsafe-buffer-usage errors. Don't use for other types of memory safety bugs like…
jni-type-conversion
How to use @JniType annotations for ergonomic JNI. Relevant for Java files that use @NativeMethods or @CalledByNative.
platform-port
Guide porting FastLED to new MCU platforms, including int.h types, clockless drivers, SPI implementations, and platform detection. Use when adding support for a new microcontroller family or board.
qt-cpp-review
Invoke when the user asks to review, check, audit, or look over Qt6 C++ code — or suggest before committing. Runs deterministic linting (60+ rules) then six parallel deep- analysis agents covering model contracts, ownership, threading, API correctness, error handling, and performance. Reports only high-confidence…
cpp-pro
Writes, optimizes, and debugs C++ applications using modern C++20/23 features, template metaprogramming, and high-performance systems techniques. Use when building or refactoring C++ code requiring concepts, ranges, coroutines, SIMD optimization, or careful memory management — or when addressing performance…
ax-cpp-ai
Use when writing C++ code with axllm for named deployment profiles, generic provider clients, model selection, OpenAI-compatible calls, Responses, Gemini, Anthropic, routers, and balancers.