Detection: Linux Possible SSH Bypass for Non-User Account

Description

The following analytic detects a failed SSH password authentication followed by a successful password authentication for the same common non-user Linux account, source address, and endpoint within five seconds. This may indicate abuse of an authentication bypass or another weakness that allowed access to an account whose shadow entry is typically locked or passwordless. The account list is a cross-distribution heuristic; verify the account's shadow status for each image.

 1`linux_syslog`
 2("Failed password for" OR "Accepted password for")
 3
 4
 5| rex field=_raw "^(?<event_timestamp>\\w{3}\\s+\\d+\\s+\\d{2}:\\d{2}:\\d{2})\\s+(?<dest>\\S+)\\s+(?:\\S+\\s+)?sshd(?:-session)?(?:\\.pam)?\\[\\d+\\]:\\s+(?<auth_result>Failed
 6|Accepted) password for (?:invalid user )?(?<user>\\S+) from (?<src_ip>\\S+) port (?<src_port>\\d+) ssh2"
 7
 8
 9| eval user=lower(user)
10
11
12| where isnotnull(auth_result) AND in(user, "daemon", "bin", "sys", "sync", "shutdown", "halt", "games", "man", "lp", "mail", "news", "uucp", "operator", "www-data", "backup", "list", "irc", "gnats", "nobody", "_apt", "systemd-network", "systemd-resolve", "messagebus", "uuidd", "sshd", "ntp", "ftp", "chrony", "postfix", "redis", "mysql", "mariadb", "postgres", "alpine", "guest")
13
14
15| eval event_priority=if(auth_result="Failed", 0, 1)
16
17
18| sort 0 _time event_priority
19
20
21| streamstats global=f window=1 current=f last(auth_result) as previous_auth_result last(_time) as failure_time by dest user src_ip
22
23
24| where auth_result="Accepted" AND previous_auth_result="Failed" AND _time-failure_time<=5
25
26
27| eval success_time=_time, elapsed_seconds=success_time-failure_time
28
29
30| `security_content_ctime(failure_time)`
31
32| `security_content_ctime(success_time)`
33
34
35| table failure_time success_time elapsed_seconds dest user src_ip src_port
36
37
38| `linux_possible_ssh_bypass_for_non_user_account_filter`

Data Source

Name Platform Sourcetype Source
Linux Messages Syslog Linux icon Linux 'linux_messages_syslog' '/var/log/kern'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
linux_possible_ssh_bypass_for_non_user_account_filter search *
linux_possible_ssh_bypass_for_non_user_account_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1021.004 SSH Lateral Movement
T1078.003 Local Accounts Initial Access
Exploitation
Delivery
Installation
DE.AE
CIS 10

CVE

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

To successfully implement this search, you need to ingest Linux syslog logs. These logs should be collected with the Splunk Add-on for Unix and Linux (https://splunkbase.splunk.com/app/833).

Known False Positives

A user may mistype a password before a legitimate login. Common account names may be unlocked or configured with a password on a particular image. Validate the account's shadow state and expected SSH access before escalating.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
Suspicious SSH login for non-user account [$user$] on [$dest$] from [$src_ip$]. dest system 20

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset /var/log/messages linux_messages_syslog
Integration ✅ Passing Dataset /var/log/messages linux_messages_syslog

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 1