AppArmor Profile Compilation via apparmor_parser

Detects the execution of "apparmor_parser" using the "-o" option to write a compiled AppArmor profile to an output file. This functionality is normally used by system administration tools or package installation scripts when building or loading AppArmor policies. In adversarial scenarios, attackers may use "apparmor_parser" to compile custom AppArmor profiles that can later be loaded into the kernel through AppArmor policy management interfaces. Malicious profiles may weaken security controls, alter the behavior of privileged programs, or assist in exploitation chains involving AppArmor policy manipulation.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/03/17"
  3integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel", "auditd_manager"]
  4maturity = "production"
  5updated_date = "2026/03/17"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects the execution of "apparmor_parser" using the "-o" option to write a compiled AppArmor
 11profile to an output file. This functionality is normally used by system administration tools
 12or package installation scripts when building or loading AppArmor policies. In adversarial
 13scenarios, attackers may use "apparmor_parser" to compile custom AppArmor profiles that can
 14later be loaded into the kernel through AppArmor policy management interfaces. Malicious
 15profiles may weaken security controls, alter the behavior of privileged programs, or assist in
 16exploitation chains involving AppArmor policy manipulation.
 17"""
 18from = "now-9m"
 19index = [
 20    "logs-endpoint.events.process*",
 21    "endgame-*",
 22    "logs-crowdstrike.fdr*",
 23    "logs-sentinel_one_cloud_funnel.*",
 24    "logs-auditd_manager.auditd-*",
 25    "auditbeat-*",
 26]
 27language = "eql"
 28license = "Elastic License v2"
 29name = "AppArmor Profile Compilation via apparmor_parser"
 30note = """## Triage and analysis
 31
 32> **Disclaimer**:
 33> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 34
 35### Investigating AppArmor Profile Compilation via apparmor_parser
 36
 37This alert flags a Linux process using apparmor_parser to write a compiled AppArmor policy to disk, an action administrators and package scripts use but adversaries can abuse to stage policy changes. An attacker with root access can compile a custom profile that grants a trojanized service broader file or capability access, then load it to weaken confinement and support privilege escalation or stealthy persistence.
 38
 39### Possible investigation steps
 40
 41- Review the full command line, parent and ancestor process chain, executing user, tty or session, and working directory to determine whether the activity came from expected package management or configuration tooling versus an interactive shell.
 42- Identify the source profile and output file paths, then inspect the profile for broad file access, dangerous capability grants, unconfined transitions, or complain/disable settings that would weaken confinement for sensitive binaries or services.
 43- Correlate nearby events for writes under AppArmor policy directories, subsequent policy loads or reloads, package installation actions, and restarts of the targeted application to confirm whether the compiled profile was actually deployed.
 44- Compare the activity against host and peer-system baselines and validate it with change records, deployment jobs, or package updates tied to the same account or system to quickly distinguish administrative maintenance from anomalous behavior.
 45- If the execution is not authorized, preserve the generated profile and related scripts, restore affected policy files from a known-good source, and review recent privileged activity on the host for additional persistence or defense-evasion changes.
 46
 47### False positive analysis
 48
 49- Operating system package installation or upgrade can invoke apparmor_parser with -o to precompile a vendor profile during a post-install action; verify this by reviewing the parent process and nearby package-management activity for an authorized update at the same time.
 50- A system administrator may compile a new or modified local AppArmor profile while hardening or troubleshooting a service; verify the executing user, source and output file paths, and whether the change aligns with approved maintenance or documented policy updates.
 51
 52### Response and remediation
 53
 54- Isolate the affected Linux host from the network and stop any service whose confinement was altered if the compiled profile was loaded or written into `/etc/apparmor.d/` or AppArmor cache directories, to prevent further policy abuse.
 55- Preserve the malicious source profile, compiled output, invoking script, and shell history for evidence, then delete unauthorized files from `/etc/apparmor.d/`, `/etc/apparmor.d/disable/`, and cache paths and unload the rogue policy with approved AppArmor administration commands.
 56- Remove attacker persistence by reviewing and cleaning systemd unit files, timers, cron entries, package maintainer scripts, login startup files, and sudoers changes that call `apparmor_parser` or restore the profile at boot.
 57- Reset or revoke credentials used on the host, including root and sudo-capable accounts, service account secrets, and unauthorized `authorized_keys`, if the attacker had interactive access or modified privileged services.
 58- Restore AppArmor policy files, affected binaries, and related service configurations from trusted packages, configuration management, or a gold image, then reload AppArmor in enforce mode and confirm the targeted program is confined by the expected profile.
 59- Escalate to incident response immediately if the custom profile targeted `sshd`, `sudo`, container runtimes, web-facing daemons, or appears on multiple hosts, and harden the environment by limiting write access to AppArmor policy paths, alerting on future `apparmor_parser -o` use outside approved package activity, and enforcing change control for policy updates.
 60"""
 61references = [
 62    "https://cdn2.qualys.com/advisory/2026/03/10/crack-armor.txt",
 63    "https://blog.qualys.com/vulnerabilities-threat-research/2026/03/12/crackarmor-critical-apparmor-flaws-enable-local-privilege-escalation-to-root",
 64]
 65risk_score = 21
 66rule_id = "d26331be-affe-46b2-bf4e-203d0e2d364c"
 67setup = """## Setup
 68
 69This rule requires data coming in from Elastic Defend.
 70
 71### Elastic Defend Integration Setup
 72Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 73
 74#### Prerequisite Requirements:
 75- Fleet is required for Elastic Defend.
 76- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 77
 78#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 79- Go to the Kibana home page and click "Add integrations".
 80- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 81- Click "Add Elastic Defend".
 82- Configure the integration name and optionally add a description.
 83- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 84- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 85- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 86- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 87For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 88- Click "Save and Continue".
 89- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 90For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 91"""
 92severity = "low"
 93tags = [
 94    "Domain: Endpoint",
 95    "OS: Linux",
 96    "Use Case: Threat Detection",
 97    "Tactic: Defense Evasion",
 98    "Data Source: Auditd Manager",
 99    "Data Source: Elastic Defend",
100    "Data Source: Elastic Endgame",
101    "Data Source: Crowdstrike",
102    "Data Source: SentinelOne",
103    "Resources: Investigation Guide",
104]
105timestamp_override = "event.ingested"
106type = "eql"
107query = '''
108process where host.os.type == "linux" and event.type == "start" and
109event.action in ("exec", "exec_event", "start", "ProcessRollup2", "executed", "process_started") and
110process.name == "apparmor_parser" and process.args in ("--ofile*", "-o*", "--output*")
111'''
112
113[[rule.threat]]
114framework = "MITRE ATT&CK"
115
116[[rule.threat.technique]]
117id = "T1562"
118name = "Impair Defenses"
119reference = "https://attack.mitre.org/techniques/T1562/"
120
121[[rule.threat.technique.subtechnique]]
122id = "T1562.001"
123name = "Disable or Modify Tools"
124reference = "https://attack.mitre.org/techniques/T1562/001/"
125
126[rule.threat.tactic]
127id = "TA0005"
128name = "Defense Evasion"
129reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

Investigating AppArmor Profile Compilation via apparmor_parser

This alert flags a Linux process using apparmor_parser to write a compiled AppArmor policy to disk, an action administrators and package scripts use but adversaries can abuse to stage policy changes. An attacker with root access can compile a custom profile that grants a trojanized service broader file or capability access, then load it to weaken confinement and support privilege escalation or stealthy persistence.

Possible investigation steps

  • Review the full command line, parent and ancestor process chain, executing user, tty or session, and working directory to determine whether the activity came from expected package management or configuration tooling versus an interactive shell.
  • Identify the source profile and output file paths, then inspect the profile for broad file access, dangerous capability grants, unconfined transitions, or complain/disable settings that would weaken confinement for sensitive binaries or services.
  • Correlate nearby events for writes under AppArmor policy directories, subsequent policy loads or reloads, package installation actions, and restarts of the targeted application to confirm whether the compiled profile was actually deployed.
  • Compare the activity against host and peer-system baselines and validate it with change records, deployment jobs, or package updates tied to the same account or system to quickly distinguish administrative maintenance from anomalous behavior.
  • If the execution is not authorized, preserve the generated profile and related scripts, restore affected policy files from a known-good source, and review recent privileged activity on the host for additional persistence or defense-evasion changes.

False positive analysis

  • Operating system package installation or upgrade can invoke apparmor_parser with -o to precompile a vendor profile during a post-install action; verify this by reviewing the parent process and nearby package-management activity for an authorized update at the same time.
  • A system administrator may compile a new or modified local AppArmor profile while hardening or troubleshooting a service; verify the executing user, source and output file paths, and whether the change aligns with approved maintenance or documented policy updates.

Response and remediation

  • Isolate the affected Linux host from the network and stop any service whose confinement was altered if the compiled profile was loaded or written into /etc/apparmor.d/ or AppArmor cache directories, to prevent further policy abuse.
  • Preserve the malicious source profile, compiled output, invoking script, and shell history for evidence, then delete unauthorized files from /etc/apparmor.d/, /etc/apparmor.d/disable/, and cache paths and unload the rogue policy with approved AppArmor administration commands.
  • Remove attacker persistence by reviewing and cleaning systemd unit files, timers, cron entries, package maintainer scripts, login startup files, and sudoers changes that call apparmor_parser or restore the profile at boot.
  • Reset or revoke credentials used on the host, including root and sudo-capable accounts, service account secrets, and unauthorized authorized_keys, if the attacker had interactive access or modified privileged services.
  • Restore AppArmor policy files, affected binaries, and related service configurations from trusted packages, configuration management, or a gold image, then reload AppArmor in enforce mode and confirm the targeted program is confined by the expected profile.
  • Escalate to incident response immediately if the custom profile targeted sshd, sudo, container runtimes, web-facing daemons, or appears on multiple hosts, and harden the environment by limiting write access to AppArmor policy paths, alerting on future apparmor_parser -o use outside approved package activity, and enforcing change control for policy updates.

References

Related rules

to-top