elastic / detection-rules

https://www.elastic.co/guide/en/security/current/detection-engine-overview.html
Other
1.92k stars 492 forks source link

[Rule Tuning] Microsoft IIS Service Account Password Dumped #3935

Closed w0rk3r closed 2 months ago

w0rk3r commented 2 months ago

Issues

Resolves #3807

Summary

Changes the args we look for in this rule to match the syntax that actually works and removed the password keyword as it is not needed to obtain passwords. I've moved this one to BBR so we can validate the noise of this change and tune it before reintroducing it as a normal DR, as we don't have any TP telemetry.

Data

Sample Event ``` { "_index": ".ds-logs-endpoint.events.process-default-2024.07.12-000026", "_id": "Mgl6CZEBiLqpmBCYtAJu", "_score": 1, "_source": { "agent": { "id": "c725ae87-e846-4602-9a08-2c717a3a504b", "type": "endpoint", "version": "8.14.2" }, "process": { "Ext": { "mitigation_policies": [ "CF Guard" ], "ancestry": [ "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTEwMTkyLTE3MjI0NDA2ODMuMzEzOTUwOTAw", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTYyMjQtMTcyMjI5MzE4MS4zNTUwODc0MDA=", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTgxMi0xNzIyMjkzMTgxLjI3NzgwOTcwMA==", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTY3Mi0xNzIyMjUwMzY4LjEyOTg3MTAwMA==" ], "code_signature": [ { "trusted": true, "subject_name": "Microsoft Windows", "exists": true, "status": "trusted" } ], "session_info": { "authentication_package": "Kerberos", "relative_password_age": 1815857.0507085, "user_flags": [ "LOGON_EXTRA_SIDS", "LOGON_WINLOGON" ], "relative_logon_time": 147713.5745794, "id": 1, "logon_type": "Interactive" }, "relative_file_creation_time": 185444653.4212362, "authentication_id": "0x2e8b75f", "relative_file_name_modify_time": 101645988.4863966, "token": { "integrity_level_name": "high", "security_attributes": [ "TSA://ProcUnique" ], "elevation_level": "full" } }, "parent": { "Ext": { "code_signature": [ { "trusted": true, "subject_name": "Microsoft Windows", "exists": true, "status": "trusted" } ] }, "args": [ "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" ], "code_signature": { "trusted": true, "subject_name": "Microsoft Windows", "exists": true, "status": "trusted" }, "name": "powershell.exe", "pid": 10192, "args_count": 1, "thread": { "Ext": { "call_stack_summary": "ntdll.dll|kernelbase.dll|kernel32.dll|system.ni.dll|system.management.automation.ni.dll|Unbacked", "call_stack_contains_unbacked": true, "call_stack": [ { "symbol_info": "C:\\Windows\\System32\\ntdll.dll!ZwCreateUserProcess+0x14" }, { "symbol_info": "C:\\Windows\\System32\\KernelBase.dll!CreateProcessInternalW+0x1f12" }, { "symbol_info": "C:\\Windows\\System32\\KernelBase.dll!CreateProcessW+0x66" }, { "symbol_info": "C:\\Windows\\System32\\kernel32.dll!CreateProcessW+0x53" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x334376" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x2b65a0" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x2b5f47" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf7fc5b" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xed9f9d" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf5cb0e" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf5c7eb" }, { "symbol_info": "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0x104fca4" }, { "symbol_info": "Unbacked+0x3211", "callsite_trailing_bytes": "834648fab8010000004883c4685b5d5e5f415c415d415e415fc3e8c02a945fcc0000001910090010c20c300b500a60097008c006d004e002f000004000000000", "protection": "RWX", "callsite_leading_bytes": "2428f6c1017404488b49ffe8af9b5d5f4889442430498bd5448b44245c4c8b4c2448488b6c244048896c2420488b6c243848896c2428488d4b08488b09ff5318" } ] } }, "entity_id": "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTEwMTkyLTE3MjI0NDA2ODMuMzEzOTUwOTAw", "command_line": "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" ", "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" }, "pid": 5708, "working_directory": "C:\\Windows\\System32\\inetsrv\\", "entity_id": "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTU3MDgtMTcyMjQ0MDg5Mi40MzU1Mzc0MDA=", "executable": "C:\\Windows\\System32\\inetsrv\\appcmd.exe", "args": [ "C:\\Windows\\System32\\inetsrv\\appcmd.exe", "list", "apppool", "WsusPool", "/text:*" ], "code_signature": { "trusted": true, "subject_name": "Microsoft Windows", "exists": true, "status": "trusted" }, "pe": { "imphash": "0c59ba75971a266506603cef51da9ceb", "original_file_name": "appcmd.exe" }, "name": "appcmd.exe", "args_count": 5, "command_line": "\"C:\\Windows\\System32\\inetsrv\\appcmd.exe\" list apppool WsusPool /text:*", "hash": { "sha1": "fcd71b4916276d196f460b0a976efbb8adf3ec63", "sha256": "429bc84babe1387abf59eefb0b225a1f5317fdb1d3f29995dbd5604e78b3ac33", "md5": "698a7b8dcf5b3f2f0cc15b2a6b18e360" } }, "@timestamp": "2024-07-31T15:48:12.4355374Z", "ecs": { "version": "8.10.0" }, "data_stream": { "namespace": "default", "type": "logs", "dataset": "endpoint.events.process" }, "elastic": { "agent": { "id": "c725ae87-e846-4602-9a08-2c717a3a504b" } }, "host": { "hostname": "kingslanding", "os": { "Ext": { "variant": "Windows Server 2019 Datacenter Evaluation" }, "kernel": "1809 (10.0.17763.1935)", "name": "Windows", "family": "windows", "type": "windows", "version": "1809 (10.0.17763.1935)", "platform": "windows", "full": "Windows Server 2019 Datacenter Evaluation 1809 (10.0.17763.1935)" }, "domain": "sevenkingdoms.local", "ip": [ "192.168.56.10", "192.168.133.195", "127.0.0.1", "::1" ], "name": "kingslanding", "id": "bb11c0d0-189a-4fad-aa85-e71a5b6c7ed9", "mac": [ "00-0c-29-f8-cf-09", "00-0c-29-f8-cf-ff" ], "architecture": "x86_64" }, "event": { "agent_id_status": "verified", "sequence": 1478750, "ingested": "2024-07-31T15:48:42Z", "created": "2024-07-31T15:48:12.4355374Z", "kind": "event", "module": "endpoint", "action": "start", "id": "NeRojTexa6/KxECF++++lFIa", "category": [ "process" ], "type": [ "start" ], "dataset": "endpoint.events.process", "outcome": "unknown" }, "message": "Endpoint process event", "user": { "domain": "SEVENKINGDOMS", "name": "robert.baratheon", "id": "S-1-5-21-3715621034-4113696668-281506975-1117" } }, "fields": { "process.hash.md5": [ "698a7b8dcf5b3f2f0cc15b2a6b18e360" ], "host.os.full.text": [ "Windows Server 2019 Datacenter Evaluation 1809 (10.0.17763.1935)" ], "process.command_line.caseless": [ "\"c:\\windows\\system32\\inetsrv\\appcmd.exe\" list apppool wsuspool /text:*" ], "event.category": [ "process" ], "host.os.name.text": [ "Windows" ], "process.parent.command_line": [ "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" " ], "process.parent.name": [ "powershell.exe" ], "process.hash.sha256": [ "429bc84babe1387abf59eefb0b225a1f5317fdb1d3f29995dbd5604e78b3ac33" ], "process.parent.pid": [ 10192 ], "host.hostname": [ "kingslanding" ], "host.mac": [ "00-0c-29-f8-cf-09", "00-0c-29-f8-cf-ff" ], "process.code_signature.exists": [ true ], "elastic.agent.id": [ "c725ae87-e846-4602-9a08-2c717a3a504b" ], "host.domain": [ "sevenkingdoms.local" ], "host.os.version": [ "1809 (10.0.17763.1935)" ], "event.agent_id_status": [ "verified" ], "event.outcome": [ "unknown" ], "host.os.type": [ "windows" ], "user.id": [ "S-1-5-21-3715621034-4113696668-281506975-1117" ], "process.Ext.ancestry": [ "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTEwMTkyLTE3MjI0NDA2ODMuMzEzOTUwOTAw", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTYyMjQtMTcyMjI5MzE4MS4zNTUwODc0MDA=", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTgxMi0xNzIyMjkzMTgxLjI3NzgwOTcwMA==", "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTY3Mi0xNzIyMjUwMzY4LjEyOTg3MTAwMA==" ], "host.architecture": [ "x86_64" ], "agent.id": [ "c725ae87-e846-4602-9a08-2c717a3a504b" ], "process.parent.code_signature.trusted": [ true ], "process.command_line.text": [ "\"C:\\Windows\\System32\\inetsrv\\appcmd.exe\" list apppool WsusPool /text:*" ], "process.Ext.relative_file_creation_time": [ 185444653.4212362 ], "process.parent.thread.Ext.call_stack_contains_unbacked": [ true ], "user.name": [ "robert.baratheon" ], "process.working_directory": [ "C:\\Windows\\System32\\inetsrv\\" ], "process.entity_id": [ "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTU3MDgtMTcyMjQ0MDg5Mi40MzU1Mzc0MDA=" ], "process.parent.code_signature.status": [ "trusted" ], "host.ip": [ "192.168.56.10", "192.168.133.195", "127.0.0.1", "::1" ], "process.executable.caseless": [ "c:\\windows\\system32\\inetsrv\\appcmd.exe" ], "agent.type": [ "endpoint" ], "process.pe.original_file_name": [ "appcmd.exe" ], "process.executable.text": [ "C:\\Windows\\System32\\inetsrv\\appcmd.exe" ], "process.parent.thread.Ext.call_stack.protection": [ "RWX" ], "user.domain": [ "SEVENKINGDOMS" ], "host.id": [ "bb11c0d0-189a-4fad-aa85-e71a5b6c7ed9" ], "process.name.caseless": [ "appcmd.exe" ], "process.Ext.token.integrity_level_name": [ "high" ], "process.parent.name.caseless": [ "powershell.exe" ], "process.working_directory.text": [ "C:\\Windows\\System32\\inetsrv\\" ], "process.Ext.session_info.user_flags": [ "LOGON_EXTRA_SIDS", "LOGON_WINLOGON" ], "process.code_signature.status": [ "trusted" ], "host.os.Ext.variant": [ "Windows Server 2019 Datacenter Evaluation" ], "event.action": [ "start" ], "event.ingested": [ "2024-07-31T15:48:42Z" ], "@timestamp": [ "2024-07-31T15:48:12.435Z" ], "host.os.platform": [ "windows" ], "process.parent.command_line.caseless": [ "\"c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe\" " ], "data_stream.dataset": [ "endpoint.events.process" ], "process.Ext.code_signature": [ { "trusted": [ true ], "subject_name": [ "Microsoft Windows" ], "exists": [ true ], "status": [ "trusted" ] } ], "process.hash.sha1": [ "fcd71b4916276d196f460b0a976efbb8adf3ec63" ], "event.id": [ "NeRojTexa6/KxECF++++lFIa" ], "host.os.name.caseless": [ "windows" ], "process.parent.thread.Ext.call_stack.symbol_info": [ "C:\\Windows\\System32\\ntdll.dll!ZwCreateUserProcess+0x14", "C:\\Windows\\System32\\KernelBase.dll!CreateProcessInternalW+0x1f12", "C:\\Windows\\System32\\KernelBase.dll!CreateProcessW+0x66", "C:\\Windows\\System32\\kernel32.dll!CreateProcessW+0x53", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x334376", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x2b65a0", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System\\97ca54a1c8839381ba1ed5463f15c706\\System.ni.dll+0x2b5f47", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf7fc5b", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xed9f9d", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf5cb0e", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0xf5c7eb", "C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\System.Manaa57fc8cc#\\c14ebad3ad3b35f8d690b67e24b08072\\System.Management.Automation.ni.dll+0x104fca4", "Unbacked+0x3211" ], "user.name.text": [ "robert.baratheon" ], "process.Ext.session_info.authentication_package": [ "Kerberos" ], "process.name.text": [ "appcmd.exe" ], "host.os.full": [ "Windows Server 2019 Datacenter Evaluation 1809 (10.0.17763.1935)" ], "process.parent.thread.Ext.call_stack.callsite_leading_bytes": [ "2428f6c1017404488b49ffe8af9b5d5f4889442430498bd5448b44245c4c8b4c2448488b6c244048896c2420488b6c243848896c2428488d4b08488b09ff5318" ], "process.pid": [ 5708 ], "process.code_signature.subject_name": [ "Microsoft Windows" ], "process.parent.entity_id": [ "YzcyNWFlODctZTg0Ni00NjAyLTlhMDgtMmM3MTdhM2E1MDRiLTEwMTkyLTE3MjI0NDA2ODMuMzEzOTUwOTAw" ], "host.os.name": [ "Windows" ], "host.name": [ "kingslanding" ], "event.kind": [ "event" ], "process.parent.thread.Ext.call_stack.callsite_trailing_bytes": [ "834648fab8010000004883c4685b5d5e5f415c415d415e415fc3e8c02a945fcc0000001910090010c20c300b500a60097008c006d004e002f000004000000000" ], "process.code_signature.trusted": [ true ], "process.Ext.session_info.relative_logon_time": [ 147713.5745794 ], "process.Ext.session_info.relative_password_age": [ 1815857.0507085 ], "process.parent.thread.Ext.call_stack_summary": [ "ntdll.dll|kernelbase.dll|kernel32.dll|system.ni.dll|system.management.automation.ni.dll|Unbacked" ], "data_stream.type": [ "logs" ], "process.parent.args_count": [ 1 ], "process.Ext.token.security_attributes": [ "TSA://ProcUnique" ], "process.name": [ "appcmd.exe" ], "ecs.version": [ "8.10.0" ], "process.parent.executable.text": [ "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" ], "event.created": [ "2024-07-31T15:48:12.435Z" ], "agent.version": [ "8.14.2" ], "host.os.family": [ "windows" ], "process.Ext.session_info.id": [ 1 ], "process.Ext.mitigation_policies": [ "CF Guard" ], "process.parent.code_signature.exists": [ true ], "process.parent.name.text": [ "powershell.exe" ], "event.sequence": [ 1478750 ], "event.module": [ "endpoint" ], "host.os.kernel": [ "1809 (10.0.17763.1935)" ], "process.Ext.relative_file_name_modify_time": [ 101645988.4863966 ], "host.os.full.caseless": [ "windows server 2019 datacenter evaluation 1809 (10.0.17763.1935)" ], "process.executable": [ "C:\\Windows\\System32\\inetsrv\\appcmd.exe" ], "process.parent.code_signature.subject_name": [ "Microsoft Windows" ], "process.parent.executable.caseless": [ "c:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe" ], "process.parent.executable": [ "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" ], "process.working_directory.caseless": [ "c:\\windows\\system32\\inetsrv\\" ], "process.parent.command_line.text": [ "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" " ], "process.args_count": [ 5 ], "data_stream.namespace": [ "default" ], "process.parent.Ext.code_signature": [ { "trusted": [ true ], "subject_name": [ "Microsoft Windows" ], "exists": [ true ], "status": [ "trusted" ] } ], "process.args": [ "C:\\Windows\\System32\\inetsrv\\appcmd.exe", "list", "apppool", "WsusPool", "/text:*" ], "message": [ "Endpoint process event" ], "process.Ext.authentication_id": [ "0x2e8b75f" ], "process.Ext.token.elevation_level": [ "full" ], "process.parent.args": [ "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" ], "process.pe.imphash": [ "0c59ba75971a266506603cef51da9ceb" ], "event.type": [ "start" ], "process.command_line": [ "\"C:\\Windows\\System32\\inetsrv\\appcmd.exe\" list apppool WsusPool /text:*" ], "process.Ext.session_info.logon_type": [ "Interactive" ], "event.dataset": [ "endpoint.events.process" ] } } ```
protectionsmachine commented 2 months ago

Rule: Tuning - Guidelines

These guidelines serve as a reminder set of considerations when tuning an existing rule.

Documentation and Context

Rule Metadata Checks

Testing and Validation