sigma icon indicating copy to clipboard operation
sigma copied to clipboard

Schema definition clarification/mod needed

Open SherifEldeeb opened this issue 8 years ago • 4 comments

The schema defines condition as str. Yet it is mentioned in the specs that

If multiple conditions are given, they are logically linked with OR.

without defining how could that be possible... the only example I found was (https://github.com/Neo23x0/sigma/blob/master/rules/network/net_susp_network_scan.yml).

So, either:

  • A) Update the schema to mention that condition could be either a str or list,
  • B) condition remains a str and fix the parser (sigmac?) to allow for multiple pipes/parentheses/ORs, or
  • C) fix condition to be a list and update all rules accordingly (all existing rules will have a single-item list for their condition)

Sorry for being picky :D, working on something which will have a sigma rule parser and being consistent is a good base to build on...

P.S: Changing the above mentioned rule from

    condition:
        - selection | count(dst_port) by src_ip > 10
        - selection | count(dst_ip) by src_ip > 10

to condition: ( selection | count(dst_port) by src_ip > 10 ) or ( selection | count(dst_ip) by src_ip > 10 ) broke sigmac, complaining about unmatched closing parentheses (maybe because it improperly parses after the pipe token)

P.P.S: I'll gladly update all rules to match whatever decision will be made.

SherifEldeeb avatar Jan 28 '18 15:01 SherifEldeeb

Actually there are few discrepancies between the schema and the rules every now and then ... author is defined as str, but here it's a list: https://github.com/Neo23x0/sigma/blob/master/rules/windows/sysmon/sysmon_susp_certutil_command.yml

Sorry for bringing this over and over, I already do check for those issues in the code that parses the rules, but consistency between the schema and the sample rules will make a better case for wider sigma adoption.

SherifEldeeb avatar Jan 29 '18 11:01 SherifEldeeb

Factually, sigmac currently implements A, but the specification defines str. Fixing it to str and adding the or syntax to conditions would make the parsing harder and the condition harder to read in my opinion. Same for author: list-only would add unneeded single-item lists to many rules while str-only will make rules with multiple authors unstructured.

On the whole, I think we should keep this flexibility in Sigma and allow str and list. Unfortunately, the used Schema language (Kwalify) doesn't support such alternatives, while Rx does. A switch to Rx could give us this flexibility. I discuss this with Florian.

thomaspatzke avatar Jan 29 '18 20:01 thomaspatzke

Ok, following plan: we switch to a Rx schema definition with alternatives.

thomaspatzke avatar Feb 01 '18 21:02 thomaspatzke

Schema has updated to Rx schema with possibilities for strings and lists of strings mentioned above.

thomaspatzke avatar Feb 05 '18 22:02 thomaspatzke