Skip to content
Threat Feed
medium advisory

Detection of PowerShell Execution Policy Weakening

Adversaries often downgrade PowerShell execution policies to execute unauthorized scripts, bypassing security controls by invoking the Set-ExecutionPolicy cmdlet with 'Unrestricted' or 'Bypass' parameters.

Attackers frequently attempt to bypass PowerShell's built-in security features, specifically the Execution Policy, to facilitate the execution of malicious scripts or payloads. The Set-ExecutionPolicy cmdlet is a common target for modification to lower security standards, specifically moving from default constrained settings to 'Unrestricted' or 'Bypass' states. This behavior is a common precursor to deploying lateral movement tools, credential harvesters, or secondary backdoors within a compromised Windows environment. Defensive teams should be aware that while some legitimate administrative tasks or automated installers (such as Chocolatey) may require such modifications, unauthorized execution of these commands by user-level processes or unexpected service accounts represents a significant indicator of malicious activity during the post-exploitation phase.

Attack Chain

  1. Initial access is established through phishing or exploit delivery to a workstation.
  2. The attacker executes a primary stager or drops a malicious script to disk.
  3. The attacker determines that the current PowerShell execution policy prevents the execution of the unsigned or remote-origin script.
  4. The attacker executes "Set-ExecutionPolicy -ExecutionPolicy Bypass" or "Unrestricted" via an interactive shell or automated script block.
  5. The system policy is downgraded, allowing the subsequent execution of the malicious script or payload without further prompt.
  6. The malicious payload executes, performing objectives such as credential dumping, discovery, or C2 beaconing.

Impact

Successful execution policy downgrades enable attackers to bypass security restrictions designed to prevent unauthorized script execution. This facilitates the deployment of malware, administrative tools, or weaponized scripts that would otherwise be blocked, increasing the likelihood of successful lateral movement and data exfiltration.

Recommendation

  • Enable PowerShell Script Block Logging (Event ID 4104) across the environment to capture the command line content necessary to identify this activity.
  • Deploy the Sigma rule below to monitor for unauthorized execution policy modifications.
  • Audit administrative usage of execution policy changes and establish a baseline of legitimate deployment processes to reduce noise from installers like Chocolatey.

Immediate actions

Enable PowerShell Script Block Logging (Event ID 4104) across all Windows endpoints

IT Operations 72h

Threat Hunt

Identify historical usage of Set-ExecutionPolicy in logs

T1059.001 medium high confidence hunt now

Data: Event ID 4104 (Script Block Logging)

Mitigations

Enforce Execution Policy via Group Policy (GPO) to prevent local user modification

short_term IT Security

T1059.001

Detection coverage 1

Detect PowerShell Execution Policy Weakening

medium

Detects changing the PowerShell script execution policy to a potentially insecure level using the Set-ExecutionPolicy cmdlet.

sigma tactics: execution techniques: T1059.001 sources: ps_script, windows

Detection queries are available on the platform. Get full rules →