Information leak via structure padding
Padding bytes can contain sensitive information
Description
This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
This defect occurs when you do not initialize the padding data of a structure or union before passing it across a trust boundary. A compiler adds padding bytes to the structure or union to ensure a proper memory alignment of its members. The bit-fields of the storage units can also have padding bits.
Information leak via structure padding raises a defect when:
You call an untrusted function with structure or union pointer type argument containing uninitialized padding data.
All external functions are considered untrusted.
You copy or assign a structure or union containing uninitialized padding data to an untrusted object.
All external structure or union objects, the output parameters of all externally linked functions, and the return pointer of all external functions are considered untrusted objects.
Risk
The padding bytes of the passed structure or union might contain sensitive information that an untrusted source can access.
Fix
Prevent the addition of padding bytes for memory alignment by using the
pack
pragma or attribute supported by your compiler.Explicitly declare and initialize padding bytes as fields within the structure or union.
Explicitly declare and initialize bit-fields corresponding to padding bits, even if you use the
pack
pragma or attribute supported by your compiler.
Examples
Result Information
Group: Security |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
PADDING_INFO_LEAK |
Impact: Low |
Version History
Introduced in R2018a
See Also
Find
defects (-checkers)
| Memory comparison of
padding data
| Use of memset with
size argument zero
| Invalid assumptions
about memory organization
| Sensitive heap memory
not cleared before release
| Uncleared sensitive
data in stack
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)