From b025d3a7642bfc78baa705807217934df28ede5c Mon Sep 17 00:00:00 2001 From: Samirbous <64742097+Samirbous@users.noreply.github.com> Date: Wed, 27 Apr 2022 01:39:54 +0200 Subject: [PATCH] [New Rule] Potential Privileged Escalation via KrbRelayUp (#1940) * [New Rule] Potential Privileged Escalation via KrbRelayUp Identifies a suspicious local successful logon event where the Logon Package is kerberos, the remote address is set to localhost and the target user SID is the builtin local Administrator account, this may indicate an attempt to leverage a Kerberos relay attack variant that can be used to elevate privilege locally from filtered administrator token to a token with full System privileges. https://github.com/Dec0ne/KrbRelayUp DATA : ``` { "_index" : ".ds-logs-system.security-default-2022.04.12-000003", "_id" : "Cwy1YoABQhClK0XGfqEU", "_source" : { "agent" : { "name" : "02694w-win10", "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "type" : "filebeat", "ephemeral_id" : "6c751494-97a3-46aa-bab2-5baf01d17d04", "version" : "8.0.0" }, "process" : { "name" : "-", "pid" : 0, "executable" : "-" }, "winlog" : { "computer_name" : "02694w-win10.corpcorp.com", "process" : { "pid" : 688, "thread" : { "id" : 9384 } }, "keywords" : [ "Audit Success" ], "logon" : { "id" : "0x0", "type" : "Network" }, "channel" : "Security", "event_data" : { "LogonGuid" : "{daac0d7c-3273-752c-bf5d-ea1c60851819}", "TargetOutboundDomainName" : "-", "VirtualAccount" : "%%1843", "LogonType" : "3", "TransmittedServices" : "-", "SubjectLogonId" : "0x0", "LmPackageName" : "-", "TargetOutboundUserName" : "-", "KeyLength" : "0", "RestrictedAdminMode" : "-", "TargetLogonId" : "0xebd3d4", "SubjectUserName" : "-", "TargetLinkedLogonId" : "0x0", "ElevatedToken" : "%%1842", "SubjectDomainName" : "-", "TargetUserName" : "Administrator", "ImpersonationLevel" : "%%1833", "LogonProcessName" : "Kerberos", "TargetDomainName" : "CORPCORP.COM", "SubjectUserSid" : "S-1-0-0", "AuthenticationPackageName" : "Kerberos", "TargetUserSid" : "S-1-5-21-308926384-506822093-3341789130-500" }, "opcode" : "Info", "version" : 2, "record_id" : "59063", "task" : "Logon", "event_id" : "4624", "provider_guid" : "{54849625-5478-4994-a5ba-3e3b0328c30d}", "activity_id" : "{e22af019-58dd-0002-43f0-2ae2dd58d801}", "api" : "wineventlog", "provider_name" : "Microsoft-Windows-Security-Auditing" }, "log" : { "level" : "information" }, "elastic_agent" : { "id" : "77a829ec-a564-44d5-9bc4-61eeefbf783a", "version" : "8.0.0", "snapshot" : false }, "source" : { "port" : 50480, "ip" : "127.0.0.1", "domain" : "-" }, "message" : """An account was successfully logged on. Subject: Security ID: S-1-0-0 Account Name: - Account Domain: - Logon ID: 0x0 Logon Information: Logon Type: 3 Restricted Admin Mode: - Virtual Account: No Elevated Token: Yes Impersonation Level: Impersonation New Logon: Security ID: S-1-5-21-308926384-506822093-3341789130-500 Account Name: Administrator Account Domain: CORPCORP.COM Logon ID: 0xEBD3D4 Linked Logon ID: 0x0 Network Account Name: - Network Account Domain: - Logon GUID: {daac0d7c-3273-752c-bf5d-ea1c60851819} Process Information: Process ID: 0x0 Process Name: - Network Information: Workstation Name: - Source Network Address: 127.0.0.1 Source Port: 50480 Detailed Authentication Information: Logon Process: Kerberos Authentication Package: Kerberos Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon session is created. It is generated on the computer that was accessed. The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. The impersonation level field indicates the extent to which a process in the logon session can impersonate. The authentication information fields provide detailed information about this specific logon request. - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. - Transited services indicate which intermediate services have participated in this logon request. - Package name indicates which sub-protocol was used among the NTLM protocols. - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.""", "input" : { "type" : "winlog" }, "@timestamp" : "2022-04-25T21:07:15.306Z", "ecs" : { "version" : "1.12.0" }, "related" : { "ip" : [ "127.0.0.1" ], "user" : [ "Administrator" ] }, "data_stream" : { "namespace" : "default", "type" : "logs", "dataset" : "system.security" }, "host" : { "hostname" : "02694w-win10", "os" : { "build" : "18363.815", "kernel" : "10.0.18362.815 (WinBuild.160101.0800)", "name" : "Windows 10 Enterprise", "family" : "windows", "type" : "windows", "version" : "10.0", "platform" : "windows" }, "ip" : [ "fe80::7587:a5c1:5a7b:68f6", "172.16.66.25" ], "name" : "02694w-win10.corpcorp.com", "id" : "6a3c3ef2-208f-4d6f-90ee-b34f4e3fd160", "mac" : [ "00:50:56:03:c6:93" ], "architecture" : "x86_64" }, "event" : { "agent_id_status" : "verified", "ingested" : "2022-04-25T21:51:43Z", "code" : "4624", "provider" : "Microsoft-Windows-Security-Auditing", "kind" : "event", "created" : "2022-04-25T21:51:08.433Z", "action" : "logged-in", "category" : [ "authentication" ], "type" : [ "start" ], "dataset" : "system.security", "outcome" : "success" }, "user" : { "domain" : "CORPCORP.COM", "name" : "Administrator", "id" : "S-1-5-21-308926384-506822093-3341789130-500" } } } ``` * Update privilege_escalation_krbrelayup_suspicious_logon.toml * Update privilege_escalation_krbrelayup_suspicious_logon.toml * Update privilege_escalation_krbrelayup_suspicious_logon.toml * Update privilege_escalation_krbrelayup_suspicious_logon.toml * Update privilege_escalation_krbrelayup_suspicious_logon.toml * Update rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml Co-authored-by: Jonhnathan * Update rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml Co-authored-by: Justin Ibarra * Update etc/non-ecs-schema.json Co-authored-by: Justin Ibarra * relinted Co-authored-by: Jonhnathan Co-authored-by: Justin Ibarra (cherry picked from commit a0672c7d2a9877ab4d69421c77a5fa6b7f00c692) --- etc/non-ecs-schema.json | 4 +- ...scalation_krbrelayup_suspicious_logon.toml | 74 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml diff --git a/etc/non-ecs-schema.json b/etc/non-ecs-schema.json index 607d4fc23..a3173e65b 100644 --- a/etc/non-ecs-schema.json +++ b/etc/non-ecs-schema.json @@ -37,7 +37,9 @@ "TargetLogonId": "keyword", "TargetProcessGUID": "keyword", "TargetSid": "keyword", - "PrivilegeList": "keyword" + "PrivilegeList": "keyword", + "AuthenticationPackageName" : "keyword", + "TargetUserSid" : "keyword" } }, "winlog.logon.type": "keyword", diff --git a/rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml b/rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml new file mode 100644 index 000000000..7c1738470 --- /dev/null +++ b/rules/windows/privilege_escalation_krbrelayup_suspicious_logon.toml @@ -0,0 +1,74 @@ +[metadata] +creation_date = "2022/04/26" +maturity = "production" +updated_date = "2022/04/26" + +[rule] +author = ["Elastic"] +description = """ +Identifies a suspicious local successful logon event where the Logon Package is Kerberos, the remote address is set to +localhost, and the target user SID is the built-in local Administrator account. This may indicate an attempt to leverage +a Kerberos relay attack variant that can be used to elevate privilege locally from a domain joined limited user to local +System privileges. +""" +from = "now-9m" +index = ["winlogbeat-*", "logs-system.*"] +language = "eql" +license = "Elastic License v2" +name = "Potential Privilege Escalation via Local Kerberos Relay over LDAP" +references = [ + "https://github.com/Dec0ne/KrbRelayUp", + "https://googleprojectzero.blogspot.com/2021/10/using-kerberos-for-authentication-relay.html", + "https://github.com/cube0x0/KrbRelay", +] +risk_score = 73 +rule_id = "3605a013-6f0c-4f7d-88a5-326f5be262ec" +severity = "high" +tags = ["Elastic", "Host", "Windows", "Threat Detection", "Privilege Escalation", "Credential Access"] +type = "eql" + +query = ''' +authentication where + + /* event 4624 need to be logged */ + event.action == "logged-in" and event.outcome == "success" and + + /* authenticate locally via relayed kerberos ticket */ + winlog.event_data.AuthenticationPackageName : "Kerberos" and winlog.logon.type == "Network" and + source.ip == "127.0.0.1" and source.port > 0 and + + /* Impersonate Administrator user via S4U2Self service ticket */ + winlog.event_data.TargetUserSid : "S-1-5-21-*-500" +''' + + +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1548" +name = "Abuse Elevation Control Mechanism" +reference = "https://attack.mitre.org/techniques/T1548/" +[[rule.threat.technique.subtechnique]] +id = "T1548.002" +name = "Bypass User Account Control" +reference = "https://attack.mitre.org/techniques/T1548/002/" + + + +[rule.threat.tactic] +id = "TA0004" +name = "Privilege Escalation" +reference = "https://attack.mitre.org/tactics/TA0004/" +[[rule.threat]] +framework = "MITRE ATT&CK" +[[rule.threat.technique]] +id = "T1558" +name = "Steal or Forge Kerberos Tickets" +reference = "https://attack.mitre.org/techniques/T1558/" + + +[rule.threat.tactic] +id = "TA0006" +name = "Credential Access" +reference = "https://attack.mitre.org/tactics/TA0006/" +