Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Sensitive data stored in reusable resources may be inadvertently leaked to a less privileged user or attacker if not properly cleared. Examples of reusable resources include

  • dynamically Dynamically allocated memory
  • statically Statically allocated memory
  • automatically Automatically allocated (stack) memory
  • memory Memory caches
  • diskDisk
  • disk Disk caches

The manner in which sensitive information can be properly cleared varies depending on the resource type and platform.

...

To prevent information leakage, dynamic memory containing sensitive information should be sanitized before being freed. This Sanitization is commonly accomplished by clearing the allocated space (that is, filling the space with '\0' characters).

...

A compliant program cannot rely on realloc() because it is not possible to clear the memory before the call. Instead, a custom function must be used that operates similarly to realloc() but sanitizes sensitive information as heap-based buffers are resized. Again, this sanitization is done by overwriting the space to be deallocated with '\0' characters.

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

Could detect possible violations of this rule by first flagging any usage of realloc(). Also, it could flag any usage of free that is not preceded by code to clear out the preceding memory, using memset. This heuristic is imperfect because it flags all possible data leaks, not just leaks of "sensitive" data, because ROSE cannot tell which data is sensitive.

Klocwork

Include Page
Klocwork_V
Klocwork_V

SV.USAGERULES.UNINTENDED_COPY

 

PRQA QA-C
Include Page
PRQA_V
PRQA_V
warncall for reallocPartially implemented

...