Tainted modulo operand
Operands of remainder operation (%
) come from an unsecure
source
Description
This defect occurs when one or both integer operands in a remainder
operation (%
) comes from unsecure
sources.
Risk
If the second remainder operand is zero, your remainder operation fails, causing your program to crash.
If the second remainder operand is
-1
, your remainder operation can overflow if the remainder operation is implemented based on the division operation that can overflow.If one of the operands is negative, the operation result is uncertain. For C89, the modulo operation is not standardized, so the result from negative operands is implementation-defined.
These risks can be exploited by attackers to gain access to your program or the target in general.
Fix
Before performing the modulo operation, validate the values
of the operands. Check the second operand for values of 0
and -1
.
Check both operands for negative values.
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_INT_MOD |
Impact: Low |
Version History
Introduced in R2015b
See Also
Integer division by zero
| Tainted division operand
| 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