Variant · Low-Medium

CWE-591: Sensitive Data Storage in Improperly Locked Memory

The product stores sensitive data in memory that is not locked, or that has been incorrectly locked, which might cause the memory to be written to swap files on disk by the virtual memory manager. Thi...

CWE-591 · Variant Level ·1 CVEs ·2 Mitigations

Description

The product stores sensitive data in memory that is not locked, or that has been incorrectly locked, which might cause the memory to be written to swap files on disk by the virtual memory manager. This can make the data more accessible to external actors.

On Windows systems the VirtualLock function can lock a page of memory to ensure that it will remain present in memory and not be swapped to disk. However, on older versions of Windows, such as 95, 98, or Me, the VirtualLock() function is only a stub and provides no protection. On POSIX systems the mlock() call ensures that a page will stay resident in memory but does not guarantee that the page will not appear in the swap. Therefore, it is unsuitable for use as a protection mechanism for sensitive data. Some platforms, in particular Linux, do make the guarantee that the page will not be swapped, but this is non-standard and is not portable. Calls to mlock() also require supervisor privilege. Return values for both of these calls must be checked to ensure that the lock operation was actually successful.

Potential Impact

Confidentiality

Read Application Data, Read Memory

Mitigations & Prevention

Architecture and Design

Identify data that needs to be protected from swapping and choose platform-appropriate protection mechanisms.

Implementation

Check return values to ensure locking operations are successful.

Real-World CVE Examples

CVE IDDescription
CVE-2024-38106OS kernel stores sensitive data in improperly locked memory, allowing local users to gain privileges by winning a race condition

Taxonomy Mappings

  • OWASP Top Ten 2004: A8 — Insecure Storage
  • CERT C Secure Coding: MEM06-C — Ensure that sensitive data is not written out to disk
  • Software Fault Patterns: SFP23 — Exposed Data

Frequently Asked Questions

What is CWE-591?

CWE-591 (Sensitive Data Storage in Improperly Locked Memory) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Variant-level weakness. The product stores sensitive data in memory that is not locked, or that has been incorrectly locked, which might cause the memory to be written to swap files on disk by the virtual memory manager. Thi...

How can CWE-591 be exploited?

Attackers can exploit CWE-591 (Sensitive Data Storage in Improperly Locked Memory) to read application data, read memory. This weakness is typically introduced during the Implementation phase of software development.

How do I prevent CWE-591?

Key mitigations include: Identify data that needs to be protected from swapping and choose platform-appropriate protection mechanisms.

What is the severity of CWE-591?

CWE-591 is classified as a Variant-level weakness (Low-Medium abstraction). It has been observed in 1 real-world CVEs.