Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigma correlations support: Event Count #1337

Closed
YamatoSecurity opened this issue May 3, 2024 · 3 comments · Fixed by #1357
Closed

Sigma correlations support: Event Count #1337

YamatoSecurity opened this issue May 3, 2024 · 3 comments · Fixed by #1357
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@YamatoSecurity
Copy link
Collaborator

YamatoSecurity commented May 3, 2024

@fukusuket Here is a (maybe) hard one for you. I'd like to start supporting sigma correlations starting with Event Count and Value Count types since we already have the logic for those with | count. We should probably start with Event Count as that is the easiest.

Both are explained here: https://github.com/SigmaHQ/sigma-specification/blob/version_2/Sigma_meta_rules.md

Event Count sample:

title: Many failed logins to the same computer
id: 0e95725d-7320-415d-80f7-004da920fc11
correlation:
  type: event_count
  rules:
    - e87bd730-df45-4ae9-85de-6c75369c5d29 # Logon Failure (Wrong Password)
    - 8afa97ce-a217-4f7c-aced-3e320a57756d # Logon Failure (User Does Not Exist)
  group-by:
    - Computer
  timespan: 5m
  condition:
    gte: 3

This is example uses multiple rules but at first we can just support one rule if that is easier.
Or you could create a generic rule with a new ID and the following logic to test:

logsource:
    product: windows
    service: security
detection:
    selection:
        Channel: Security
        EventID: 4625

This just detects any failed logon.

I think this should be the same as the following count rule:

logsource:
    product: windows
    service: security
detection:
    selection:
        Channel: Security
        EventID: 4625
    condition: selection | count() by Computer >= 3 
    timeframe: 5m

If there a 3 or more failed logons to the same Computer, then there will be an alert.

Things to consider:

  • There may be multiple rules... If it is difficult to implement checking multiple conditions from multiple rules then we might want to just start off by supporting one rule
  • Rules may be defined by name instead of ID so we need a way to look this up internally. Info: https://github.com/SigmaHQ/sigma-specification/blob/version_2/Sigma_meta_rules.md#related-rules
  • There may be multiple fields in group-by. I believe this means that, for example if Computer and IpAddress were defined in group-by then if the combination of the same ComputerName AND the same IpAddress reaches 3 or more, then we should give an alert.
@YamatoSecurity YamatoSecurity added the enhancement New feature or request label May 3, 2024
@YamatoSecurity YamatoSecurity added this to the v2.16.0 milestone May 3, 2024
@fukusuket
Copy link
Collaborator

Sounds very difficult :) But I would love to implement it!!💪

@fukusuket
Copy link
Collaborator

fukusuket commented Jun 2, 2024

New impl memo:

Related Sequence

rule parse

  • parse_rule_files
  • parse_correlation_rule_files(Vec<RuleNode>) -> Vec<RuleNode>
    • Vec<RuleNode>
    • ↓ partition(correlation)
    • Vec<RuleNode>,Vec<RuleNode>
      • RuleNode
      • ↓ map (RuleNode.yaml)
      • RuleNode
        • OrSelectionNode?
        • AggregationParseInfo
        • TimeFrameInfo
  • same sequence as is ?

func

  • compile_correlation_rule(Yaml, Vec<RuleNode>) -> DetectionNode
    • merge_related_rules(Vec<RuleNode>) -> DetectionNode

Error condition

  • Related rules does not exists in rule directory
  • Related rules support Only List
  • Correlation type except for event_count
  • Grouping support Only Map(not List) ... maybe
  • Condition support Only Map(not List)
  • does not support (in first PR)
    • Recursive Correlation
    • Multiple yaml in one file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants