Definition
Reachability analysis is a technique in software composition analysis that checks whether an application can actually execute the vulnerable code in a dependency, by following the calls from the application's own code into the package. Vulnerabilities in code that is never called get a lower priority.
How reachability analysis works
- The advisory is mapped to the affected functions or modules of the package.
- The tool builds a call graph: which function in your code calls which function in each dependency, through transitive dependencies too.
- If a path exists from your code to an affected function, the vulnerability is reachable. If not, it is reported as unreachable or given a lower priority.
There are levels of precision. Package-level reachability asks only whether the dependency is imported. Function-level reachability asks whether the vulnerable function can be called. Go's official govulncheck works at function level, and several commercial SCA products offer it for JavaScript, Python and Java.
Why teams use it
A plain SCA report lists each known vulnerability in each installed version. Many of those are in functions the application never calls, or in development tools that never see untrusted input. Reachability analysis lets a team fix the small number that matter first.
Limits
- Dynamic code hides calls. Reflection,
eval, dynamicrequireand dependency injection make the call graph incomplete, so "unreachable" is a probability, not a proof. - It depends on advisory quality. Someone must record which functions are affected.
- It does not apply to malware. Malicious code does not wait for your application to call it. A postinstall script runs during installation, and top-level code runs when the module is imported. A malicious package is dangerous if it is installed at all.
For this reason reachability is a tool to sort known vulnerabilities, and not a reason to ignore a package that a source review flags. Togoder Security reports what the code of each package does at install time and on import.
Frequently asked questions
Does an unreachable vulnerability need to be fixed?
It has a lower priority, but it is not gone. A later code change can make it reachable, and call graphs miss dynamic calls. Update the package in your normal maintenance.
Which tools do reachability analysis?
govulncheck does it for Go at function level and is free. Several commercial SCA products offer function-level reachability for other languages.
Does reachability analysis help against malicious packages?
No. Malware in a package runs from install scripts or when the module loads, without a call from your code. If a malicious version is installed, treat the machine as compromised.