id: safety-01 original_id: P.UNS.SAS.01 level: P impact: CRITICAL clippy: panic_in_result_fn Be Aware of Memory Safety Issues from Panics Summary Panics in unsafe code can leave data structures in an
阅读全文
Prefer pointer::cast Over `as` for Pointer Casting
id: ptr-06 original_id: G.UNS.PTR.03 level: G impact: LOW clippy: ptr_as_ptr Prefer pointer::cast Over as for Pointer Casting Summary Use the cast() method instead of as for pointer type conversions.
阅读全文
Do Not Let String/Vec Auto-Drop Other Process's Memory
id: mem-03 original_id: P.UNS.MEM.03 level: P impact: CRITICAL Do Not Let String/Vec Auto-Drop Other Process's Memory Summary Never create String, Vec, or Box from memory allocated outside Rust's allo
阅读全文
Validate Non-Robust External Values
id: ffi-15 original_id: P.UNS.FFI.15 level: P impact: HIGH Validate Non-Robust External Values Summary Data received from external sources (FFI, files, network) may be invalid. Validate before using i
阅读全文
Separate Data and Code When Passing Rust Closures to C
id: ffi-16 original_id: P.UNS.FFI.16 level: P impact: HIGH Separate Data and Code When Passing Rust Closures to C Summary C callbacks are function pointers without captured state. To pass Rust closure
阅读全文
Avoid Passing Strings Directly to C from Public Rust API
id: ffi-01 original_id: P.UNS.FFI.01 level: P impact: HIGH Avoid Passing Strings Directly to C from Public Rust API Summary Use CString and CStr for string handling at FFI boundaries. Never pass Rust
阅读全文
Consider Safety When Manually Implementing Auto Traits
id: safety-05 original_id: P.UNS.SAS.05 level: P impact: CRITICAL clippy: non_send_fields_in_send_ty Consider Safety When Manually Implementing Auto Traits Summary When manually implementing Send or S
阅读全文
Avoid Passing Trait Objects to C Interfaces
id: ffi-18 original_id: P.UNS.FFI.18 level: P impact: HIGH Avoid Passing Trait Objects to C Interfaces Summary Trait objects (dyn Trait) have Rust-specific layout (fat pointers with vtable) that is no
阅读全文
Do Not Create Aliases for Types/Methods Named "Unsafe"
id: general-03 original_id: G.UNS.01 level: G impact: MEDIUM Do Not Create Aliases for Types/Methods Named "Unsafe" Summary Do not create type aliases, re-exports, or wrapper methods that hide the "un
阅读全文
Unsafe Checker - Section Definitions
Unsafe Checker - Section Definitions Section Overview #SectionPrefixLevelCountImpact 1General Principlesgeneral-CRITICAL3Foundational unsafe usage guidance 2Safety Abstractionsafety-CRITICAL11Building
阅读全文