Sensitive Files Compression Inside A Container

Identifies the use of a compression utility to collect known files containing sensitive information, such as credentials and system configurations inside a container.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/05/12"
  3integration = ["cloud_defend"]
  4maturity = "production"
  5updated_date = "2025/01/15"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies the use of a compression utility to collect known files containing sensitive information, such as credentials
 11and system configurations inside a container.
 12"""
 13from = "now-6m"
 14index = ["logs-cloud_defend*"]
 15interval = "5m"
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Sensitive Files Compression Inside A Container"
 19risk_score = 47
 20rule_id = "475b42f0-61fb-4ef0-8a85-597458bfb0a1"
 21severity = "medium"
 22tags = [
 23    "Data Source: Elastic Defend for Containers",
 24    "Domain: Container",
 25    "OS: Linux",
 26    "Use Case: Threat Detection",
 27    "Tactic: Collection",
 28    "Tactic: Credential Access",
 29    "Resources: Investigation Guide",
 30]
 31timestamp_override = "event.ingested"
 32type = "eql"
 33
 34query = '''
 35process where container.id: "*" and event.type== "start" and
 36
 37/*account for tools that execute utilities as a subprocess, in this case the target utility name will appear as a process arg*/
 38(process.name: ("zip", "tar", "gzip", "hdiutil", "7z") or process.args: ("zip", "tar", "gzip", "hdiutil", "7z"))
 39and process.args: (
 40"/root/.ssh/id_rsa",
 41"/root/.ssh/id_rsa.pub",
 42"/root/.ssh/id_ed25519",
 43"/root/.ssh/id_ed25519.pub",
 44"/root/.ssh/authorized_keys",
 45"/root/.ssh/authorized_keys2",
 46"/root/.ssh/known_hosts",
 47"/root/.bash_history",
 48"/etc/hosts",
 49"/home/*/.ssh/id_rsa",
 50"/home/*/.ssh/id_rsa.pub",
 51"/home/*/.ssh/id_ed25519",
 52"/home/*/.ssh/id_ed25519.pub",
 53"/home/*/.ssh/authorized_keys",
 54"/home/*/.ssh/authorized_keys2",
 55"/home/*/.ssh/known_hosts",
 56"/home/*/.bash_history",
 57"/root/.aws/credentials",
 58"/root/.aws/config",
 59"/home/*/.aws/credentials",
 60"/home/*/.aws/config",
 61"/root/.docker/config.json",
 62"/home/*/.docker/config.json",
 63"/etc/group",
 64"/etc/passwd",
 65"/etc/shadow",
 66"/etc/gshadow")
 67'''
 68note = """## Triage and analysis
 69
 70> **Disclaimer**:
 71> 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.
 72
 73### Investigating Sensitive Files Compression Inside A Container
 74
 75Containers are lightweight, portable environments used to run applications consistently across different systems. Adversaries may exploit compression utilities within containers to gather and exfiltrate sensitive files, such as credentials and configuration files. The detection rule identifies suspicious compression activities by monitoring for specific utilities and file paths, flagging potential unauthorized data collection attempts.
 76
 77### Possible investigation steps
 78
 79- Review the process details to confirm the use of compression utilities such as zip, tar, gzip, hdiutil, or 7z within the container environment, focusing on the process.name and process.args fields.
 80- Examine the specific file paths listed in the process.args to determine if they include sensitive files like SSH keys, AWS credentials, or Docker configurations, which could indicate unauthorized data collection.
 81- Identify the container.id associated with the alert to gather more context about the container's purpose, owner, and any recent changes or deployments that might explain the activity.
 82- Check the event.type field for "start" to verify the timing of the process initiation and correlate it with any known legitimate activities or scheduled tasks within the container.
 83- Investigate the user or service account under which the process was executed to assess whether it has the necessary permissions and if the activity aligns with expected behavior for that account.
 84- Look for any related alerts or logs that might indicate a broader pattern of suspicious activity within the same container or across other containers in the environment.
 85
 86### False positive analysis
 87
 88- Routine backup operations may trigger the rule if they involve compressing sensitive files for storage. To handle this, identify and exclude backup processes or scripts that are known and trusted.
 89- Automated configuration management tools might compress configuration files as part of their normal operation. Exclude these tools by specifying their process names or paths in the exception list.
 90- Developers or system administrators might compress sensitive files during legitimate troubleshooting or maintenance activities. Establish a process to log and review these activities, and exclude them if they are verified as non-threatening.
 91- Continuous integration and deployment pipelines could involve compressing configuration files for deployment purposes. Identify these pipelines and exclude their associated processes to prevent false positives.
 92- Security tools that perform regular audits or scans might compress files for analysis. Ensure these tools are recognized and excluded from triggering the rule.
 93
 94### Response and remediation
 95
 96- Immediately isolate the affected container to prevent further data exfiltration or unauthorized access. This can be done by stopping the container or disconnecting it from the network.
 97- Conduct a thorough review of the compressed files and their contents to assess the extent of sensitive data exposure. Focus on the specific file paths identified in the alert.
 98- Change credentials and keys that may have been compromised, including SSH keys, AWS credentials, and Docker configurations. Ensure that new credentials are distributed securely.
 99- Review and update access controls and permissions for sensitive files within containers to minimize exposure. Ensure that only necessary processes and users have access to these files.
