Introducing Function-Level Reachability for Rust
Socket launches build-aware, function-level reachability for Rust, tracing execution paths through dependencies and generated code to vulnerable functions.
- Jeppe Fredsgaard Blaabjerg

Today, we're announcing function-level reachability analysis for Rust, powered by a new whole-program analysis engine engineered around the complexities of the Rust language.
Socket can now trace execution paths from application code through transitive dependencies, compiler-generated code, and the Rust standard library, down to individual vulnerable functions. Security teams can pinpoint which vulnerabilities are reachable in their applications, with call paths that show developers exactly how execution can reach the vulnerable code.
Socket's analysis is build-aware, accounting for the project's selected Rust toolchain, enabled Cargo features, and target platform. It executes build scripts, expands procedural macros, and follows execution through traits, closures, asynchronous tasks, and even across foreign code boundaries.
In validation against real executions of Rust test suites, Socket identified 99.6% of observed functions and 99.6% of observed function calls. We've also extensively tested the engine across some of the Rust ecosystem's most prominent open source projects, including Cargo, ripgrep, Helix, Nushell, Alacritty, Typst, and Zellij.
The new analysis is already available to Socket customers using full application reachability for Rust, with no configuration changes required.

One Line of Code Can Change Vulnerability Reachability
#Consider CVE-2026-25727, a stack exhaustion vulnerability in the popular time crate that can cause a denial of service when parsing RFC 2822 dates.
To demonstrate the precision of Socket's analysis, we built a small web service using axum that accepts JSON events containing timestamps:
#[derive(Deserialize)]
struct Event {
name: String,
#[serde(with = "time::serde::rfc2822")] // twin: time::serde::rfc3339
sent_at: OffsetDateTime,
}
async fn ingest(Json(event): Json<Event>) -> String {
format!("{} at {}", event.name, event.sent_at.unix_timestamp())
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/events", post(ingest));
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}The application never explicitly calls a parsing function in time. The vulnerable parser is reached through code generated by #[derive(Deserialize)], which deserializes the incoming JSON and parses the timestamp.
Socket identifies the vulnerability as reachable and surfaces the call path in the dashboard, tracing execution through generated deserialization code, serde_json, serde_path_to_error, and the Rust standard library into the vulnerable RFC 2822 parser.

Now change the timestamp format to RFC 3339:
#[serde(with = "time::serde::rfc3339")]
Socket determines that the vulnerability is not reachable in this version of the application. Both applications:
- Depend on the exact same vulnerable crate version.
- Invoke the same public parsing API.
- Differ by a single line of code.
- Have entirely different vulnerability reachability results.
Both eventually call OffsetDateTime::parse, but only the first application reaches the RFC 2822 parser containing the vulnerable code.

Build-Aware Analysis of the Entire Rust Application
#Socket constructs a whole-program call graph spanning application code, every dependency, and the Rust standard library. While many SCA tools limit Rust analysis to dependency graphs or first-party source code, Socket follows execution across crate boundaries and analyzes the code that the project's enabled Cargo features and target platform actually compile.
The shipped application, its tests, and its build scripts are analyzed as separate programs.
Our analysis follows the mechanisms Rust uses to determine which code executes, including:
- Trait dispatch: Resolving which implementations can actually be invoked based on the types flowing through the program.
- Closures and trait objects: Following callbacks passed into libraries and invoked elsewhere in the dependency graph.
- Implicit function calls: Tracking calls introduced by operators,
?,forloops, formatting, and automatic cleanup throughDrop. - Asynchronous execution and threads: Connecting call paths across task schedulers, including work handed off through
tokio::spawn. - Standard library callbacks: Following execution through standard library implementations that call back into application or dependency code.
Generated Code Is Essential to Rust Reachability Analysis
#Rust's procedural macros can generate entire functions, introducing calls into dependencies that never appear in the original source. Socket runs build scripts and expands procedural macros to capture these execution paths.
To quantify the importance of generated code for reachability analysis, we analyzed popular open source Rust applications twice, with and without build scripts and procedural macro expansion, and compared the dependency functions identified as reachable.
Using a more permissive analysis that tolerated type errors, we obtained comparable results for 43 applications.
Omitting generated code caused the analysis to miss a median of 21% of reachable dependency functions. Nineteen applications lost at least a quarter of their reachable dependency functions, and four had no reachable dependency functions identified at all.

