AUTOSAR C++14 Rule A27-0-1
Description
Rule Definition
Inputs from independent components shall be validated.
Rationale
When inputs from independent components are directly used in the source code, attackers might get complete or partial control of an application buffer. This control enables an attacker to terminate the program, view the content of the stack, access the content of the memory, modify the memory in random places, and execute unwanted code disguised as the program source code.
To prevent such vulnerabilities, validate the input from independent components. This rule applies to inputs received from external sources, such as:
- Inputs received from networks 
- Inputs received from other processes and software through interprocess communication (IPC) 
- Inputs received from components API 
Polyspace Implementation
Polyspace® raises a flag when inputs from independent components are used without validation. The flagged uses include:
- Routines such as - sethostid(Linux®) or- SetComputerName(Windows®) use externally controlled arguments to change the host ID. See- Host change using externally controlled elements.
- Functions such as - putenvand- setenvobtain new environment variable values or from unsecure sources. See- Use of externally controlled environment variable.
- Functions such as - printfuse a format specifier that is constructed from unsecure sources. See- Tainted string format.
- Arrays or pointers use an index that is obtained from unsecure sources. See - Array access with tainted index.
- The program obtains the path to a command from an external unsecure source. See - Command executed from externally controlled path.
- The program execute a command that is fully or partially constructed from externally controlled input. See - Execution of externally controlled command.
- The program loads libraries from fixed or externally controlled unsecure paths that can be partially or fully controlled by attackers. See - Library loaded from externally controlled path.
- A loop uses values obtained from unsecure sources as its boundary. See - Loop bounded with tainted value.
- Memory allocation functions, such as - callocor- malloc, use a size argument from an unsecure source. See- Size argument to memory function is from an unsecure source.
- A pointer dereference uses an offset variable from an unknown or unsecure source. See - Pointer dereference with tainted offset.
- One or both integer operands in a division operation comes from unsecure sources. See - Tainted division operand.
- One or both integer operands in a remainder operation ( - %) comes from unsecure sources. See- Tainted modulo operand.
- String manipulation functions that implicitly dereference the string buffer such as - strcpyor- sprintfuse strings from unsecure sources. See- Tainted NULL or non-null-terminated string.
- Values from unsecure sources are implicitly or explicitly converted from signed to unsigned values. See - Tainted sign change conversion.
- The program dereferences a pointer from an unsecure source that might be NULL or point to unknown memory. See - Use of tainted pointer.
Polyspace considers these inputs as input from an independent component or tainted:
- Volatile objects 
- Object that interact with the user 
- Objects that interact with the hardware 
- Objects that use random numbers or the current date and time 
To consider all input from outside the current analysis perimeter as
        unsecure, use -consider-analysis-perimeter-as-trust-boundary. See
          Sources of Tainting in a Polyspace Analysis.
When an input from an independent component is used without validation multiple times in a code, Polyspace flags the first use.
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.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Input/output library | 
| Category: Required, Non-automated | 
Version History
Introduced in R2021b