Skip to content
Threat Feed
medium advisory

Detection of PowerShell Downloads from Code Hosting Services

This detection identifies PowerShell activity using native cmdlets to fetch payloads from raw-content URLs on code hosting platforms, a technique frequently abused for stage-one payload delivery.

Threat actors frequently abuse legitimate code hosting services like GitHub, GitLab, and Codeberg to stage and retrieve malicious payloads. By hosting payloads as "raw" content, attackers can use native Windows PowerShell cmdlets to download and execute scripts or binaries directly into memory or to disk, bypassing traditional perimeter defenses that might block unknown web domains. This activity is often associated with initial access or delivery stages of malware campaigns, including the Braodo Stealer. Detection engineers must distinguish between legitimate administrative tasks or developer workflows and unauthorized staging of executable content by correlating the PowerShell script block with the process ancestry, the destination path, and the file type retrieved.

Impact

Successful exploitation of this technique allows attackers to stage and execute malicious payloads within an environment. If unauthorized scripts (such as .ps1, .bat) or binaries (.exe, .dll) are retrieved and executed, it can lead to credential theft, persistence establishment, or full system compromise. The severity of the impact depends on the nature of the staged payload and the permissions of the account executing the script.

Recommendation

Prioritize the identification of unauthorized downloads from code hosting services by monitoring PowerShell Script Block Logging.

  • Enable PowerShell Script Block Logging (Event ID 4104) and ensure the ScriptBlockText field is ingested into the SIEM.
  • Deploy the provided Sigma rule to detect common PowerShell download patterns directed at GitHub, GitLab, or Codeberg raw content URLs.
  • Review administrative and developer workstation baseline activity to reduce noise from legitimate script and package management workflows.

Immediate actions

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

IT Operations 72h

Deploy the Detection Rule to SIEM for monitoring

Detection Engineering 48h

Threat Hunt

Search for script blocks containing both download cmdlets and github/gitlab/codeberg URL patterns

T1105 medium medium confidence hunt now

Data: Event ID 4104

Detection coverage 1

Detect PowerShell Download from Code Hosting Service

medium

Detects PowerShell script blocks using common download cmdlets to retrieve executable or script files from raw URLs on GitHub, GitLab, or Codeberg.

sigma tactics: command_and_control, execution techniques: T1059.001, T1105 sources: process_creation, windows

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