detection-rules icon indicating copy to clipboard operation
detection-rules copied to clipboard

[Rule Tuning] Process Potentially Masquerading as WerFault (+others)

Open dancs85 opened this issue 5 years ago • 6 comments

This rule is expecting that process arguments are included in an event, however arguments are only included if the event was generated by Sysmon (for winlogbeat-*). These events are also generated from the Windows Security channel but do not include arguments.

This rule should probably include 'and not event.provider: "Microsoft-Windows-Security-Auditing"' to avoid unnecessary alerts.

This issue will apply to a number of other Windows rules that require fields not includes with Security channel generated events.

dancs85 avatar Dec 05 '20 22:12 dancs85

Hey @dancs85 , thanks for reporting this (good point). can you share an example of JSON FP ? (hiding of course any sensitive info)

Samirbous avatar Dec 06 '20 15:12 Samirbous

Hi @Samirbous , see below for Security module example: { "_index": "winlogbeat-7.10.0-000001", "_type": "_doc", "_id": "f7NYNnYBEY5BcOdus1eE", "_version": 1, "_score": null, "_source": { "process": { "parent": { "name": "svchost.exe", "executable": "C:\\Windows\\System32\\svchost.exe" }, "name": "WerFault.exe", "pid": 13280, "executable": "C:\\Windows\\System32\\WerFault.exe" }, "agent": { "hostname": "xxxx", "name": "xxxx", "id": "fdc2558b-10b2-4caa-b8ba-eebea932490e", "ephemeral_id": "5101b6c6-23df-4778-8c3e-9d82b8787d92", "type": "winlogbeat", "version": "7.10.0" }, "winlog": { "computer_name": "xxxx", "process": { "pid": 4, "thread": { "id": 17500 } }, "keywords": [ "Audit Success" ], "logon": { "id": "0x3e7" }, "channel": "Security", "event_data": { "MandatoryLabel": "S-1-16-8192", "TargetLogonId": "0x120c7d", "SubjectUserName": "xxxx", "TokenElevationType": "%%1938", "SubjectDomainName": "WORKGROUP", "ProcessId": "0x3fa8", "TargetUserName": "xxxx", "SubjectLogonId": "0x3e7", "TargetDomainName": "xxxx", "SubjectUserSid": "S-1-5-18", "TargetUserSid": "xxxx" }, "opcode": "Info", "version": 2, "record_id": 1138625, "task": "Process Creation", "event_id": 4688, "provider_guid": "{54849625-5478-4994-a5ba-3e3b0328c30d}", "api": "wineventlog", "provider_name": "Microsoft-Windows-Security-Auditing" }, "log": { "level": "information" }, "message": "A new process has been created.\n\nCreator Subject:\n\tSecurity ID:\t\tS-1-5-18\n\tAccount Name:\t\txxxx\n\tAccount Domain:\t\tWORKGROUP\n\tLogon ID:\t\t0x3E7\n\nTarget Subject:\n\tSecurity ID:\t\txxxx\n\tAccount Name:\t\txxxx\n\tAccount Domain:\t\txxxx\n\tLogon ID:\t\t0x120C7D\n\nProcess Information:\n\tNew Process ID:\t\t0x33e0\n\tNew Process Name:\tC:\\Windows\\System32\\WerFault.exe\n\tToken Elevation Type:\t%%1938\n\tMandatory Label:\t\tS-1-16-8192\n\tCreator Process ID:\t0x3fa8\n\tCreator Process Name:\tC:\\Windows\\System32\\svchost.exe\n\tProcess Command Line:\t\n\nToken Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy.\n\nType 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account.\n\nType 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group.\n\nType 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator.", "environment": [ "xxxx" ], "@timestamp": "2020-12-06T04:07:08.222Z", "related": { "user": [ "xxxx", "xxxx" ] }, "ecs": { "version": "1.5.0" }, "host": { "hostname": "xxxx", "os": { "build": "19041.630", "kernel": "10.0.19041.630 (WinBuild.160101.0800)", "name": "Windows 10 Enterprise", "family": "windows", "version": "10.0", "platform": "windows" }, "ip": [ "fe80::4805:db45:13c1:2296", "10.34.20.161", "fe80::ec57:c249:3274:c94b", "169.254.201.75", "fe80::d5da:9676:e9e1:2a00", "169.254.42.0", "fe80::a00c:8723:5bfb:3ecf", "169.254.62.207", "fe80::98cf:cd0f:e2f5:1c48", "169.254.28.72", "fe80::9c77:9f01:8bdd:d8be", "192.168.80.1", "fe80::8587:f134:d67c:ff3", "172.24.48.1" ], "name": "xxxx", "id": "9db3f2c4-3829-448e-82fe-a26bdb7585ff", "mac": [ "98:e7:43:a8:3e:8e", "9e:b6:d0:9b:9b:ef", "ae:b6:d0:9b:9b:ef", "9c:b6:d0:9b:9b:ef", "9c:b6:d0:9b:9b:f0", "00:15:5d:21:60:67", "00:15:5d:c6:b2:e1" ], "architecture": "x86_64" }, "event": { "code": 4688, "provider": "Microsoft-Windows-Security-Auditing", "kind": "event", "created": "2020-12-06T04:07:38.765Z", "module": "security", "action": "created-process", "category": "process", "type": "start", "outcome": "success" }, "user": { "domain": "WORKGROUP", "name": "xxxx", "id": "S-1-5-18" } }, "fields": { "@timestamp": [ "2020-12-06T04:07:08.222Z" ], "event.created": [ "2020-12-06T04:07:38.765Z" ] }, "highlight": { "process.name": [ "@[email protected]@/kibana-highlighted-field@" ], "event.category": [ "@kibana-highlighted-field@process@/kibana-highlighted-field@" ], "event.type": [ "@kibana-highlighted-field@start@/kibana-highlighted-field@" ] }, "sort": [ 1607227628222 ] }

