Unusual Remote File Creation

This rule leverages the new_terms rule type to detect file creation via a commonly used file transfer service while excluding typical remote file creation activity. This behavior is often linked to lateral movement, potentially indicating an attacker attempting to move within a network.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2025/02/20"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2025/04/07"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10This rule leverages the new_terms rule type to detect file creation via a commonly used file
 11transfer service while excluding typical remote file creation activity. This behavior is
 12often linked to lateral movement, potentially indicating an attacker attempting to move
 13within a network.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.file*", "auditbeat-*"]
 17language = "kuery"
 18license = "Elastic License v2"
 19name = "Unusual Remote File Creation"
 20note = """ ## Triage and analysis
 21
 22> **Disclaimer**:
 23> 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.
 24
 25### Investigating Unusual Remote File Creation
 26
 27Remote file creation tools like SCP, FTP, and SFTP are essential for transferring files across networks, often used in legitimate administrative tasks. However, adversaries can exploit these services to move laterally within a network, creating files in unauthorized locations. The detection rule identifies suspicious file creation activities by monitoring specific processes and excluding typical paths, thus highlighting potential lateral movement attempts by attackers.
 28
 29### Possible investigation steps
 30
 31- Review the alert details to identify the specific process name (e.g., scp, ftp, sftp) involved in the file creation event.
 32- Examine the file path where the file was created to determine if it is an unusual or unauthorized location, considering the exclusion of typical paths like /dev/ptmx, /run/*, or /var/run/*.
 33- Check the user account associated with the process to verify if it is a legitimate user or if there are signs of compromised credentials.
 34- Investigate the source and destination IP addresses involved in the file transfer to identify any suspicious or unexpected network connections.
 35- Analyze recent activity on the host to identify any other unusual or unauthorized actions that may indicate lateral movement or further compromise.
 36- Correlate this event with other alerts or logs to determine if it is part of a broader attack pattern or campaign within the network.
 37
 38### False positive analysis
 39
 40- Administrative file transfers: Legitimate administrative tasks often involve transferring files using SCP, FTP, or SFTP. To manage this, create exceptions for known administrative accounts or specific IP addresses that regularly perform these tasks.
 41- Automated backup processes: Scheduled backups may use tools like rsync or sftp-server to create files remotely. Identify and exclude these processes by specifying the paths or scripts involved in the backup operations.
 42- System updates and patches: Some system updates might involve remote file creation in non-standard directories. Monitor update schedules and exclude these activities by correlating them with known update events.
 43- Development and testing environments: Developers may use remote file transfer services to deploy or test applications. Establish a baseline of typical development activities and exclude these from alerts by defining specific user accounts or project directories.
 44- Third-party integrations: Some third-party applications might require remote file creation as part of their functionality. Document these integrations and exclude their associated processes or file paths from triggering alerts.
 45
 46### Response and remediation
 47
 48- Isolate the affected host immediately to prevent further lateral movement within the network. This can be done by removing the host from the network or applying network segmentation controls.
 49- Terminate any suspicious processes identified in the alert, such as scp, ftp, sftp, vsftpd, sftp-server, or sync, to stop unauthorized file transfers.
 50- Conduct a thorough review of the file paths and files created to determine if any sensitive data has been compromised or if any malicious files have been introduced.
 51- Restore any unauthorized or malicious file changes from known good backups to ensure system integrity.
 52- Update and patch the affected systems to close any vulnerabilities that may have been exploited by the attacker.
 53- Implement stricter access controls and authentication mechanisms for remote file transfer services to prevent unauthorized use.
 54- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems have been compromised.
 55"""
 56risk_score = 47
 57rule_id = "ed3fedc3-dd10-45a5-a485-34a8b48cea46"
 58setup = """## Setup
 59
 60This rule requires data coming in from one of the following integrations:
 61- Elastic Defend
 62- Auditbeat
 63
 64### Elastic Defend Integration Setup
 65Elastic 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.
 66
 67#### Prerequisite Requirements:
 68- Fleet is required for Elastic Defend.
 69- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 70
 71#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 72- Go to the Kibana home page and click "Add integrations".
 73- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 74- Click "Add Elastic Defend".
 75- Configure the integration name and optionally add a description.
 76- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 77- 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).
 78- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 79- 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.
 80For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 81- Click "Save and Continue".
 82- 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.
 83For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 84
 85### Auditbeat Setup
 86Auditbeat is a lightweight shipper that you can install on your servers to audit the activities of users and processes on your systems. For example, you can use Auditbeat to collect and centralize audit events from the Linux Audit Framework. You can also use Auditbeat to detect changes to critical files, like binaries and configuration files, and identify potential security policy violations.
 87
 88#### The following steps should be executed in order to add the Auditbeat on a Linux System:
 89- Elastic provides repositories available for APT and YUM-based distributions. Note that we provide binary packages, but no source packages.
 90- To install the APT and YUM repositories follow the setup instructions in this [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setup-repositories.html).
 91- To run Auditbeat on Docker follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-docker.html).
 92- To run Auditbeat on Kubernetes follow the setup instructions in the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/running-on-kubernetes.html).
 93- For complete “Setup and Run Auditbeat” information refer to the [helper guide](https://www.elastic.co/guide/en/beats/auditbeat/current/setting-up-and-running.html).
 94"""
 95severity = "medium"
 96tags = [
 97    "Domain: Endpoint",
 98    "OS: Linux",
 99    "Use Case: Threat Detection",
100    "Tactic: Lateral Movement",
101    "Data Source: Elastic Defend",
102    "Resources: Investigation Guide",
103]
104timestamp_override = "event.ingested"
105type = "new_terms"
106query = '''
107event.category:file and host.os.type:linux and event.action:creation and
108process.name:(scp or ftp or sftp or vsftpd or sftp-server or sync) and
109not file.path:(/dev/ptmx or /run/* or /var/run/*)
110'''
111
112[[rule.threat]]
113framework = "MITRE ATT&CK"
114
115[[rule.threat.technique]]
116id = "T1021"
117name = "Remote Services"
118reference = "https://attack.mitre.org/techniques/T1021/"
119
120[[rule.threat.technique.subtechnique]]
121id = "T1021.004"
122name = "SSH"
123reference = "https://attack.mitre.org/techniques/T1021/004/"
124
125[[rule.threat.technique]]
126id = "T1570"
127name = "Lateral Tool Transfer"
128reference = "https://attack.mitre.org/techniques/T1570/"
129
130[rule.threat.tactic]
131id = "TA0008"
132name = "Lateral Movement"
133reference = "https://attack.mitre.org/tactics/TA0008/"
134
135[rule.new_terms]
136field = "new_terms_fields"
137value = ["process.executable", "host.id"]
138
139[[rule.new_terms.history_window_start]]
140field = "history_window_start"
141value = "now-10d"
...
toml

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.

