Pluggable Authentication Module (PAM) Version Discovery

This rule detects PAM version discovery activity on Linux systems. PAM version discovery can be an indication of an attacker attempting to backdoor the authentication process through malicious PAM modules.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/12/16"
  3integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5min_stack_version = "8.13.0"
  6min_stack_comments = "Breaking change at 8.13.0 for SentinelOne Integration."
  7updated_date = "2025/01/24"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12This rule detects PAM version discovery activity on Linux systems. PAM version discovery can be an indication of an
 13attacker attempting to backdoor the authentication process through malicious PAM modules.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.*", "endgame-*", "logs-crowdstrike.fdr*", "logs-sentinel_one_cloud_funnel.*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Pluggable Authentication Module (PAM) Version Discovery"
 20references = [
 21    "https://www.group-ib.com/blog/pluggable-authentication-module/",
 22    "https://embracethered.com/blog/posts/2022/post-exploit-pam-ssh-password-grabbing/",
 23]
 24risk_score = 21
 25rule_id = "135abb91-dcf4-48aa-b81a-5ad036b67c68"
 26setup = """## Setup
 27
 28This rule requires data coming in from Elastic Defend.
 29
 30### Elastic Defend Integration Setup
 31Elastic 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.
 32
 33#### Prerequisite Requirements:
 34- Fleet is required for Elastic Defend.
 35- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 36
 37#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 38- Go to the Kibana home page and click "Add integrations".
 39- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 40- Click "Add Elastic Defend".
 41- Configure the integration name and optionally add a description.
 42- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 43- 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).
 44- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 45- 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.
 46For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 47- Click "Save and Continue".
 48- 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.
 49For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 50"""
 51severity = "low"
 52tags = [
 53    "Domain: Endpoint",
 54    "OS: Linux",
 55    "Use Case: Threat Detection",
 56    "Tactic: Discovery",
 57    "Tactic: Persistence",
 58    "Tactic: Credential Access",
 59    "Data Source: Elastic Defend",
 60    "Data Source: Elastic Endgame",
 61    "Data Source: Crowdstrike",
 62    "Data Source: SentinelOne",
 63    "Resources: Investigation Guide",
 64]
 65timestamp_override = "event.ingested"
 66type = "eql"
 67query = '''
 68process where host.os.type == "linux" and event.type == "start" and
 69  event.action in ("exec", "exec_event", "start", "ProcessRollup2") and process.parent.name != null and
 70  (
 71    (process.name in ("dpkg", "dpkg-query") and process.args == "libpam-modules") or
 72    (process.name == "rpm" and process.args == "pam")
 73  ) and
 74not process.parent.name in ("dcservice", "inspectorssmplugin")
 75'''
 76note = """## Triage and analysis
 77
 78> **Disclaimer**:
 79> 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.
 80
 81### Investigating Pluggable Authentication Module (PAM) Version Discovery
 82
 83Pluggable Authentication Modules (PAM) provide a flexible mechanism for authenticating users on Linux systems. Adversaries may exploit PAM by discovering its version to identify vulnerabilities or backdoor the authentication process with malicious modules. The detection rule identifies suspicious processes querying PAM-related packages, indicating potential reconnaissance or tampering attempts, thus alerting security teams to possible threats.
 84
 85### Possible investigation steps
 86
 87- Review the process details to confirm the presence of suspicious activity, focusing on processes with names "dpkg", "dpkg-query", or "rpm" and their arguments "libpam-modules" or "pam".
 88- Check the user account associated with the process to determine if it is a legitimate user or potentially compromised.
 89- Investigate the parent process to understand the origin of the command execution and assess if it aligns with normal user behavior.
 90- Analyze recent login attempts and authentication logs to identify any unusual patterns or failed attempts that may indicate unauthorized access attempts.
 91- Correlate this activity with other alerts or logs from the same host to identify if there are additional indicators of compromise or related suspicious activities.
 92
 93### False positive analysis
 94
 95- Routine system updates or package management activities may trigger the rule when legitimate processes like dpkg or rpm query PAM-related packages. To manage this, consider creating exceptions for known maintenance windows or trusted administrative scripts.
 96- Automated configuration management tools, such as Ansible or Puppet, might execute commands that match the rule's criteria. Identify these tools and exclude their processes from triggering alerts by specifying their execution context.
 97- Security compliance checks or vulnerability assessments often involve querying system packages, including PAM. If these are regularly scheduled and verified, whitelist the associated processes to prevent unnecessary alerts.
 98- Developers or system administrators testing PAM configurations might inadvertently trigger the rule. Establish a protocol for notifying the security team of such activities in advance, allowing for temporary exceptions during testing periods.
 99- Custom scripts used for system monitoring or auditing may include commands that match the rule. Review these scripts and, if deemed safe, add them to an exclusion list to reduce false positives.
100
101### Response and remediation
102
103- Isolate the affected system from the network to prevent further unauthorized access or lateral movement by the adversary.
104- Terminate any suspicious processes identified by the detection rule, specifically those involving 'dpkg', 'dpkg-query', or 'rpm' with arguments related to PAM.
105- Conduct a thorough review of PAM configuration files and modules on the affected system to identify and remove any unauthorized or malicious modifications.
106- Restore any compromised PAM modules from a known good backup to ensure the integrity of the authentication process.
107- Monitor for any additional suspicious activity on the affected system and related systems, focusing on unusual authentication attempts or process executions.
108- Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
109- Implement enhanced monitoring and logging for PAM-related activities across the network to detect similar threats in the future."""
110
111[[rule.threat]]
112framework = "MITRE ATT&CK"
113
114[[rule.threat.technique]]
115id = "T1082"
116name = "System Information Discovery"
117reference = "https://attack.mitre.org/techniques/T1082/"
118
119[rule.threat.tactic]
120id = "TA0007"
121name = "Discovery"
122reference = "https://attack.mitre.org/tactics/TA0007/"
123
124[[rule.threat]]
125framework = "MITRE ATT&CK"
126
127[[rule.threat.technique]]
128id = "T1543"
129name = "Create or Modify System Process"
130reference = "https://attack.mitre.org/techniques/T1543/"
131
132[rule.threat.tactic]
133id = "TA0003"
134name = "Persistence"
135reference = "https://attack.mitre.org/tactics/TA0003/"
136
137[[rule.threat]]
138framework = "MITRE ATT&CK"
139
140[[rule.threat.technique]]
141id = "T1556"
142name = "Modify Authentication Process"
143reference = "https://attack.mitre.org/techniques/T1556/"
144
145[rule.threat.tactic]
146id = "TA0006"
147name = "Credential Access"
148reference = "https://attack.mitre.org/tactics/TA0006/"

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 Pluggable Authentication Module (PAM) Version Discovery

