- Home
- Techniques
- Enterprise
- Unsecured Credentials
- Bash History
Unsecured Credentials: Bash History
Other sub-techniques of Unsecured Credentials (6)
ID | Name |
---|---|
T1552.001 | Credentials In Files |
T1552.002 | Credentials in Registry |
T1552.003 | Bash History |
T1552.004 | Private Keys |
T1552.005 | Cloud Instance Metadata API |
T1552.006 | Group Policy Preferences |
Adversaries may search the bash command history on compromised systems for insecurely stored credentials. Bash keeps track of the commands users type on the command-line with the "history" utility. Once a user logs out, the history is flushed to the user’s .bash_history
file. For each user, this file resides at the same location: ~/.bash_history
. Typically, this file keeps track of the user’s last 500 commands. Users often type usernames and passwords on the command-line as parameters to programs, which then get saved to this file when they log out. Attackers can abuse this by looking through the file for potential credentials. [1]
Mitigations
Mitigation | Description |
---|---|
Operating System Configuration |
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: |
Detection
Monitoring when the user's .bash_history
is read can help alert to suspicious activity. While users do typically rely on their history of commands, they often access this history through other utilities like "history" instead of commands like cat ~/.bash_history
.