Detection rules › Elastic

Startup/Logon Script added to Group Policy Object

Status
production
Severity
medium
Author
Elastic
Source
github.com/elastic/detection-rules

Detects the modification of Group Policy Objects (GPO) to add a startup/logon script to users or computer objects.

MITRE ATT&CK coverage

Event coverage

Rule body elastic

[metadata]
creation_date = "2021/11/08"
integration = ["system", "windows"]
maturity = "production"
updated_date = "2026/05/04"

[rule]
author = ["Elastic"]
description = "Detects the modification of Group Policy Objects (GPO) to add a startup/logon script to users or computer objects."
false_positives = ["Legitimate Administrative Activity"]
index = ["logs-system.security*", "logs-windows.forwarded*", "winlogbeat-*"]
language = "eql"
license = "Elastic License v2"
name = "Startup/Logon Script added to Group Policy Object"
note = """## Triage and analysis

### Investigating Startup/Logon Script added to Group Policy Object

Group Policy Objects (GPOs) can be used by attackers to instruct arbitrarily large groups of clients to execute specified commands at startup, logon, shutdown, and logoff. This is done by creating or modifying the `scripts.ini` or `psscripts.ini` files. The scripts are stored in the following paths:
  - `<GPOPath>\\Machine\\Scripts\\`
  - `<GPOPath>\\User\\Scripts\\`

#### Possible investigation steps

- This attack abuses a legitimate mechanism of Active Directory, so it is important to determine whether the activity is legitimate and the administrator is authorized to perform this operation.
- Retrieve the contents of the `ScheduledTasks.xml` file, and check the `<Command>` and `<Arguments>` XML tags for any potentially malicious commands or binaries.
- Investigate other alerts associated with the user/host during the past 48 hours.
- Scope which objects may be compromised by retrieving information about which objects are controlled by the GPO.

### False positive analysis

- Verify if the execution is legitimately authorized and executed under a change management process.

### Related rules

- Group Policy Abuse for Privilege Addition - b9554892-5e0e-424b-83a0-5aef95aa43bf
- Scheduled Task Execution at Scale via GPO - 15a8ba77-1c13-4274-88fe-6bd14133861e

### Response and remediation

- Initiate the incident response process based on the outcome of the triage.
- The investigation and containment must be performed in every computer controlled by the GPO, where necessary.
- Remove the script from the GPO.
- Check if other GPOs have suspicious scripts attached.
- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
"""
references = [
    "https://github.com/atc-project/atc-data/blob/master/docs/Logging_Policies/LP_0025_windows_audit_directory_service_changes.md",
    "https://github.com/atc-project/atc-data/blob/f2bbb51ecf68e2c9f488e3c70dcdd3df51d2a46b/docs/Logging_Policies/LP_0029_windows_audit_detailed_file_share.md",
    "https://labs.f-secure.com/tools/sharpgpoabuse",
]
risk_score = 47
rule_id = "16fac1a1-21ee-4ca6-b720-458e3855d046"
setup = """## Setup

The following Windows audit policies must be enabled to generate the events used by this rule:
- [Audit Directory Service Changes](https://ela.st/audit-directory-service-changes)
- [Audit Detailed File Share](https://ela.st/audit-detailed-file-share)
"""
severity = "medium"
tags = [
    "Domain: Endpoint",
    "OS: Windows",
    "Use Case: Threat Detection",
    "Tactic: Privilege Escalation",
    "Data Source: Active Directory",
    "Resources: Investigation Guide",
    "Use Case: Active Directory Monitoring",
    "Data Source: Windows Security Event Logs",
]
timestamp_override = "event.ingested"
type = "eql"

query = '''
any where host.os.type == "windows" and event.code in ("5136", "5145") and
(
  (
    winlog.event_data.AttributeLDAPDisplayName : (
      "gPCMachineExtensionNames",
      "gPCUserExtensionNames"
    ) and
    winlog.event_data.AttributeValue : "*42B5FAAE-6536-11D2-AE5A-0000F87571E3*" and
    winlog.event_data.AttributeValue : (
      "*40B66650-4972-11D1-A7CA-0000F87571E3*",
      "*40B6664F-4972-11D1-A7CA-0000F87571E3*"
    )
  ) or
  (
    winlog.event_data.ShareName : "\\\\*\\SYSVOL" and
    winlog.event_data.RelativeTargetName : ("*\\scripts.ini", "*\\psscripts.ini") and
    winlog.event_data.AccessList:"*%%4417*"
  )
)
'''


[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1484"
name = "Domain or Tenant Policy Modification"
reference = "https://attack.mitre.org/techniques/T1484/"

[[rule.threat.technique.subtechnique]]
id = "T1484.001"
name = "Group Policy Modification"
reference = "https://attack.mitre.org/techniques/T1484/001/"

[[rule.threat.technique]]
id = "T1547"
name = "Boot or Logon Autostart Execution"
reference = "https://attack.mitre.org/techniques/T1547/"

[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 = "T1037"
name = "Boot or Logon Initialization Scripts"
reference = "https://attack.mitre.org/techniques/T1037/"

[rule.threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"

Stages and Predicates

Stage 1: any

winlog.event_data.AttributeLDAPDisplayName in ("gPCMachineExtensionNames", "gPCUserExtensionNames") and wildcard(winlog.event_data.AttributeValue, "*40B66650-4972-11D1-A7CA-0000F87571E3*", "*40B6664F-4972-11D1-A7CA-0000F87571E3*") and wildcard(winlog.event_data.AttributeValue, "*42B5FAAE-6536-11D2-AE5A-0000F87571E3*")

Stage 2: any

wildcard(winlog.event_data.AccessList, "*%%4417*") and wildcard(winlog.event_data.RelativeTargetName, "*\\scripts.ini", "*\\psscripts.ini") and wildcard(winlog.event_data.ShareName, "\\\\*\\SYSVOL")

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
winlog.event_data.AccessListwildcard
  • *%%4417* corpus 11 (sigma 8, elastic 2, splunk 1)
winlog.event_data.AttributeLDAPDisplayNamewildcard
  • gPCMachineExtensionNames corpus 7 (sigma 3, elastic 3, splunk 1)
  • gPCUserExtensionNames corpus 4 (sigma 2, elastic 2)
winlog.event_data.AttributeValuewildcard
  • *40B6664F-4972-11D1-A7CA-0000F87571E3* corpus 2 (sigma 1, elastic 1)
  • *40B66650-4972-11D1-A7CA-0000F87571E3* corpus 2 (sigma 1, elastic 1)
  • *42B5FAAE-6536-11D2-AE5A-0000F87571E3* corpus 2 (sigma 1, elastic 1)
winlog.event_data.RelativeTargetNamewildcard
  • *\psscripts.ini corpus 2 (sigma 1, elastic 1)
  • *\scripts.ini corpus 2 (sigma 1, elastic 1)
winlog.event_data.ShareNamewildcard
  • \\*\SYSVOL corpus 2 (elastic 2)