Remote file creation tools like SCP, FTP, and SFTP are essential for transferring files across networks, often used in legitimate administrative tasks. However, adversaries can exploit these services to move laterally within a network, creating files in unauthorized locations. The detection rule identifies suspicious file creation activities by monitoring specific processes and excluding typical paths, thus highlighting potential lateral movement attempts by attackers.

  • Review the alert details to identify the specific process name (e.g., scp, ftp, sftp) involved in the file creation event.
  • Examine the file path where the file was created to determine if it is an unusual or unauthorized location, considering the exclusion of typical paths like /dev/ptmx, /run/, or /var/run/.
  • Check the user account associated with the process to verify if it is a legitimate user or if there are signs of compromised credentials.
  • Investigate the source and destination IP addresses involved in the file transfer to identify any suspicious or unexpected network connections.
  • Analyze recent activity on the host to identify any other unusual or unauthorized actions that may indicate lateral movement or further compromise.
  • Correlate this event with other alerts or logs to determine if it is part of a broader attack pattern or campaign within the network.
  • Administrative file transfers: Legitimate administrative tasks often involve transferring files using SCP, FTP, or SFTP. To manage this, create exceptions for known administrative accounts or specific IP addresses that regularly perform these tasks.
  • Automated backup processes: Scheduled backups may use tools like rsync or sftp-server to create files remotely. Identify and exclude these processes by specifying the paths or scripts involved in the backup operations.
  • System updates and patches: Some system updates might involve remote file creation in non-standard directories. Monitor update schedules and exclude these activities by correlating them with known update events.
  • Development and testing environments: Developers may use remote file transfer services to deploy or test applications. Establish a baseline of typical development activities and exclude these from alerts by defining specific user accounts or project directories.
  • Third-party integrations: Some third-party applications might require remote file creation as part of their functionality. Document these integrations and exclude their associated processes or file paths from triggering alerts.
  • Isolate the affected host immediately to prevent further lateral movement within the network. This can be done by removing the host from the network or applying network segmentation controls.
  • Terminate any suspicious processes identified in the alert, such as scp, ftp, sftp, vsftpd, sftp-server, or sync, to stop unauthorized file transfers.
  • Conduct a thorough review of the file paths and files created to determine if any sensitive data has been compromised or if any malicious files have been introduced.
  • Restore any unauthorized or malicious file changes from known good backups to ensure system integrity.
  • Update and patch the affected systems to close any vulnerabilities that may have been exploited by the attacker.
  • Implement stricter access controls and authentication mechanisms for remote file transfer services to prevent unauthorized use.
  • Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems have been compromised.

Related rules

to-top