Detection rules › Splunk

Package installation (PowerShell)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Some programming languages, like Python, come with an easy, more or less official method of installing dependencies for your projects. These installers are usually tied to public code repositories where anyone can freely upload code packages for others to use. The intent of this use case is to identify installation of packages, with common repositories using pip, gem and npm. Use case will be used to with additional threat identifiers to potentially identify Dependency confusion style attacks.

MITRE ATT&CK coverage

TacticTechniques
Command & Control

References

Telemetry coverage

Rule body

id: '5987.6350'
title: Package installation
description: 'Some programming languages, like Python, come with an easy, more or
  less official method of installing dependencies for your projects. These installers
  are usually tied to public code repositories where anyone can freely upload code
  packages for others to use. The intent of this use case is to identify installation
  of packages, with common repositories using pip, gem and npm. Use case will be used
  to with additional threat identifiers to potentially identify Dependency confusion
  style attacks. '
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` TERM(EventCode=4104) (TERM(npm)
  OR TERM(pip) OR TERM(gem)) TERM(install) | regex process="(?i)install\s" | rex field=process
  "(?<reqs>(?i)requirements\.txt") | rex field=process "(?<extra>(?i)(\-{2}extra)?\-index\-url(\s+\S+)")
  | rex field=process "(?<source1>(?i)\-{2}source(\s+\S+)") | eval keywords=mvappend(reqs,
  extra, source1) | table _time, host, user, signature_id, process, process_*, keywords
  | bin span=1s | stats values(*) as * by _time, host '
techniques:
- command-and-control:ingress tool transfer
technique_id: 
- T1105
data_category:
- PowerShell logs
references:
- https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_powershell` TERM(EventCode=4104) (TERM(npm) OR TERM(pip) OR TERM(gem)) TERM(install)

Stage 2: regex

| regex process="(?i)install\s"

Stage 3: rex

| rex field=process "(?<reqs>(?i)requirements\.txt")

The parser skipped this rex command.

Stage 4: rex

| rex field=process "(?<extra>(?i)(\-{2}extra)?\-index\-url(\s+\S+)")

The parser skipped this rex command.

Stage 5: rex

| rex field=process "(?<source1>(?i)\-{2}source(\s+\S+)")

The parser skipped this rex command.

Stage 6: eval

| eval keywords=mvappend(reqs, extra, source1)

Stage 7: table

| table _time, host, user, signature_id, process, process_*, keywords

Stage 8: bucket

| bin span=1s

Stage 9: stats

| stats values(*) as * by _time, host

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 4104 corpus 269 (splunk 269)
field:"EventID" kind:eq value:"4104"
processregex_match
  • "(?i)install\s" corpus 3 (splunk 3)
field:"CommandLine" kind:regex_match

Search terms

These SPL tokens match against raw event text.

StageTerm
1npm
1pip
1gem
1install