Windows PowerShell: Detect ScriptBlock Text Modifying Group Policy Settings

Alerts on PowerShell ScriptBlock content referencing Group Policy policy keys and specific security policy value names.

FreeUnreviewedSigmamediumv1
title: "Windows PowerShell: Detect ScriptBlock Text Modifying Group Policy Settings"
id: 32d8df7d-5d62-4923-88c9-c20654d7b462
related:
  - id: ada4b0c4-758b-46ac-9033-9004613a150d
    type: similar
  - id: b7216a7d-687e-4c8d-82b1-3080b2ad961f
    type: derived
status: test
description: This rule flags PowerShell ScriptBlock content that includes Windows Group Policy-related registry policy paths and specific Group Policy setting value names (e.g., GroupPolicyRefreshTime*, EnableSmartScreen, ShellSmartScreenLevel). Attackers can use GPO modifications to persist changes and impair defenses by manipulating security-relevant policy settings. The detection relies on ScriptBlock logging telemetry containing the matched strings within the ScriptBlockText field.
references:
  - https://github.com/redcanaryco/atomic-red-team/blob/40b77d63808dd4f4eafb83949805636735a1fd15/atomics/T1484.001/T1484.001.md
  - https://github.com/SigmaHQ/sigma/blob/master/rules/windows/powershell/powershell_script/posh_ps_modify_group_policy_settings.yml
author: frack113, Huntrule Team
date: 2022-08-19
tags:
  - attack.privilege-escalation
  - attack.defense-impairment
  - attack.t1484.001
logsource:
  product: windows
  category: ps_script
  definition: "Requirements: Script Block Logging must be enabled"
detection:
  selection_path:
    ScriptBlockText|contains: \SOFTWARE\Policies\Microsoft\Windows\System
  selection_key:
    ScriptBlockText|contains:
      - GroupPolicyRefreshTimeDC
      - GroupPolicyRefreshTimeOffsetDC
      - GroupPolicyRefreshTime
      - GroupPolicyRefreshTimeOffset
      - EnableSmartScreen
      - ShellSmartScreenLevel
  condition: all of selection_*
falsepositives:
  - Legitimate use
level: medium
license: DRL-1.1

What it detects

This rule flags PowerShell ScriptBlock content that includes Windows Group Policy-related registry policy paths and specific Group Policy setting value names (e.g., GroupPolicyRefreshTime*, EnableSmartScreen, ShellSmartScreenLevel). Attackers can use GPO modifications to persist changes and impair defenses by manipulating security-relevant policy settings. The detection relies on ScriptBlock logging telemetry containing the matched strings within the ScriptBlockText field.

Known false positives

  • Legitimate use

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.