Skip to content
Threat Feed
critical advisory

Detecting Malicious Activity within Package Manager Installation Ancestry

This detection logic identifies suspicious subprocess activity originating from software package manager installation processes (npm, pip, uv, poetry, cargo) to surface potential supply-chain compromises.

The detection logic targets supply-chain and post-installation abuse by monitoring for malicious behavior stemming from package manager installation processes. Attackers frequently exploit the package installation lifecycle - such as 'postinstall' hooks in npm, 'setup.py' in Python, or build scripts in Cargo - to execute arbitrary code, establish persistence, or exfiltrate credentials.

This rule monitors Elastic Defend alerts (including behavioral, file, memory, and shellcode detections) to determine if the alerted process has a known package manager (npm, pip/PyPI, or cargo) in its process ancestry. By utilizing ES|QL and process ancestry analysis, the rule effectively correlates benign installation commands with descendant processes that exhibit anomalous security events. This capability is critical for environments utilizing CI/CD pipelines, automated build systems, or developer workstations where third-party dependency compromise is a persistent risk.

Impact

Successful exploitation of the software supply chain allows attackers to gain initial access, maintain persistence, and execute code with the privileges of the package installer. This can lead to unauthorized access to sensitive source code, internal network reconnaissance, theft of development secrets, or the poisoning of build artifacts.

Recommendation

Prioritize alerts generated by this logic to identify potential dependency confusion or compromised package installations.

  • Deploy the ES|QL detection query to identify security alerts originating from descendant processes of package managers.
  • Investigate the specific package installation command (npm, pip, cargo) identified in the process ancestry to determine if it aligns with known legitimate development or CI/CD activity.
  • Review all descendant processes of the installation tree for unauthorized network connections or file system modifications.
  • Tune the detection logic by excluding known-safe internal build scripts or authorized CI/CD runner paths if false positives occur.
  • Audit third-party dependencies used within the organization to reduce exposure to malicious packages.

Immediate actions

Deploy the Elastic Defend package ancestry rule to monitor for suspicious post-install script behavior.

Detection Engineering 72h

Threat Hunt

Identify all processes spawned by npm, pip, or cargo installation commands across build nodes.

T1195.002 high medium confidence hunt now

Data: Process creation logs with ancestry information.

Mitigations

Implement strict dependency pinning and private repository mirrors for third-party libraries.

medium_term IT Operations

Supply Chain Compromise (T1195.002)