Pluggable Authentication Modules (PAM) provide a flexible mechanism for authenticating users on Linux systems. Adversaries may exploit PAM by discovering its version to identify vulnerabilities or backdoor the authentication process with malicious modules. The detection rule identifies suspicious processes querying PAM-related packages, indicating potential reconnaissance or tampering attempts, thus alerting security teams to possible threats.

Possible investigation steps

  • Review the process details to confirm the presence of suspicious activity, focusing on processes with names "dpkg", "dpkg-query", or "rpm" and their arguments "libpam-modules" or "pam".
  • Check the user account associated with the process to determine if it is a legitimate user or potentially compromised.
  • Investigate the parent process to understand the origin of the command execution and assess if it aligns with normal user behavior.
  • Analyze recent login attempts and authentication logs to identify any unusual patterns or failed attempts that may indicate unauthorized access attempts.
  • Correlate this activity with other alerts or logs from the same host to identify if there are additional indicators of compromise or related suspicious activities.

False positive analysis

  • Routine system updates or package management activities may trigger the rule when legitimate processes like dpkg or rpm query PAM-related packages. To manage this, consider creating exceptions for known maintenance windows or trusted administrative scripts.
  • Automated configuration management tools, such as Ansible or Puppet, might execute commands that match the rule's criteria. Identify these tools and exclude their processes from triggering alerts by specifying their execution context.
  • Security compliance checks or vulnerability assessments often involve querying system packages, including PAM. If these are regularly scheduled and verified, whitelist the associated processes to prevent unnecessary alerts.
  • Developers or system administrators testing PAM configurations might inadvertently trigger the rule. Establish a protocol for notifying the security team of such activities in advance, allowing for temporary exceptions during testing periods.
  • Custom scripts used for system monitoring or auditing may include commands that match the rule. Review these scripts and, if deemed safe, add them to an exclusion list to reduce false positives.

Response and remediation

  • Isolate the affected system from the network to prevent further unauthorized access or lateral movement by the adversary.
  • Terminate any suspicious processes identified by the detection rule, specifically those involving 'dpkg', 'dpkg-query', or 'rpm' with arguments related to PAM.
  • Conduct a thorough review of PAM configuration files and modules on the affected system to identify and remove any unauthorized or malicious modifications.
  • Restore any compromised PAM modules from a known good backup to ensure the integrity of the authentication process.
  • Monitor for any additional suspicious activity on the affected system and related systems, focusing on unusual authentication attempts or process executions.
  • Escalate the incident to the security operations team for further investigation and to determine if additional systems are affected.
  • Implement enhanced monitoring and logging for PAM-related activities across the network to detect similar threats in the future.

References

Related rules

to-top