Query Details
# Rule : Sensitive File Copy to /tmp Directory
## Description
Detects attempts to copy sensitive system files, such as `shadow` and `passwd`, to the `/tmp` directory using the `cp` command. These files contain critical information about user accounts and passwords, and copying them to a temporary directory may indicate malicious intent to exfiltrate or manipulate sensitive data.
- Source: [Sigma rule for detecting copying of sensitive files to /tmp](https://github.com/SigmaHQ/sigma/blob/0bb6f0c0d75ae3e1c37f9ab77d68f20cdb32ecd3/rules/linux/process_creation/proc_creation_lnx_cp_passwd_or_shadow_tmp.yml)
## Detection Logic
- Monitors process events where the executed file name is `cp`.
- Filters for instances where the process command line contains `/tmp` and includes either `shadow` or `passwd`, indicating an attempt to copy these sensitive files to the `/tmp` directory.
## Tags
- Sensitive File Copy
- Shadow File
- Passwd File
- Process Events
- Linux
## Search Query
```kql
DeviceProcessEvents
| where FileName == "cp" and ProcessCommandLine contains "/tmp" and ProcessCommandLine has_any ("shadow", "passwd")
This query is designed to detect attempts to copy sensitive system files, specifically shadow and passwd, to the /tmp directory using the cp command. These files contain critical information about user accounts and passwords, and copying them to a temporary directory could indicate malicious activity, such as an attempt to steal or manipulate sensitive data.
cp: It specifically checks for the cp command, which is used to copy files./tmp: It filters for instances where the command line includes the /tmp directory.shadow or passwd: It further filters for commands that involve the shadow or passwd files.DeviceProcessEvents
| where FileName == "cp" and ProcessCommandLine contains "/tmp" and ProcessCommandLine has_any ("shadow", "passwd")
cp./tmp directory.shadow or passwd files./etc/shadow file, which stores hashed passwords./etc/passwd file, which stores user account information.
Ali Hussein
Released: July 9, 2024
Tables
Keywords
Operators