Can target credentials in shell history on self-hosted runners.1
- Tactic
- Credential Access
- Platforms
- Linux, macOS, Windows
- Version
- 2.0
- Created
- 04 February 2020
- Last modified
- 24 October 2025
- Contributors
- Raja Singh (raja-singh-r3v-sh3ll); Avioo360
Adversaries may search the command history on compromised systems for insecurely stored credentials.
Shell History MITRE reference T1552.003
Offense vs defense T1552.003
Is defensive coverage keeping up with adversary use? Eight counts, each ranked against all 697 ATT&CK techniques. Attack sits left, defense right, so a shape leaning left means adversaries are better documented here than defenders are equipped. Hover any spoke for its percentile and the share of techniques that have more. The timeline below shows when each side arrived.
How it got here
Adversary activity (campaign spans) over cumulative rule output. Each source is plotted independently from zero, so neither line includes the other. Campaign dates are year-granularity.
Shell History detection strategy DET0385
MITRE names one behaviour worth catching for this technique and breaks it into 2 analytics, one per platform. Each carries the log sources it needs and the fields you tune per environment.
Detect Access and Parsing of .bash_history Files for Credential Harvesting
AN1085 · Linux
A process outside of interactive shell context reads ~/.bash_history directly (e.g., using cat, less, grep), often shortly after privilege escalation or user switch (su/sudo). This may be followed by credential scanning in memory or file writes to new locations.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process CreationDC0032 | auditd:EXECVE | cat|less|grep accessing .bash_history from a non-shell process |
| File CreationDC0039 | auditd:SYSCALL | write or create file after .bash_history access |
| File AccessDC0055 | auditd:SYSCALL | open/read access to ~/.bash_history |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| UserContext | Filter by users with elevated privileges or service accounts |
| TimeWindow | Correlate access to .bash_history within X seconds of user switch or privilege escalation |
| ProcessNamePatterns | Add/remove CLI utilities used to read bash history |
AN1086 · macOS
A process or terminal command outside of standard shell utilities reads the user's .bash_history file. On macOS, unified logs or telemetry tools like EndpointSecurity (ESF) may observe file read APIs or terminal process lineage that shows non-user-initiated access.
Log sources
The data this analytic draws on. You do not need every component — each one you already collect covers part of it. Each links to its ATT&CK record.
| Data component | Name | Channel |
|---|---|---|
| Process MetadataDC0034 | macos:unifiedlog | non-shell process tree accessing bash history |
| File AccessDC0055 | macos:endpointsecurity | open or read syscall to ~/.bash_history |
Tunable fields
MITRE calls these the analytic’s mutable elements: the thresholds and filters you set for your own environment.
| Field | What you tune |
|---|---|
| ParentProcessCheck | Scope access to .bash_history only if parent is not Terminal.app or bash/zsh |
| AccessFrequency | Raise priority if .bash_history is accessed multiple times in short window |
There are multiple methods of preventing a user's command history from being flushed to their .bash_history file, including use of the following commands:
set +o history and set -o history to start logging again;
unset HISTFILE being added to a user's .bash_rc file; and
ln -s /dev/null ~/.bash_history to write commands to /dev/null instead.
In Zsh, fc -p can be used to create a private history session. However, previous history will be unavailable to the user until the session ends. Using unset HISTFILE and writing commands to /dev/null can also be used, similarly to Bash.
In PowerShell, users can utilize Set-PSReadLineOption to modify how commands are saved into history. Setting -HistorySaveStyle SaveNothing prevents command history from being saved onto the file. Note that setting it from SaveNothing to SaveIncrementally in the same session will cause all commands from that session to be saved. Alternatively, -AddToHistoryHandler can be used to filter certain commands from being saved into the history file.
Tests from Atomic Red Team (MIT licence) · technique definition