CWE-591: Sensitive Data Storage in Improperly Locked Memory

VariantDraft

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.

View on MITRE
Back to CWE Lookup

Extended Description

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.

Technical Details

Structure
Simple

Applicable To

Languages
Platforms

Frequently Asked Questions

What is CWE-591: Sensitive Data Storage in Improperly Locked Memory?+

CWE-591: Sensitive Data Storage in Improperly Locked Memory is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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.

What are the security consequences of Sensitive Data Storage in Improperly Locked Memory?+

If exploited, CWE-591 (Sensitive Data Storage in Improperly Locked Memory) it can compromise Confidentiality, leading to outcomes such as Read Application Data and Read Memory.

How do you prevent or mitigate Sensitive Data Storage in Improperly Locked Memory?+

Recommended mitigations for CWE-591 include: Identify data that needs to be protected from swapping and choose platform-appropriate protection mechanisms. Check return values to ensure locking operations are successful.

What is the difference between a CWE and a CVE?+

A CWE (Common Weakness Enumeration) like CWE-591 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.

Learn More