Sensitive Data Retained in Memory
The client keeps passwords, keys or other secrets in process memory in cleartext for longer than needed, where they can be read from a memory dump.
| Severity | Low |
| CVSS 3.1 | 3.3 CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 4.8 CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-316: Cleartext Storage of Sensitive Information in Memory |
| OWASP Top 10 | A06:2025 Insecure Design |
| Category | Information Disclosure |
Description
The application holds sensitive values in its process memory in cleartext for longer than it needs them: for example the user's password after sign-in has completed, database credentials, encryption keys, tokens, or sensitive records that remain after the screen showing them has closed. Values can also persist in memory that has been freed but not cleared, in several copies made by the runtime, and in files that capture memory, such as crash dumps, the page file and the hibernation file.
Managed runtimes make this hard to avoid. Strings in .NET and Java are immutable and cannot be cleared, and the garbage collector may copy them before they are released, so a password handled as a string can remain in memory for the life of the process. In native code, a call to clear a buffer that is not used afterwards may be removed by the compiler's optimiser.
Anyone who can read the process memory, which requires code running as the same user or administrative rights, or who obtains a crash dump or the device's storage, can recover these secrets. In most cases an attacker with that access could capture the same information in other ways, such as by logging keystrokes, which limits the rating. The exposure matters more where memory holds secrets the user does not otherwise see, such as shared service credentials or keys protecting other users' data.
The weakness is identified by using the application, then creating a dump of its process, for example with Task Manager or ProcDump, and searching it for known secrets such as the password used to sign in. Tools that inspect live process memory show the same.
Remediation
Hold secrets in memory only as long as they are needed, and clear them afterwards:
- Do not keep the user's password after authentication; exchange it for a token or session and discard it.
- In .NET, hold secrets in byte or character arrays rather than strings, and clear them with
CryptographicOperations.ZeroMemoryorArray.Clearas soon as they have been used. Microsoft advises against relying onSecureStringin new code, as it offers limited protection on modern .NET. - In native code, clear buffers with
SecureZeroMemory, or an equivalent the compiler will not remove, rather thanmemset. - Avoid holding shared or server-side secrets in the client at all, which also removes them from its memory.
- Configure crash reporting so that full memory dumps of the application are not created or sent automatically, and protect any dumps that are kept.
Confirm the fix by repeating the memory dump after the same actions and searching for the same values.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.