Skip to content
Threat Feed
medium advisory

Detection of Malicious Linux Profile Modification for Persistence

This intelligence details the detection of adversaries modifying Linux profile configuration files via command-line utilities to establish persistent code execution upon system login or reboot.

Adversaries targeting Linux environments often seek to establish persistence by modifying startup configuration files. This technique involves appending malicious commands, scripts, or binary paths into common shell initialization files such as ~/.bashrc, ~/.bash_profile, or /etc/profile. By successfully modifying these files, an attacker ensures that their arbitrary code executes with the privileges of the user who logs in, or the system account during boot, facilitating long-term access and potential privilege escalation.

Security operations centers must monitor for processes that perform write operations to these sensitive configuration files, particularly when initiated by utilities like 'echo' or redirect operators. While legitimate system administration tasks may involve these commands, the lack of expected administrative context or unusual patterns of modification can serve as a strong indicator of compromise. This activity is a classic method for maintaining a foothold in a Linux environment and is commonly associated with broader persistence and post-exploitation objectives.

Attack Chain

  1. Initial access is gained on the Linux target system (e.g., via web shell or remote exploitation).
  2. The attacker identifies shell profile files (e.g., ~/.bashrc or /etc/profile) to target for persistence.
  3. The attacker utilizes standard utilities like 'echo' or 'printf' to generate malicious command strings.
  4. The attacker uses file redirection operators ('>' or '>>') to append the generated command strings into the target profile file.
  5. The system saves the modified configuration file, embedding the malicious payload into the startup environment.
  6. The attacker waits for a user to initiate a login session or for the system to reboot.
  7. The shell or init process reads the modified profile file and executes the appended malicious command.
  8. The attacker regains execution control on the host, achieving persistent access.

Impact

Successful modification of profile files allows attackers to execute arbitrary code with elevated privileges, potentially leading to total system compromise, exfiltration of sensitive data, and further lateral movement within the network. This technique is a high-reward objective for actors aiming for long-term presence on targeted infrastructure.

Recommendation

  • Deploy the provided Sigma rule to your SIEM and tune the filter macros to exclude legitimate administrative activity.
  • Enable process-creation logging (e.g., via Sysmon for Linux or auditd) to ensure the full command line is captured for all process executions.
  • Perform regular integrity monitoring on sensitive Linux configuration files, such as ~/.bashrc and /etc/profile, to detect unauthorized modifications.
  • Correlate process creation events targeting profile files with parent process metadata to identify unauthorized or anomalous parent-child relationships.

Immediate actions

Deploy and tune the provided Sigma rule for Linux persistence monitoring.

Detection Engineering 72h

Mitigations

Implement restricted write permissions on system-wide configuration files like /etc/profile.

short_term IT Operations

T1546.004

Detection coverage 1

Detect Suspicious Append to Linux Profile Config Files

medium

Detects the use of 'echo' to append data to shell profile files, a technique often used to maintain persistent access.

sigma tactics: persistence techniques: T1546.004 sources: process_creation, linux

Detection queries are available on the platform. Get full rules →