Potential Persistence via Atom Init Script Modification
Identifies modifications to the Atom desktop text editor Init File. Adversaries may add malicious JavaScript code to the init.coffee file that will be executed upon the Atom application opening.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2021/01/21"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2025/01/15"
6
7[rule]
8author = ["Elastic"]
9description = """
10Identifies modifications to the Atom desktop text editor Init File. Adversaries may add malicious JavaScript code to the
11init.coffee file that will be executed upon the Atom application opening.
12"""
13from = "now-9m"
14index = ["logs-endpoint.events.*"]
15language = "kuery"
16license = "Elastic License v2"
17name = "Potential Persistence via Atom Init Script Modification"
18references = [
19 "https://github.com/D00MFist/PersistentJXA/blob/master/AtomPersist.js",
20 "https://flight-manual.atom.io/hacking-atom/sections/the-init-file/",
21]
22risk_score = 21
23rule_id = "b4449455-f986-4b5a-82ed-e36b129331f7"
24setup = """## Setup
25
26This rule requires data coming in from Elastic Defend.
27
28### Elastic Defend Integration Setup
29Elastic 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.
30
31#### Prerequisite Requirements:
32- Fleet is required for Elastic Defend.
33- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
34
35#### The following steps should be executed in order to add the Elastic Defend integration on a macOS System:
36- Go to the Kibana home page and click "Add integrations".
37- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
38- Click "Add Elastic Defend".
39- Configure the integration name and optionally add a description.
40- Select the type of environment you want to protect, for MacOS it is recommended to select "Traditional Endpoints".
41- 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).
42- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
43- 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.
44For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html).
45- Click "Save and Continue".
46- 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.
47For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
48"""
49severity = "low"
50tags = [
51 "Domain: Endpoint",
52 "OS: macOS",
53 "Use Case: Threat Detection",
54 "Tactic: Persistence",
55 "Data Source: Elastic Defend",
56 "Resources: Investigation Guide",
57]
58timestamp_override = "event.ingested"
59type = "query"
60
61query = '''
62event.category:file and host.os.type:macos and not event.type:"deletion" and
63 file.path:/Users/*/.atom/init.coffee and not process.name:(Atom or xpcproxy) and not user.name:root
64'''
65note = """## Triage and analysis
66
67> **Disclaimer**:
68> 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.
69
70### Investigating Potential Persistence via Atom Init Script Modification
71
72Atom, a popular text editor, allows customization via the `init.coffee` script, which executes JavaScript upon startup. Adversaries exploit this by embedding malicious code, ensuring persistence each time Atom launches. The detection rule identifies suspicious modifications to this script on macOS, excluding benign processes and root user actions, thus highlighting potential unauthorized persistence attempts.
73
74### Possible investigation steps
75
76- Review the file modification details for /Users/*/.atom/init.coffee to identify the exact changes made to the script.
77- Investigate the process that modified the init.coffee file by examining the process name and user associated with the modification, ensuring it is not Atom, xpcproxy, or the root user.
78- Check the user account involved in the modification for any unusual activity or recent changes, such as new software installations or privilege escalations.
79- Analyze the content of the modified init.coffee file for any suspicious or unfamiliar JavaScript code that could indicate malicious intent.
80- Correlate the modification event with other security alerts or logs from the same host to identify any related suspicious activities or patterns.
81- If malicious code is found, isolate the affected system and conduct a deeper forensic analysis to determine the scope and impact of the potential compromise.
82
83### False positive analysis
84
85- Frequent legitimate updates to the init.coffee file by developers or power users can trigger alerts. To manage this, create exceptions for specific user accounts known to regularly modify this file for legitimate purposes.
86- Automated scripts or tools that modify the init.coffee file as part of a legitimate configuration management process may cause false positives. Identify these processes and exclude them from the rule by adding their process names to the exception list.
87- Non-malicious third-party Atom packages that require modifications to the init.coffee file for functionality can be mistaken for threats. Review and whitelist these packages if they are verified as safe and necessary for user workflows.
88- System maintenance or administrative tasks performed by non-root users that involve changes to the init.coffee file might be flagged. Consider adding exceptions for these specific maintenance activities if they are routine and verified as non-threatening.
89
90### Response and remediation
91
92- Immediately isolate the affected system from the network to prevent further execution of potentially malicious code.
93- Review the contents of the `init.coffee` file to identify and document any unauthorized or suspicious code modifications.
94- Remove any malicious code found in the `init.coffee` file and restore it to a known good state, either by reverting to a backup or by manually cleaning the file.
95- Conduct a thorough scan of the system using updated antivirus or endpoint detection and response (EDR) tools to identify and remove any additional malware or persistence mechanisms.
96- Change the credentials of the user account associated with the modified `init.coffee` file to prevent unauthorized access.
97- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if other systems may be affected.
98- Implement monitoring for future unauthorized changes to the `init.coffee` file and similar persistence mechanisms, enhancing detection capabilities to quickly identify and respond to similar threats."""
99
100
101[[rule.threat]]
102framework = "MITRE ATT&CK"
103[[rule.threat.technique]]
104id = "T1037"
105name = "Boot or Logon Initialization Scripts"
106reference = "https://attack.mitre.org/techniques/T1037/"
107
108
109[rule.threat.tactic]
110id = "TA0003"
111name = "Persistence"
112reference = "https://attack.mitre.org/tactics/TA0003/"
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 Potential Persistence via Atom Init Script Modification
Atom, a popular text editor, allows customization via the init.coffee
script, which executes JavaScript upon startup. Adversaries exploit this by embedding malicious code, ensuring persistence each time Atom launches. The detection rule identifies suspicious modifications to this script on macOS, excluding benign processes and root user actions, thus highlighting potential unauthorized persistence attempts.
Possible investigation steps
- Review the file modification details for /Users/*/.atom/init.coffee to identify the exact changes made to the script.
- Investigate the process that modified the init.coffee file by examining the process name and user associated with the modification, ensuring it is not Atom, xpcproxy, or the root user.
- Check the user account involved in the modification for any unusual activity or recent changes, such as new software installations or privilege escalations.
- Analyze the content of the modified init.coffee file for any suspicious or unfamiliar JavaScript code that could indicate malicious intent.
- Correlate the modification event with other security alerts or logs from the same host to identify any related suspicious activities or patterns.
- If malicious code is found, isolate the affected system and conduct a deeper forensic analysis to determine the scope and impact of the potential compromise.
False positive analysis
- Frequent legitimate updates to the init.coffee file by developers or power users can trigger alerts. To manage this, create exceptions for specific user accounts known to regularly modify this file for legitimate purposes.
- Automated scripts or tools that modify the init.coffee file as part of a legitimate configuration management process may cause false positives. Identify these processes and exclude them from the rule by adding their process names to the exception list.
- Non-malicious third-party Atom packages that require modifications to the init.coffee file for functionality can be mistaken for threats. Review and whitelist these packages if they are verified as safe and necessary for user workflows.
- System maintenance or administrative tasks performed by non-root users that involve changes to the init.coffee file might be flagged. Consider adding exceptions for these specific maintenance activities if they are routine and verified as non-threatening.
Response and remediation
- Immediately isolate the affected system from the network to prevent further execution of potentially malicious code.
- Review the contents of the
init.coffee
file to identify and document any unauthorized or suspicious code modifications. - Remove any malicious code found in the
init.coffee
file and restore it to a known good state, either by reverting to a backup or by manually cleaning the file. - Conduct a thorough scan of the system using updated antivirus or endpoint detection and response (EDR) tools to identify and remove any additional malware or persistence mechanisms.
- Change the credentials of the user account associated with the modified
init.coffee
file to prevent unauthorized access. - Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if other systems may be affected.
- Implement monitoring for future unauthorized changes to the
init.coffee
file and similar persistence mechanisms, enhancing detection capabilities to quickly identify and respond to similar threats.
References
Related rules
- Attempt to Enable the Root Account
- Authorization Plugin Modification
- Bash Shell Profile Modification
- Modification of Standard Authentication Module or Configuration
- Persistence via DirectoryService Plugin Modification