# Secret residue in process memory

Plaintext passwords or tokens lingering in memory, logs, or tracing hooks after use

_Area: Memory corruption and native code. Seen in 2 disclosed reports; latest 2023-05-23. Updated 2026-11-09._

## How it works
A secret is handled in plaintext at some point, and the code assumes that once it is "done" the secret is gone. That assumption breaks because copies persist: per-character buffers, kernel log backtraces, or function arguments visible to tracing hooks. The root cause is that the secret is never held in one place that is reliably wiped, so residue outlives the operation and is readable by a weaker observer than the one who supplied it.

## Where it shows up
- Custom secure-input controls that store each typed character separately rather than one managed buffer [E2](https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md)
- Vendor logging daemons that copy kmsg into files with looser permissions than /dev/kmsg [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md)
- WARN_ON backtraces that print raw stack contents including kernel pointers [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md)
- Authentication APIs that pass the plaintext token as a function argument, reachable by uprobes [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md)
- Structs exposing usernames or handles at fixed offsets readable from userspace memory [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md)
- SELinux ctl.start grants letting system apps read OEM log files [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md)

## How to review
Identify every place a secret exists in plaintext and ask where each copy lives and when it is zeroed. The invariant: after the secret's last use, no readable copy remains in process memory, logs, swap, or crash dumps, and no tracing hook can observe it. Check that secure-input controls use a single buffer that is explicitly wiped, not per-character strings [E2](https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md). Check that logging paths do not duplicate kernel or auth data into more permissive sinks [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md). Check whether auth APIs expose the token as an argument and whether that is avoidable [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md).

## How finders spotted it
- Asked what a vendor-specific log file (sec_log) actually contained, then hunted for a reachable WARN_ON whose backtrace would include task_struct and a KASLR-breaking address [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md)
- Read pam_private.h to derive the pam_handle layout and identified pam_get_authtok's arg2 as the authtok pointer, then paired uprobe/uretprobe to read it after the call [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md)
- Reasoned that a custom password control handling characters individually would leave per-character remnants, so dumped process memory and crash/hibernation/swap files rather than only the locked UI [E2](https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md)

## Variants seen
- Kernel log duplication leaking KASLR and kernel pointers to system apps [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md)
- Per-character residue in a desktop password manager's custom input control [E2](https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md)
- Plaintext token exposed as a function argument to tracing hooks on Linux [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md)

## Impact and severity
E1 leaked KASLR and kernel pointers, and was chained with a kernel privilege escalation to gain arbitrary kernel read/write, raising severity sharply [E1](https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md). E2 let a local attacker recover the master password (minus the first character) even while the database was locked [E2](https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md). E3 captured plaintext logon passwords on Linux hosts [E3](https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md). Impact rises when the residue is reachable by a weaker principal than the secret's owner, or when it feeds another weakness such as KASLR defeat.

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **KeePass** (SecureTextBoxEx) versions newer than 2.0 up to the yet unreleased 2.54, fixed in 2.54.0: Exploitable and unpatched KeePass vulnerability: everything you need to know (CVE-2023-32784). Report: https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md
- **Samsung Android** (dumpstate / sec_log) Samsung Exynos, kernel 4.14.113, pre SMR-Mar-2021, fixed in SMR-Mar-2021: CVE-2021-25369: Samsung kernel info leak in sec_log (CVE-2021-25369). Report: https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md

## Evidence
- E1: https://bugbountylibrary.com/r/p0%3ACVE-2021-25369.md
- E2: https://bugbountylibrary.com/r/blog%3Awiz-io-blog-cve-2023-32784-keepass-vulnerability-exploit-released.md
- E3: https://bugbountylibrary.com/r/blog%3Aembracethered-com-blog-posts-2022-offensive-bpf-bpftrace-sniff-logon-pam-passwords.md
