The Problem With Cloud-Based Dependency Scanners
Most modern software composition analysis tools check your dependency tree against a vulnerability database and flag every package with a known advisory. If your application includes a library that has a remote code execution vulnerability, the tool flags it red. The problem is that most flags are false alarms because your code never invokes the vulnerable function.
To solve this, modern security tooling uses reachability analysis. It builds a call graph from your entry points through your internal modules down to the third-party dependency. If the call graph contains a valid path from your application logic to the vulnerable function, the finding is reachable. If no path exists, the finding is unreachable.
Many commercial tools perform this analysis by uploading your source code or an abstract syntax tree representation to a cloud backend. For teams working on proprietary codebases, financial systems, or health data, sending raw source code or symbol tables to a third-party API introduces compliance friction and security risks. You are trusting an external vendor with your intellectual property just to find out if a function is called.
Running reachability analysis entirely on your local machine or inside your own ephemeral CI runner eliminates this risk. This post walks through how reachability analysis works under the hood, how to construct a call graph for a typical project, and how to query that graph locally.
How Reachability Analysis Works Under the Hood
Reachability analysis relies on static program analysis. It does not execute your code. Instead, it reads your source files, parses them into abstract syntax trees, resolves imports and package boundaries, and builds a directed graph where nodes represent functions or methods and edges represent function calls.
Consider a simple dependency chain:
- Your service contains an HTTP handler in
main.gothat parses a user payload. - Your handler calls a helper function in your internal
parserpackage. - The helper package imports a third-party library to decode a specific data format.
- The third-party library contains a vulnerable function that allows arbitrary memory access when fed malformed input.
To determine if your application is vulnerable, the analyzer starts at the entry point of your binary. It traverses the edges of the call graph. If it reaches the node belonging to the third-party library that contains the vulnerable function, the vulnerability is marked reachable. If your HTTP handler calls the parser helper, but the parser helper only invokes safe routines in the third-party library and never touches the vulnerable routine, the vulnerability is marked unreachable.
Building this graph requires understanding language-specific semantics. A Python import statement resolves differently than a Rust crate dependency or a Go module import path. The analyzer must resolve symbol names, handle interface polymorphism, and trace pointers or method receivers correctly.
Parsing the Dependency Tree Locally
To run this locally without cloud interaction, you need a parser that runs as a binary on your workstation or build runner. Let us look at how to inspect your dependency tree and build a local AST representation using standard command-line tools and a local analysis engine.
First, ensure you have your dependency manifest locked down. For a Go project, this means a clean go.mod and go.sum. For a Node.js project, a package-lock.json or pnpm-lock.yaml. Locking your versions ensures that the local parser inspects the exact package versions present in your build.
Next, invoke your local analysis tool to generate the call graph. For instance, running a local static analysis scan targeting your package directory:
safeguard analyze reachability --target ./cmd/myservice --output graph.json
This command reads your source files, resolves dependencies locally using your local cache, and writes a structured JSON representation of the call graph to disk. No network calls are made to external vulnerability scanners during the parsing phase. The tool queries local vulnerability databases cached on your disk to match identified package versions against known CVE records.
Inspecting the Generated Call Graph
Once the analysis completes, you can inspect the resulting graph to verify why a specific package was flagged or cleared. Opening the generated JSON file reveals nodes representing functions and edges representing invocations.
A typical node entry looks like this:
{
"id" : "pkg:golang/github.com/example/parser@v1.2.3#DecodePayload",
"package" : "github.com/example/parser",
"version" : "1.2.3",
"symbol" : "DecodePayload",
"file" : "vendor/github.com/example/parser/decode.go",
"line" : 45
}
Edges represent directed calls from an initiator to a target:
{
"from" : "pkg:golang/myservice/internal/handlers#ProcessRequest",
"to" : "pkg:golang/github.com/example/parser@v1.2.3#DecodePayload"
}
If you want to query this graph programmatically to check whether a specific CVE is reachable before your CI pipeline approves a pull request, you can run a local query command:
safeguard query reachability --graph graph.json --cve CVE-2026-1234
The output will show one of three states:
- Reachable: A clear call path exists from an entry point to the vulnerable symbol.
- Unreachable: The package is present in your dependency tree, but no execution path reaches the vulnerable symbol.
- Unknown: The call graph could not resolve dynamic dispatches or reflection calls, requiring manual inspection.
Fix It Without Waiting for Upstream
When a vulnerability is flagged as reachable, the standard advice is to upgrade the dependency to the patched version. However, upstream maintainers often take days or weeks to release a patch, or the vulnerable dependency is buried deep within a transitive tree where upgrading requires breaking changes across multiple downstream modules.
When you cannot upgrade immediately, local reachability data gives you actionable options to remediate the risk yourself without waiting for upstream.
1. Prune Dead Code Paths
If the reachability report shows that your code invokes a specific helper function in a library, but that helper function is only used in a legacy feature that is disabled by default, you can remove the call site from your application code. By eliminating the edge in your call graph that leads to the vulnerable function, you render the vulnerability unreachable even if the vulnerable package remains on disk.
2. Implement Input Validation Wrappers
If the vulnerability requires a specific malformed input parameter to trigger memory corruption or injection, you can add strict input validation and sanitization at the boundary where your application receives data. If your wrapper rejects payloads containing the trigger signature before they reach the dependency function, the attack vector is closed.
3. Override Transitive Dependencies
Many package managers allow you to force a specific version of a transitive dependency regardless of what your direct dependencies request. For example, in Go, you can use a replace directive in your go.mod file to substitute a vulnerable sub-dependency with a patched fork or a local override:
replace example.com/vulnerable/dep v1.0.0 => example.com/patched/dep v1.0.1
By managing dependency overrides locally, you patch the vulnerability in your own builds immediately while contributing a fix back to the open source community.
Integrating Local Analysis Into Your Workflow
To ensure reachability analysis runs consistently without violating data privacy policies, integrate the local scanner into your pre-commit hooks or local CI runner scripts. Because the tool runs entirely offline using cached vulnerability databases, it adds minimal latency to your build process.
Add the check to your local lint script:
#!/usr/bin/env bash
set -euo pipefail
# Run local reachability scan
safeguard analyze reachability --strict --fail-on-reachable
Running this check before pushing code ensures that vulnerabilities introduced during development are caught and triaged on your local machine, keeping your proprietary source code entirely under your control while maintaining a high security posture.