Trail of Bits:Rust 安全与正确性规则提取
来源:trailofbits/skills(原始出处:https://github.com/trailofbits/skills);固定提交 e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff;提取日期:2026-11-12。
这是中文归纳和语义校正,不是原文逐字翻译,也不包含原 skill 的执行编排。原始文件可通过每条规则的链接查看;改写说明和许可见 README。
完整保留固定版本 manifest 中的 15 类、69 个检查项;ID 保留原前缀。以下是检查方向,不是仅凭关键词即可判缺陷的规则。需结合调用链、可达性、构建目标和上游误报排除条件验证。标注“总是检查”表示不做能力门控,并不表示一定存在问题。
规则目录:manifest.json(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/manifest.json);上游说明(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/README.md)。
unsafe-boundary
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
URAPI | 追踪安全 API 到 unsafe 操作的调用链;安全函数必须通过类型约束或运行时校验保证所有安全调用的健全性,不能只靠调用者遵守注释。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
TRANS | 核对 transmute/transmute_copy 的有效位模式、大小、布局、生命周期和别名约束;大小相同不足以证明安全。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
RAWPTR | 核对裸指针算术、读写和复制的分配范围、存活期、对齐及重叠要求;按具体 API 契约判断 one-past 等边界。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
PTRCAST | 核对指针转换后的来源、地址、元数据、对齐和解引用范围;单独出现 as、胖指针转瘦指针或指针整数往返不等于 UB。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
REPRC | 核对跨语言类型的表示、字段布局、枚举及平台差异;repr(C) 不会自动使内部所有字段 FFI 安全。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
ENUMUB | 反序列化、transmute 或 FFI 构造的 enum、bool、NonZero 和 niche 优化类型必须具有有效表示。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
SAFETYDOC | unsafe 块/impl 写明具体安全论证;unsafe fn 的 Safety 文档列出调用者必须满足的不变量;注释须与实现一致。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
DEBUGSAFETY | 不能把可能关闭的 debug_assert 当作 unsafe 唯一安全保障,release 中也必须满足前置条件。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/unsafe-boundary.md) |
memory-safety
启用条件:存在 unsafe。
| ID | 核查内容 | 原文 |
|---|---|---|
UNINITREAD | MaybeUninit::assume_init* 之前,每条可达路径都已初始化所需字段,并满足目标类型有效性。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/uninitialized-read-finder.md) |
SETLEN | Vec::set_len/from_raw_parts 宣称有效的所有元素都已初始化,len/capacity/分配来源一致。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/vec-set-len-uninit-finder.md) |
INVFREE | 向未初始化、带析构的槽位写入时,避免赋值触发旧垃圾值的 Drop;核对 ptr::write 等操作的适用契约。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/invalid-free-finder.md) |
UAF | 裸指针不能在原对象释放、重分配、移动导致地址失效后继续使用。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/use-after-free-finder.md) |
DFREE | ptr::read、from_raw、所有权移交不能让同一资源出现多个释放者。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/double-free-finder.md) |
BOF | 从安全代码流入 unchecked 访问的索引、偏移、长度必须有边界证明;已分配容量不等于已初始化长度。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/buffer-overflow-unsafe-finder.md) |
UNIONUB | 读取 union 字段时证明当前位模式对该字段有效,并维护引用别名、生命周期与析构约束。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/union-ub-finder.md) |
PANICUNWIND | unsafe 容器更新过程中发生 unwind 后,len、容量、初始化计数和已释放元素状态仍可安全清理。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/panic-unwind-unsafe-finder.md) |
concurrency-locking
启用条件:存在并发。
| ID | 核查内容 | 原文 |
|---|---|---|
DLOCK | 追踪 guard 实际存活期、临时值和重入调用,防止同一非重入锁重复加锁;结合 edition 判断临时值作用域。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
ABBA | 检查多把锁的获取顺序是否形成可同时到达的循环等待。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
CONDVAR | 条件变量的谓词更新受对应锁保护;用循环处理虚假唤醒并证明通知可达,不要求 notify 必须在持锁时调用。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
CHANSTARVE | 检查发送者、接收者、容量及关闭路径,避免互相等待、孤立端点和无法结束的接收循环。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
ONCEREENTRY | Once/OnceLock/OnceCell/LazyLock 的初始化不得直接或间接重入同一初始化对象。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
REENTRANT | 真正的 POSIX 信号处理函数只调用 async-signal-safe 操作;持锁回调须检查重入。普通 Tokio 信号接收任务不按信号处理器判定。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/clusters/concurrency-locking.md) |
concurrency-data-race
启用条件:存在并发。
| ID | 核查内容 | 原文 |
|---|---|---|
ATOMICRACE | load 后条件 store 不自动构成原子事务;检查是否需要 CAS、锁或明确单写者约束,同时核对内存序。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/atomic-race-finder.md) |
UNSAFESYNC | 手写 unsafe impl Send/Sync 须证明底层状态、外部句柄、泛型参数满足跨线程安全条件。 附加条件:存在 unsafe。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/unsafe-sync-impl-finder.md) |
SENDSYNCBOUND | 检查自定义 unsafe 线程桥接/类型擦除是否丢失 Send、Sync、存活期条件;编译器已拒绝的直接 spawn 用法不当作可运行缺陷。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/send-sync-bounds-finder.md) |
SHMRACE | 共享映射和跨进程内存需要符合平台契约的同步、访问和生命周期设计,不能假设本进程拥有独占可变访问。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/shared-memory-race-finder.md) |
STATICMUT | static mut 及其裸指针访问不得在缺少同步时并发读写,别名约束也须成立。 附加条件:存在 unsafe。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/static-mut-race-finder.md) |
panic-dos
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
RESEXHAUST | 外部输入驱动的分配、队列、CPU 循环、算法放大和并发任务需有合理预算/上限。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/resource-exhaustion-finder.md) |
UNWRAP | 追踪不可信输入到 unwrap/expect/unwrap_err 的可达失败路径,报告真实 panic 影响。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/unwrap-on-untrusted-finder.md) |
ARITHOFL | 核对整数溢出、截断、移位、除零和有符号最小值除以 -1;不能把所有 wrapping/saturating 操作都当成无 panic。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/arithmetic-overflow-finder.md) |
ASSERTREACH | 检查外部输入或实际业务状态能否到达 assert、panic、unreachable、todo、unimplemented,结合构建配置判断影响。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/assertion-reachable-finder.md) |
OOBIDX | 数组、Vec、slice 下标和范围运算需证明边界;区分 checked 访问和直接索引的失败行为。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/out-of-bounds-index-finder.md) |
STRSLICE | 字符串字节切片、截断和 split_at 的索引同时满足长度与 UTF-8 字符边界。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/str-slice-boundary-finder.md) |
REFCELLPANIC | 检查 RefCell 借用、回调、递归、析构重入导致的运行时借用冲突。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/refcell-borrow-panic-finder.md) |
recursion-dos
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
RECURSEDES | 不可信嵌套输入反序列化的递归深度需有上限;先核实库现有深度限制。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/recursive-deserialize-stack-overflow-finder.md) |
RECURSEFMT | 深层结构在 Debug/Display/Serialize 或日志路径上可能耗尽栈,即使解析阶段有保护也需复核。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/recursive-format-stack-overflow-finder.md) |
RECURSEDROP | 递归 Box/链表/树的隐式 Drop 可能栈溢出;深度可控或迭代销毁才可排除此风险。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/recursive-drop-stack-overflow-finder.md) |
error-handling
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
RESDISC | 检查被丢弃的 Result、.ok()、默认回退是否掩盖写入、发送、持久化等关键失败。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/result-discarded-finder.md) |
DROPPANIC | Drop 中避免可达 panic;展开期间再次 panic 可能终止进程,需检查清理路径。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/drop-panic-finder.md) |
LOSSYFROM | 窄化、符号变化或浮点转整数的转换必须满足数值语义;From 应无损、不可失败,必要时使用 TryFrom。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/lossy-from-into-finder.md) |
LOSSYSTR | 用于身份、路径、授权或键匹配的数据不得因有损编码转换而合并不同原始值;纯展示需单独判断。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/lossy-str-conversion-finder.md) |
BUFFLUSH | 重要缓冲输出显式处理 flush/into_inner 错误,不能把 Drop 的尽力刷新当作写入成功保证。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/bufwriter-unflushed-finder.md) |
logic-correctness
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
ORDEQHASH | 自定义 Eq、Ord、PartialOrd、Hash 满足一致性、对称/传递和总序契约;看语义而非仅看 derive/手写组合。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/ord-eq-hash-finder.md) |
TRAITADV | unsafe 代码不能无条件相信安全 trait 实现返回的长度、计数等;安全 trait 的违规实现不能使安全调用产生 UB。 附加条件:存在 unsafe。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/adversarial-trait-finder.md) |
CLOSUREPANIC | unsafe 状态变更中调用用户闭包时,闭包 panic 不能留下可重复释放或未初始化暴露等不一致状态。 附加条件:存在 unsafe。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/closure-panic-finder.md) |
FLOATEDGE | 检查 NaN、Inf、舍入、负零等如何影响范围、索引、授权比较和序列化。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/float-edge-finder.md) |
STRCMP | 身份和授权匹配采用协议要求的精确/规范化语义,避免错误的前后缀匹配或大小写处理不一致。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/string-comparison-finder.md) |
SERFIELDS | 手写 Serialize 的字段数、元素数和实际输出一致;核对 skip/可选字段及目标序列化格式。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/serialize-struct-mismatch-finder.md) |
NONDET | 需确定性的签名、哈希、持久化输出和状态复制不能依赖 HashMap/HashSet 随机迭代顺序。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/nondeterminism-finder.md) |
KEYMUT | 元素进入 Map/Set/Heap 后,不得通过内部可变性改变其参与 Hash/Eq/Ord 的键属性。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/collection-key-mutation-finder.md) |
ffi-cross-language
启用条件:存在 FFI。
| ID | 核查内容 | 原文 |
|---|---|---|
CSTRDANGLE | CString/CStr 的拥有者在外部函数实际使用指针的整个期间存活,包含异步保存和回调场景。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/cstring-dangling-finder.md) |
ABIMISMATCH | Rust 声明与 C 头文件/实际库的 ABI、参数、返回类型、整数宽度和目标平台一致。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/abi-mismatch-finder.md) |
REPRCPAD | 不能直接把 repr(C) 对象内存当作稳定序列化格式;核查 padding 未初始化字节泄露与布局差异。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/repr-c-padding-finder.md) |
OPAQUEPTR | 外部 opaque handle 的有效期、关闭、所有权转移和并发访问契约明确,关闭后不再使用。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/opaque-pointer-finder.md) |
FOREIGNDROP | 外部内存由匹配的分配器/释放函数释放;不可随意将外部分配变为 Box/Vec 的所有权。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/foreign-drop-finder.md) |
CLOSUREFFI | 外部回调的捕获对象持续存活、注销后才释放;明确 panic 和 ABI 策略,catch_unwind 不能捕获 abort。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/closure-ffi-finder.md) |
DYNFFI | Rust trait object 的布局不作为稳定 C ABI;跨边界使用明确句柄与函数表,保留必要元数据。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/dyn-trait-ffi-finder.md) |
layout-safety
启用条件:存在 packed 布局。
| ID | 核查内容 | 原文 |
|---|---|---|
PACKEDREF | 不能先构造未对齐字段引用再转换裸指针;使用合适的原始地址操作及 read_unaligned/write_unaligned。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/packed-field-ref-finder.md) |
async-runtime
启用条件:存在 async。
| ID | 核查内容 | 原文 |
|---|---|---|
ASYNCBLOCK | 检查同步 I/O、等待和长 CPU 工作是否阻塞 executor;spawn_blocking 的并发量、退出限制也要考虑。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/async-blocking-finder.md) |
CANCELSAFETY | 每个可能取消的 await 处检查部分读写、消息移交、状态更新和提交,保证恢复、回滚或可重试。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/cancel-safety-finder.md) |
SELECTBIAS | 检查 select 的优先级、饥饿与停止语义;默认轮询不自动有错,biased 也可能饿死后续分支。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/select-bias-finder.md) |
static-hygiene
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
CARGOLINT | 结合已有 CI/工作区 lint 检查实际缺失或降级的安全检查;未启用 pedantic 不是安全缺陷。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/cargo-lint-config-finder.md) |
MSRV | 代码、依赖、edition 和 feature 与声明的 rust-version 及实际工具链兼容。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/msrv-mismatch-finder.md) |
DEPRECAPI | 查明弃用/不稳定 API 的真实风险,尤其 mem::uninitialized;普通弃用不自动判高危。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/deprecated-api-finder.md) |
resource-handling
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
RAWFD | 区分 BorrowedFd/OwnedFd/RawFd 的借用与所有权,避免 from_raw_fd 重复接管、重复关闭及泄漏。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/raw-fd-lifecycle-finder.md) |
DROPSKIP | exit、forget、ManuallyDrop 跳过析构时,关键持久化/回滚/释放不能丢失;合法所有权转移不误报。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/destructor-skip-finder.md) |
input-os-safety
启用条件:存在文件系统 I/O。
| ID | 核查内容 | 原文 |
|---|---|---|
PATHJOIN | 外部绝对路径、..、符号链接或平台路径形式不能逃出预期目录;join 本身不做沙箱校验。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/path-traversal-join-finder.md) |
TOCTOU | 权限/目标检查和实际打开之间不能被替换,优先原子创建、已打开句柄的检查和相对目录句柄操作。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/toctou-finder.md) |
info-disclosure
启用条件:总是检查。
| ID | 核查内容 | 原文 |
|---|---|---|
PTREXPOSE | 运行时地址流入低信任日志/响应时评估信息泄露;本地受控调试输出不一律当作可利用漏洞。 | 来源(原始出处:https://github.com/trailofbits/skills/blob/e4dd0bb5b15535f7c5a0834187dffba6ac37e4ff/plugins/rust-review/prompts/general/pointer-exposure-finder.md) |
提取时的校正
PTRCAST:不采用“所有指针整数往返/胖转瘦都自动 UB”的绝对表述。按标准库 provenance、范围和有效访问契约判断,见 std::ptr。SELECTBIAS:不要求所有 select 一律加 biased;必须证明停止响应或公平性需求被违反。REPRCPAD:repr(C) 有 padding 不是缺陷;将对象内存直接输出且读到/泄露未初始化字节才是需要核查的具体路径。SAFETYDOC、CARGOLINT:缺文档/缺 lint 与已证实 UB 分开报告。- 本清单不沿用上游各检测器预设的固定严重度;按实际影响和置信度定级。