Skip to content
Back to search

RAPx

A static analysis tool for Rust programs. The guardrail for AI-generated Rust code.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/safer-rust/RAPx with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/safer-rust/RAPx'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/safer-rust--rapx/badge.svg)](/listings/safer-rust--rapx)

HTML

<a href="/listings/safer-rust--rapx"><img src="/api/listings/safer-rust--rapx/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Install the latest `nightly` toolchain, on which rapx is compiled. This just needs to be done once on your machine. If the toolchain exists, this will do nothing.

rustup toolchain install nightly --profile minimal --component rustc-dev,rust-src,llvm-tools-preview
cargo +nightly install rapx --git https://github.com/safer-rust/RAPx.git

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 284 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # <img src="https://raw.githubusercontent.com/safer-rust/RAPx/main/logo.png" width="50%">
  2. RAPx (Rust Analysis Platform with Extensions) [![license: MPL 2.0](https://img.shields.io/badge/license-MPL%202.0-brightgreen)](./LICENSE-MPL)[![docs.rs](https://img.shields.io/badge/docs-docs.rs-blue)](https://docs.rs/rapx) is an advanced static analysis platform for Rust. It provides an extensible framework for building and integrating powerful analysis capabilities that go beyond those available in the standard rustc compiler, empowering developers to reason about safety, robustness, and performance at a deeper level.
  3. RAPx is available on crates.io. [![crates.io](https://img.shields.io/badge/crates.io-latest-orange)](https://crates.io/crates/rapx)
  4. ## Features
  5. # ![logo](https://raw.githubusercontent.com/safer-rust/RAPx/main/feature.png)
  6. RAPx is structured into two layers: a core layer offering essential program analysis algorithms (e.g., alias and dataflow analysis), and an application layer implementing specific tasks such as bug detection. This separation of concerns promotes modular development and fosters collaboration between algorithm and application developers.
  7. The project is still under heavy development. For further details, please refer to the [RAPx-Book](https://safer-rust.github.io/RAPx-Book/).
  8. ## Quick Start
  9. Install the latest `nightly` toolchain, on which rapx is compiled. This just needs to be done once on your machine. If the toolchain exists,
  10. this will do nothing.
  11. ```shell
  12. rustup toolchain install nightly --profile minimal --component rustc-dev,rust-src,llvm-tools-preview
  13. cargo +nightly install rapx --git https://github.com/safer-rust/RAPx.git
  14. ```
  15. ## Usage
  16. Navigate to your Rust project folder containing a `Cargo.toml` file. Then run `rapx` by manually specifying the toolchain version according to the [toolchain override shorthand syntax](https://rust-lang.github.io/rustup/overrides.html#toolchain-override-shorthand).
  17. ```shell
  18. cargo +nightly rapx [rapx options] -- [cargo check options]
  19. ```
  20. or by setting up default toolchain to the required version.
  21. ```shell
  22. rustup default nightly
  23. ```
  24. Everything after `--` is forwarded verbatim to `cargo check`, so `--target` and other
  25. cargo flags work for cross-compiled or bare-metal (`#![no_std]`) crates:
  26. ```shell
  27. # verify a no_std kernel crate for a bare-metal target
  28. cargo rapx verify --crate ostd -- --target x86_64-unknown-none
  29. ```
  30. Here `ostd` is the kernel crate from [asterinas/asterinas](https://github.com/asterinas/asterinas/tree/main/ostd).
  31. Make sure the target is installed first (`rustup target add x86_64-unknown-none`).
  32. Check out supported options with `-help`:
  33. ```shell
  34. $ cargo rapx --help
  35. Usage: cargo rapx [OPTIONS] <COMMAND> [-- [CARGO_FLAGS]]
  36. Commands:
  37. analyze perform various analyses on the crate, e.g., alias analysis, callgraph generation
  38. check check potential vulnerabilities in the crate, e.g., use-after-free, memory leak
  39. opt detect code optimization opportunities
  40. verify verify annotated functions in the crate, e.g., identify #[rapx::verify] targets
  41. help Print this message or the help of the given subcommand(s)
  42. Options:
  43. --timeout <TIMEOUT> specify the timeout seconds in running rapx
  44. --test-crate <TEST_CRATE> specify the tested package in the workspace
  45. -h, --help Print help
  46. -V, --version Print version
  47. NOTE: multiple detections can be processed in single run by
  48. appending the options to the arguments. Like `cargo rapx check -f -m`
  49. will perform two kinds of detection in a row.
  50. Examples:
  51. 1. detect use-after-free and memory leak:
  52. cargo rapx check -f -m
  53. 2. detect optimization opportunities:
  54. cargo rapx opt
  55. 3. perform alias analysis:
  56. cargo rapx analyze alias
  57. 4. verify annotated functions:
  58. cargo rapx verify --prepare-targets
  59. ```
  60. ### `analyze` command
  61. ```
  62. Usage: cargo rapx analyze <COMMAND>
  63. Commands:
  64. alias alias analysis (meet-over-paths by default)
  65. adg API dependency graphs
  66. callgraph callgraph generation
  67. dataflow dataflow graphs
  68. heapowner analyze heap-owning types
  69. paths path-sensitive CFG paths
  70. range range analysis
  71. scan basic crate info
  72. mir print MIR
  73. dot-mir print MIR as DOT
  74. help Print this message or the help of the given subcommand(s)
  75. Options:
  76. -h, --help Print help
  77. ```
  78. ### `check` command
  79. ```
  80. Usage: cargo rapx check [OPTIONS]
  81. Options:
  82. -f, --uaf [<UAF>] detect use-after-free/double-free (optional level, default 1)
  83. -m, --mleak detect memory leakage
  84. -h, --help Print help
  85. ```
  86. ### `opt` command
  87. ```
  88. Usage: cargo rapx opt
  89. ```
  90. ### `verify` command
  91. The `verify` command provides a contract-based verification pipeline for functions annotated with `#[rapx::verify]`. It uses path-sensitive backward/forward analysis and Z3-based SMT solving to prove safety properties.
  92. ```
  93. Usage: cargo rapx verify [OPTIONS]
  94. Options:
  95. --prepare-targets identify #[rapx::verify] functions and list their safety contracts
  96. --postfix-repeat <N|auto> number of extra SCC postfix repetitions during path enumeration; `auto` enables automatic loop-depth detection (default auto)
  97. --mode <MODE> verification mode: scan, targeted (default scan)
  98. --no-invariant-target skip struct invariant checks and derive safety via constructor-mutator-method chains
  99. --expand-ctor <MODE> constructor expansion: true, false, default (default: default)
  100. --debug-contracts print expanded contract assertions for debug purposes
  101. --crate <CRATE> filter verification targets to a specific crate (Rust crate name or Cargo package name)
  102. --module <MODULE_PATH> filter verification targets to a specific module path within the crate
  103. -h, --help Print help
  104. ```
  105. Verification modes:
  106. - `scan` — auto-detect: verify all functions with unsafe callees or struct invariants
  107. - `targeted` — only verify functions annotated with `#[rapx::verify]`
  108. Options:
  109. - `--no-invariant-target` — works with both modes; skips struct invariant checks and instead derives safety requirements automatically from constructor-mutator-method chains
  110. - `--expand-ctor` — `true` forces constructor MIR when available; `false` never uses constructor MIR and uses a summary when available; `default` usually uses invariants and otherwise uses available MIR. `--no-invariant-target` makes `default` behave like `true`.
  111. **Filtering targets:** `--crate` and `--module` work in any mode and can be combined. When analyzing standard-library workspaces or sub-workspaces:
  112. ```bash
  113. # Verify a specific module (single crate or workspace)
  114. cargo rapx verify --module my_mod::sub
  115. # Verify a specific crate in a workspace
  116. cargo rapx verify --crate my_crate
  117. # Combine both for precise targeting (e.g. standard library)
  118. cargo rapx verify --crate core --module ptr::NonNull
  119. cargo rapx verify --crate std --module collections::vec
  120. ```
  121. When `--module` is used without `--crate`, a `crate_name::module` prefix is also accepted for backward compatibility (e.g. `--module core::ptr` strips the `core::` prefix automatically).
  122. ```rust
  123. #![feature(register_tool)]
  124. #![register_tool(rapx)]
  125. #[rapx::verify]
  126. fn init_buffer(buf: *mut u32, len: usize) {
  127. unsafe {
  128. // rapx checks: NonNull(buf), Align(buf, u32), InBound(buf, len)
  129. core::ptr::write(buf.add(len - 1), 0);
  130. }
  131. }
  132. #[rapx::requires(NonNull(_ptr))]
  133. unsafe fn custom_ptr_op(_ptr: *const i32) -> i32 {
  134. unsafe { *_ptr }
  135. }
  136. ```
  137. Struct fields holding raw pointers can carry `#[rapx::invariant(...)]` annotations. Methods assume the invariants on entry (constructors re-establish them at return), which lets RAPx verify patterns like linked-list `Drop` implementations where the pointer's provenance lives in the type's invariant rather than in the function body:
  138. ```rust
  139. // Fields that may be null use the `any(...)` combinator (logical OR;
  140. // commas inside a parenthesised group mean logical AND): every property
  141. // holds whenever the pointer is non-null and vacuously when it is null.
  142. #[rapx::invariant(any(Null(next), (Align(next, Node), ValidPtr(next, Node, 1), Allocated(next, Node, 1), Typed(next, Node), Owning(next))))]
  143. struct Node {
  144. value: i32,
  145. prev: *mut Node,
  146. next: *mut Node,
  147. }
  148. // Option<NonNull<T>> fields express the same conditionality with
  149. // `unwrap_some()`: the property constrains the Some payload only.
  150. #[rapx::invariant(Align(head.unwrap_some(), Node))]
  151. #[rapx::invariant(Allocated(head.unwrap_some(), Node, 1))]
  152. #[rapx::invariant(Typed(head.unwrap_some(), Node))]
  153. #[rapx::invariant(Owning(head.unwrap_some()))]
  154. struct List {
  155. head: Option<core::ptr::NonNull<Node>>,
  156. }
  157. ```
  158. See `tests/verify_cases/linked_list_rawptr` and `tests/verify_cases/linked_list_nonnull` for complete examples proved SOUND end-to-end (including `Box::from_raw` in `Drop`).
  159. Safety properties include: `Align`, `NonNull`, `Allocated`, `InBound`, `Init`, `ValidPtr`, `Deref`, `Ptr2Ref`, and more. See the [RAPx-Book](https://safer-rust.github.io/RAPx-Book/) for the full list.
  160. ### Verification Property Support Checklist
  161. This checklist maps RAPx's contract verification to the [Primitive Safety Properties](https://github.com/safer-rust/safety-tags/blob/main/primitive-sp.md) defined in `safer-rust/safety-tags`.
  162. > **Legend**: ✅ = full Z3-based SMT verification (produces SOUND/UNSOUND verdicts) — = not yet verified (parsed but no SMT lowering)
  163. | safety-tag | Example | Supported |
  164. |----------------|-----------------------------|:---------:|
  165. | `Align` | Align(p, T) | ✅ |
  166. | `Size` | Size(T, c) | ✅ |
  167. | `NoPadding` | !Padding(T) | ✅ |
  168. | `NonNull` | !Null(p) | ✅ |
  169. | `Allocated` | Allocated(p, T, len, A) | ✅ |
  170. | `InBound` | InBound(p, T, len) | ✅ |
  171. | `NonOverlap` | !Overlap(dst, src, T, len) | ✅ |
  172. | `ValidNum` | ValidNum(exp, vrange) | ✅ |
  173. | `ValidString` | ValidString(arange) | ✅ |
  174. | `ValidCStr` | ValidCStr(p, len) | ✅ |
  175. | `Init` | Init(p, T, len) | ✅ |
  176. | `Unwrap` | Unwrap(x, T) | — |
  177. | `Typed` | Typed(p, T) | ✅ |
  178. | `ValidTransmute` \*† | ValidTransmute(T, U) | ✅ |
  179. | `SplitTransmute` \*† | SplitTransmute(T, U) | ✅ |
  180. | `Owning` | Owning(p) | ✅ |
  181. | `Alias` | Alias(p1, p2) | ✅ |
  182. | `Alive` | Alive(p, l) | ✅ |
  183. | `Pinned` | Pinned(p, l) | — |
  184. | `NonVolatile` | !Volatile(p, T, len) | — |
  185. | `Opened` | Opened(fd) | — |
  186. | `Trait` | Trait(T, trait) | ✅ |
  187. | `Unreachable` | !Reachable() | — |
  188. | `ValidPtr` \* | ValidPtr(p, T, len) | ✅ |
  189. | `Deref` \* | Deref(p, T, len) | ✅ |
  190. | `Ptr2Ref` \* | Ptr2Ref(p, T) | ✅ |
  191. | `Layout` \* | Layout(p, layout) | ✅ |
  192. > \* Compound safety properties are composed from primitive SPs: `Deref(p, T, len) = Allocated(p, T, len) && InBound(p, T, len)`, `ValidPtr(p, T, len) = Size(T, 0) || Deref(p, T, len)`, `Ptr2Ref(p, T) = Init(p, T, 1) && Align(p, T) && Alias(p)`, and `Layout(p, l) = Allocated(p)`.
  193. >
  194. > \*† `ValidTransmute` and `SplitTransmute` are specializations of `Typed` for transmute operations: `ValidTransmute(T, U)` checks that a `T`-typed value is a valid bit-pattern of `U`, while `SplitTransmute` checks that every `size_of(U)`-byte contiguous chunk of a `T`-typed value is a valid `U` bit-pattern.
  195. RAPx ships with a curated set of `std` library safety contracts (`std-contracts.json`) that annotate standard library functions with property tags. This enables contract-based verification for common `std`/`core` APIs without requiring user annotations.
  196. Beyond the built-in tags, users can define their own named contracts inside their crate with the `pred!` macro (from `rapx_macros`) — a boolean combination of the primitive safety properties — and reference them from `#[rapx::requires(MyTag(...))]` without rebuilding `rapx`:
  197. ```rust
  198. use rapx_macros::pred;
  199. // Name(params) { body } — params carry a role: Ptr | Ty | Expr | Ident.
  200. pred!(Readable(p: Ptr, T: Ty, n: Expr) { NonNull(p) && Align(p, T) && Allocated(p, T, n) && Init(p, T, n) });
  201. #[rapx::requires(Readable(ptr, u8, len))]
  202. unsafe fn read_byte(ptr: *const u8, len: usize) -> u8 { unsafe { *ptr } }
  203. ```
  204. The verifier is exercised against real-world safe abstractions built on top of unsafe code — for example `core::slice`-style methods such as `split_at`, `as_chunks`/`as_rchunks`, `as_flattened`, `binary_search`, `partition_dedup`, and `get_disjoint_mut` — where RAPx proves that the internal unsafe operations cannot cause undefined behavior. Each SMT query is bounded by a per-query timeout so that undecidable nonlinear goals return `unknown` instead of hanging.
  205. ### Environment Variables (values are case insensitive)
  206. | var | default when absent | possible values | description |
  207. |-----------------|---------------------|---------------------|------------------------------|
  208. | `RAPX_LOG` | info | trace, debug, info, warn | verbosity of logging |
  209. | `RAPX_CLEAN` | true | true, false | run cargo clean before check |
  210. | `RAPX_RECURSIVE` | none | none, shallow, deep | scope of packages to check |
  211. | `RAPXFLAGS` | (unset) | CLI arguments | arguments passed to `rapx` binary directly |
  212. For `RAPX_RECURSIVE`:
  213. * `none`: check for current folder
  214. * `shallow`: check for current workspace members
  215. * `deep`: check for all workspaces from current folder
  216. NOTE: for `shallow` or `deep`, rapx will enter each member folder to do the check.
  217. If RAPx gets stuck after executing `cargo clean`, try manually downloading metadata dependencies by running `cargo metadata`.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.