Detection rules › Splunk
Package installation (Sysmon)
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
| Tactic | Techniques |
|---|---|
| Command & Control |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 1: Process creation |
Rule body
id: '5987.18207'
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_sysmon` ("EventCode=1" OR "<EventID>1<")
(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_*, parent_*,
keyword | bin span=1s | stats values(*) as * by _time, host '
techniques:
- command-and-control:ingress tool transfer
technique_id:
- T1105
data_category:
- Windows Sysmon
references:
- https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_sysmon` ("EventCode=1" OR "<EventID>1<") (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")
Stage 4: rex
| rex field=process "(?<extra>(?i)(\-{2}extra)?\-index\-url(\s+\S+)")
Stage 5: rex
| rex field=process "(?<source1>(?i)\-{2}source(\s+\S+)")
Stage 6: eval
| eval keywords=mvappend(reqs, extra, source1)
Stage 7: table
| table _time, host, user, signature_id, process, process_*, parent_*, keyword
Stage 8: bucket
| bin span=1s
Stage 9: stats
| stats values(*) as * by _time, host
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
process | regex_match |
| field:"CommandLine" kind:regex_match |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | "EventCode=1" |
| 1 | "<EventID>1<" |
| 1 | npm |
| 1 | pip |
| 1 | gem |
| 1 | install |