100- Implement monitoring and alerting for similar compression activities in other containers to detect potential threats early. Use the identified process names and arguments as indicators.
101- Escalate the incident to the security operations team for further investigation and to determine if additional systems or data have been affected.
102- Conduct a post-incident review to identify gaps in security controls and update container security policies to prevent recurrence."""
103
104
105[[rule.threat]]
106framework = "MITRE ATT&CK"
107[[rule.threat.technique]]
108id = "T1552"
109name = "Unsecured Credentials"
110reference = "https://attack.mitre.org/techniques/T1552/"
111[[rule.threat.technique.subtechnique]]
112id = "T1552.001"
113name = "Credentials In Files"
114reference = "https://attack.mitre.org/techniques/T1552/001/"
115
116
117
118[rule.threat.tactic]
119id = "TA0006"
120name = "Credential Access"
121reference = "https://attack.mitre.org/tactics/TA0006/"
122[[rule.threat]]
123framework = "MITRE ATT&CK"
124[[rule.threat.technique]]
125id = "T1560"
126name = "Archive Collected Data"
127reference = "https://attack.mitre.org/techniques/T1560/"
128[[rule.threat.technique.subtechnique]]
129id = "T1560.001"
130name = "Archive via Utility"
131reference = "https://attack.mitre.org/techniques/T1560/001/"
132
133
134
135[rule.threat.tactic]
136id = "TA0009"
137name = "Collection"
138reference = "https://attack.mitre.org/tactics/TA0009/"

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 Sensitive Files Compression Inside A Container

Containers are lightweight, portable environments used to run applications consistently across different systems. Adversaries may exploit compression utilities within containers to gather and exfiltrate sensitive files, such as credentials and configuration files. The detection rule identifies suspicious compression activities by monitoring for specific utilities and file paths, flagging potential unauthorized data collection attempts.

Possible investigation steps

  • Review the process details to confirm the use of compression utilities such as zip, tar, gzip, hdiutil, or 7z within the container environment, focusing on the process.name and process.args fields.
  • Examine the specific file paths listed in the process.args to determine if they include sensitive files like SSH keys, AWS credentials, or Docker configurations, which could indicate unauthorized data collection.
  • Identify the container.id associated with the alert to gather more context about the container's purpose, owner, and any recent changes or deployments that might explain the activity.
  • Check the event.type field for "start" to verify the timing of the process initiation and correlate it with any known legitimate activities or scheduled tasks within the container.
  • Investigate the user or service account under which the process was executed to assess whether it has the necessary permissions and if the activity aligns with expected behavior for that account.
  • Look for any related alerts or logs that might indicate a broader pattern of suspicious activity within the same container or across other containers in the environment.

False positive analysis

  • Routine backup operations may trigger the rule if they involve compressing sensitive files for storage. To handle this, identify and exclude backup processes or scripts that are known and trusted.
  • Automated configuration management tools might compress configuration files as part of their normal operation. Exclude these tools by specifying their process names or paths in the exception list.
  • Developers or system administrators might compress sensitive files during legitimate troubleshooting or maintenance activities. Establish a process to log and review these activities, and exclude them if they are verified as non-threatening.
  • Continuous integration and deployment pipelines could involve compressing configuration files for deployment purposes. Identify these pipelines and exclude their associated processes to prevent false positives.
  • Security tools that perform regular audits or scans might compress files for analysis. Ensure these tools are recognized and excluded from triggering the rule.

Response and remediation

  • Immediately isolate the affected container to prevent further data exfiltration or unauthorized access. This can be done by stopping the container or disconnecting it from the network.
  • Conduct a thorough review of the compressed files and their contents to assess the extent of sensitive data exposure. Focus on the specific file paths identified in the alert.
  • Change credentials and keys that may have been compromised, including SSH keys, AWS credentials, and Docker configurations. Ensure that new credentials are distributed securely.
  • Review and update access controls and permissions for sensitive files within containers to minimize exposure. Ensure that only necessary processes and users have access to these files.
  • Implement monitoring and alerting for similar compression activities in other containers to detect potential threats early. Use the identified process names and arguments as indicators.
  • Escalate the incident to the security operations team for further investigation and to determine if additional systems or data have been affected.
  • Conduct a post-incident review to identify gaps in security controls and update container security policies to prevent recurrence.

Related rules

to-top