Skip to content

[Rule Tuning] PowerShell Script with Archive Compression Capabilities #7233

Backlog

Description

@FilipPwn

Link to Rule

https://github.com/elastic/detection-rules/blob/main/rules_building_block/collection_posh_compression.toml

Rule Tuning Type

False Negatives - Enhancing detection of true threats that were previously missed.

Description

In the rule, one of the included .NET compression function is ZipFile.CreateFromDirectory.

Rule would fire only if it is used with arguments:

 "CompressionLevel" or
 "CompressionMode" or
 "ZipArchiveMode"

but this function is not using those arguments, so it would never catch any use ZipFile.CreateFromDirectory.

Example Data

Example emulation:

Add-Type -A System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::CreateFromDirectory("C:\temp\x", "C:\temp\x.zip")
image

Link:
https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.zipfile.createfromdirectory

Proposed change

 event.category:process and host.os.type:windows and
 (
   powershell.file.script_block_text : (
     "IO.Compression.ZipFile" or
     "IO.Compression.ZipArchive" or
-    "ZipFile.CreateFromDirectory" or
     "IO.Compression.BrotliStream" or
     "IO.Compression.DeflateStream" or
     "IO.Compression.GZipStream" or
     "IO.Compression.ZLibStream"
   ) and
   powershell.file.script_block_text : (
     "CompressionLevel" or
     "CompressionMode" or
     "ZipArchiveMode"
   ) or
-  powershell.file.script_block_text : "Compress-Archive"
+  powershell.file.script_block_text : ("Compress-Archive" or "ZipFile.CreateFromDirectory")
 ) and

Activity

  1. added
    Rule: Tuning
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Rule: TuningTeam: TRADEcommunity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions