Suspicious Network Connection Attempt by Rootedit

Identifies an outbound network connection attempt followed by a session id change as the root user by the same process entity. This particular instantiation of a network connection is abnormal and should be investigated as it may indicate a potential reverse shell activity via a privileged process.

Rule type: eql

Rule indices:

  • logs-endpoint.events.*

Severity: medium

Risk score: 43

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Elastic
  • Host
  • Linux
  • Threat Detection
  • Command and Control

Version: 3 (version history)

Added (Elastic Stack release): 8.3.0

Last modified (Elastic Stack release): 8.4.0

Rule authors: Elastic

Rule license: Elastic License v2

Potential false positivesedit

False-Positives (FP) can appear if another remote terminal service is being used to connect to it’s listener but typically SSH is used in these scenarios.

Investigation guideedit

## Triage and analysis
### Investigating Connection Attempt by Non-SSH Root Session
Detection alerts from this rule indicate a strange or abnormal outbound connection attempt by a privileged process.  Here are some possible avenues of investigation:
- Examine unusual and active sessions using commands such as 'last -a', 'netstat -a', and 'w -a'.
- Analyze processes and command line arguments to detect anomalous process execution that may be acting as a listener.
- Analyze anomalies in the use of files that do not normally initiate connections.
- Examine processes utilizing the network that do not normally have network communication.

Rule queryedit

sequence by process.entity_id with maxspan=1m [network where
event.type == "start" and event.action == "connection_attempted" and
user.id == "0" and not process.executable : ("/bin/ssh",
"/sbin/ssh", "/usr/lib/systemd/systemd", "/usr/sbin/sshd")] [process
where event.action == "session_id_change" and user.id == "0" and
not process.executable : ("/bin/ssh", "/sbin/ssh",
"/usr/lib/systemd/systemd", "/usr/sbin/sshd")]

Threat mappingedit

Framework: MITRE ATT&CKTM

Rule version historyedit

Version 3 (8.4.0 release)
  • Updated query, changed from:

    sequence by process.entity_id with maxspan=1m [network where
    event.type == "start" and event.action == "connection_attempted" and
    user.id == "0" and not process.executable : ("/bin/ssh",
    "/sbin/ssh", "/usr/lib/systemd/systemd")] [process where event.action
    == "session_id_change" and user.id == "0"]