Library loaded from externally controlled path
Using a library argument from an externally controlled path
Description
This defect occurs when libraries are loaded from fixed or externally controlled unsecure paths and unintended actors can control one or more locations on the paths.
Risk
If an attacker knows or controls the path that you use to load a library, the attacker can change:
The library that the program loads, replacing the intended library and commands.
The environment in which the library executes, giving unintended permissions and capabilities to the attacker.
Fix
When possible, use hard-coded or fully qualified path names to load libraries. It is possible the hard-coded paths do not work on other systems. Use a centralized location for hard-coded paths, so that you can easily modify the path within the source code.
Another solution is to use functions that require explicit paths.
For example, system()
does not require a full path
because it can use the PATH
environment variable.
However, execl()
and execv()
do
require the full path.
Extend Checker
By default, Polyspace® assumes that data from external sources are tainted. See Sources of Tainting in a Polyspace Analysis. To consider
any data that does not originate in the current scope of Polyspace analysis as
tainted, use the command line option -consider-analysis-perimeter-as-trust-boundary
.
Examples
Result Information
Group: Tainted Data |
Language: C | C++ |
Default: Off |
Command-Line Syntax: TAINTED_PATH_LIB |
Impact: Medium |
Version History
Introduced in R2015b
See Also
Execution of externally controlled command
| Use of externally controlled environment variable
| Command executed from externally controlled path
| Find
defects (-checkers)
| -consider-analysis-perimeter-as-trust-boundary
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)
- Sources of Tainting in a Polyspace Analysis
- Modify Default Behavior of Bug Finder Checkers