I do have the Sysmon equivalent of that exact alert too for comparison if required.

dancs85 avatar Dec 06 '20 21:12 dancs85

thanks for the example, the WerFault Masquerading rule has been already updated and converted to EQL, If you want to adjust the existing rule in KQL you can use "process.command_line : *" to avoid matches on events with missing Command Line value (4688 without cmdline logging enabled). Let me know if that solves the problem.

Samirbous avatar Dec 07 '20 08:12 Samirbous

Hello, Just updated to 7.11.2 and this rule is generating quite a bit of noise (I think /hope). Some examples:

image

Except for the noise, i'm also wondering how this EQL query works..

sequence by host.id, process.entity_id with maxspan = 5s
  [process where event.type:"start" and process.name : ("wermgr.exe", "WerFault.exe") and process.args_count == 1]
  [network where process.name : ("wermgr.exe", "WerFault.exe") and network.protocol != "dns" and
    network.direction == "outgoing" and destination.ip !="::1" and destination.ip !="127.0.0.1"
  ]

Do both:

[process where event.type:"start" and process.name : ("wermgr.exe", "WerFault.exe") and process.args_count == 1]

and

[network where process.name : ("wermgr.exe", "WerFault.exe") and network.protocol != "dns" and
    network.direction == "outgoing" and destination.ip !="::1" and destination.ip !="127.0.0.1"

have to be fulfilled with a timespan of 5s? I'm asking because I didn't enable network events yet for some hosts, but the rule is still triggering when only the process part has been found.

Grtz

Willem

willemdh avatar Mar 17 '21 12:03 willemdh

@willemdh hello, from the screenshot you've shared looks like process.args_count is more than 1 for werfault.exe, normally they shouldn't match on the first part of the sequence (process execution). can you share one example of json blob for the FPs matching this EQL rule ? also if no network events are collected that's another abnormal, the sequence should trigger when both queries are satisfied process and network with 5s time difference max).

Samirbous avatar Mar 17 '21 16:03 Samirbous

@Samirbous Ouch, I'm rly sry, seems I was looking at old signals generated by the previous version. Please forgive me and close this again.

willemdh avatar Mar 17 '21 20:03 willemdh