[New Rule] Potential Password Spraying Attack via SSH#5515
Conversation
Rule: New - GuidelinesThese guidelines serve as a reminder set of considerations when proposing a new rule. Documentation and Context
Rule Metadata Checks
New BBR Rules
Testing and Validation
|
|
⛔️ Test failed Results
|
| timestamp_override = "event.ingested" | ||
| type = "esql" | ||
| query = ''' | ||
| from "logs-system.auth-*" metadata _id, _index, _version |
There was a problem hiding this comment.
| from "logs-system.auth-*" metadata _id, _index, _version | |
| from logs-system.auth-* |
There was a problem hiding this comment.
Discussed this on Slack, although not necessary (as metadata is dropped after stats), we are enforcing metadata in unit tests soon for non-stats queries, and I think it's better for consistency to just add it, as it does no harm (as far as I know), and makes all rules similar.
| | keep | ||
| @timestamp, | ||
| _id, | ||
| _index, | ||
| _version, | ||
| event.category, | ||
| event.action, | ||
| event.outcome, | ||
| source.ip, | ||
| process.name, | ||
| user.name, | ||
| event.dataset, | ||
| data_stream.namespace, | ||
| agent.id, | ||
| user.id |
There was a problem hiding this comment.
| | keep | |
| @timestamp, | |
| _id, | |
| _index, | |
| _version, | |
| event.category, | |
| event.action, | |
| event.outcome, | |
| source.ip, | |
| process.name, | |
| user.name, | |
| event.dataset, | |
| data_stream.namespace, | |
| agent.id, | |
| user.id |
Everything that is not used in the stats is dropped, makes more sense to do the KEEP after stats
There was a problem hiding this comment.
Adding KEEP after stats also makes no sense, because stats will only keep all fields within the by clause or used in the stats function, so it would not really do much. I mostly add keeps because the unit tests expect them. Think it is good to have a broader discussion about this in the new year.
There was a problem hiding this comment.
There are pros and cons for enforcing KEEP and placement. Performance (if any) for aggregation-based (use it before aggregating for performance). Otherwise by does a KEEP in theory. Non-aggregation-based, it can be used but forces limitations on fields that appear in the alert doc which I don't believe we want to practice doing. Maybe we follow-up with ES on the subject and if it is still best practice given our scenarios and rule examples.
|
|
||
| by source.ip | ||
|
|
||
| | where Esql.user_name_count_distinct > 10 and Esql.event_count >= 30 |
There was a problem hiding this comment.
| | where Esql.user_name_count_distinct > 10 and Esql.event_count >= 30 | |
| | where Esql.user_name_count_distinct > 10 and Esql.event_count >= 30 | |
| | keep Esql.*, source.ip |
…ck.toml Co-authored-by: Jonhnathan <26856693+w0rk3r@users.noreply.github.com>
|
⛔️ Test failed Results
|
|
⛔️ Test failed Results
|
Mikaayenson
left a comment
There was a problem hiding this comment.
One question that comes to mind is the bustiness of this. I think it's >10 unique users and >=30 failures in 1 min bucket? I wonder if we should expand the bucket e.g. 5 min or lower the counts?
|
⛔️ Test failed Results
|
|
⛔️ Test failed Results
|
|
⛔️ Test failed Results
|
|
@Mikaayenson expanded the interval slightly. |
Summary
This rule detects potential password spraying attacks via SSH by identifying multiple failed login attempts from a single source IP address targeting various user accounts within a short time frame. Password spraying is a technique where an attacker attempts to gain unauthorized access by trying a few commonly used passwords against many different accounts, rather than targeting a single account with multiple password attempts.