We observed several examples of this across open source Rust projects:
- zoxide: The program depends on
Cmd::parse(), a function that exists only in code generated by a derive macro. - mini-redis: The
#[tokio::main]attribute generates the runtime initialization and entry point needed to execute the asynchronous application. - hyperfine: Its JSON export functionality passes through code generated by
#[derive(Serialize)]intoserde_json, creating a call path that is invisible without macro expansion.
Engineering a Whole-Program Analyzer for Rust
#One of our primary engineering goals was to deliver precise Rust reachability analysis without requiring customers to change their Rust toolchains.
Many academic Rust static analysis tools, including Rupta and Rudra, build on the compiler's internal APIs, which typically tie the analysis to a specific nightly compiler release. Socket needs to analyze customer projects across a wide range of Rust releases and build configurations.
We initially explored a compiler-based approach before moving to rust-analyzer. Adapting its architecture from interactive editor tooling to whole-program security analysis required substantial engineering work. We built our own lowering of its source-level representation, developed standard library models checked against Rust releases from 1.74 through 1.100, and made more than 30 fixes to type inference, trait solving, and macro handling.
Some of the engineering challenges we addressed include:
- Compiler-accurate method resolution: The popular
itertoolscrate and Rust's standard library both provide aninterspersemethod, but the standard library implementation is experimental and requires nightly Rust. We reimplemented the compiler's method selection rules so the call graph follows the implementation that actually executes. - Version-specific standard library analysis: We adapted rust-analyzer to load the standard library as each supported Rust release builds it, including the code underlying
HashMapin releases before Rust 1.82. Standard library implementations such asHashMapcan call back into application code, making them essential to constructing complete call paths. We also accounted for differences in macro and formatting implementations across Rust releases. - Per-crate trait resolution: Different crates can see different trait implementations. We changed how rust-analyzer caches trait resolution results, scoping them per crate in accordance with the compiler's behavior so results are independent of analysis order.
- Memory modeling for unsafe Rust: The analysis uses a memory model based on MiniRust to track memory flows through raw pointers and
unsafecode in dependencies and the standard library. - Execution across foreign code boundaries: Our analysis connects callbacks passed to C code and asynchronous wake-ups driven by operating system event queues such as
epollandkevent, preserving call paths across native libraries and asynchronous runtimes.
Validating Static Analysis Against Real Executions
#We validated our Rust reachability engine by running the test suites of published crates, including regex, clap, serde_json, rayon, and futures, recording every function call and comparing the observed execution paths against our static analysis results.
Socket identified:
- 99.6% of the 39,591 functions executed during testing.
- 99.6% of the 79,163 observed calls between functions.

These results measure the analyzer's recall against actual runtime behavior, quantifying its ability to identify functions and call relationships that we know occurred during execution.
We also thoroughly tested the engine across major open source Rust applications built from source, including Cargo, ripgrep, Helix, Nushell, Alacritty, Typst, and Zellij, exercising a broad range of language features, dependency structures, and build configurations.
Function-Level Reachability for Rust Is Available Now
#Socket's new function-level analysis is automatically available to customers already using full application reachability for Rust, with no configuration changes required.
The analysis supports Rust 1.74 and newer, runs with your project's existing toolchain, and automatically installs the rust-src component if needed. It requires a buildable project but no prior compilation, special compiler plugin, or custom toolchain. Additional Cargo build flags can be passed through SOCKET_REACH_CARGO_BUILD_OPTS.
Get started with Socket's Rust and Cargo reachability documentation.





