Back to skill

Security audit

PM2 Process Manager

Security checks for vulnerabilities and agentic risk

Overview

This PM2 skill is a straightforward command reference, but users should be careful with its boot-startup and cleanup commands because they can affect running services.

Install only from the expected npm registry, avoid running npm or PM2 setup from an elevated shell unless required, review the exact pm2 startup command before using sudo, and verify the PM2 process list before running pm2 save, pm2 delete all, pm2 kill, or pm2 unstartup on a production host.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T06 · System Persistence

Error
Location
SKILL.md:54
Finding
PM2 Boot-Time Persistence Configuration## Vulnerability Details **File Location**: `SKILL.md`, lines 54-62 **Vulnerability Type**: `T06: System Persistence` **Risk Level**: High **Vulnerable Code**: ```bash ## Auto-Start on Boot ```bash # Save current process list pm2 save # Generate startup script (run the output command with sudo) pm2 startup # Example output - run this: # sudo env PATH=$PATH:/opt/homebrew/bin pm2 startup launchd -u username --hp /Users/username ``` ### Technical Analysis The documented workflow saves the current PM2 process list and generates an operating-system startup integration. The generated command may be executed with `sudo`, allowing the configured PM2 applications to start automatically after reboot. Although this functionality is consistent with PM2's intended operational purpose and is explicitly disclosed, it creates cross-session persistence. If an untrusted application, command, or ecosystem configuration has previously been added to PM2, saving the process list and enabling startup will make that payload execute automatically on subsequent boots. ### Attack Path 1. An attacker causes a user to start an attacker-controlled application or PM2 ecosystem configuration. 2. The application becomes part of the active PM2 process list. 3. The user follows the Skill and runs `pm2 save`. 4. The user runs `pm2 startup` and executes its generated command with `sudo`. 5. PM2 restores the saved process list after reboot. 6. The attacker-controlled application executes persistently under the configured PM2 account. ### Impact Assessment Successful exploitation provides recurring execution after system reboot under the account configured for PM2. The payload normally inherits that account's permissions. The startup installation itself may require administrative privileges, increasing system-level impact, although managed applications do not necessarily run as root. The affected scope includes every application in the saved ...[truncated 77 chars]
Remediation
## Remediation Suggestions - Remove boot-persistence instructions if cross-session startup is not strictly required by the Skill. - Require explicit, informed user approval before running `pm2 save`, `pm2 startup`, or any generated privileged command. - Display and validate the complete PM2 process list before saving it. - Verify each script path, working directory, argument, environment variable, and ecosystem configuration before enabling startup. - Run managed applications through a dedicated least-privilege service account rather than an administrative account. - Do not execute generated commands with `sudo` until their paths, target user, home directory, and startup mechanism have been reviewed. - Document rollback procedures using `pm2 unstartup`, `pm2 delete`, and removal of the saved process list where appropriate. - Periodically audit enabled startup entries and saved PM2 applications for unauthorized changes.

T08 · Insecure Dependencies

Warning
Location
SKILL.md:10
Finding
Unpinned Global PM2 Package Installation## Vulnerability Details **File Location**: `SKILL.md`, lines 10-14 **Vulnerability Type**: `T08: Insecure Dependencies` **Risk Level**: Medium **Vulnerable Code**: ```markdown ## Install ```bash npm install -g pm2 ``` ``` ### Technical Analysis The installation command retrieves the registry-resolved PM2 version without pinning an exact release or verifying artifact integrity and provenance. Consequently, the installed content can change over time without a corresponding change to this Skill. npm package installation can invoke lifecycle scripts with the permissions of the invoking user. The global `-g` installation also places the package in a system-wide or user-wide executable location, broadening the consequences of a compromised package release or transitive dependency. No evidence establishes that the legitimate `pm2` package is currently malicious; the issue is the mutable and unverified dependency installation process. ### Attack Path 1. The npm account, registry entry, release pipeline, or dependency chain associated with the package is compromised. 2. A malicious version is published under the expected package name or included through its dependency graph. 3. A user follows the Skill and runs `npm install -g pm2`. 4. npm resolves the mutable current release and downloads the compromised content. 5. Malicious lifecycle code executes with the user's permissions during installation. 6. The compromised globally available executable can subsequently run whenever the user invokes `pm2`. ### Impact Assessment Exploitation could permit arbitrary code execution with the installing user's privileges. If the installation is performed from an elevated shell, the impact may extend to system-level modification. A compromised global executable could affect all projects and workflows that invoke PM2 within the installation scope. Potential consequences include data access, process manipulation, credential theft, or ad ...[truncated 63 chars]
Remediation
## Remediation Suggestions - Pin PM2 to a reviewed exact version, for example `pm2@X.Y.Z`, rather than resolving an unspecified current release. - Prefer a project-local development dependency and invoke it through `npx --no-install` or an npm script instead of installing it globally. - Commit and enforce a lockfile where project-local installation is used. - Verify package provenance, signatures, publisher identity, and registry configuration before installation. - Use npm integrity metadata and an approved internal registry or artifact mirror where available. - Review package lifecycle scripts and transitive dependency changes before upgrading. - Perform installation without administrative privileges and in an isolated build or deployment environment. - Establish an explicit dependency-update process so version changes undergo security review before rollout.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (2)

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
pm2 startup

# Example output - run this:
# sudo env PATH=$PATH:/opt/homebrew/bin pm2 startup launchd -u username --hp /Users/username
```

## Next.js / Production Builds
Confidence
91% confidence
Finding
The skill includes an example telling the user to run a `sudo` command generated by `pm2 startup`, which normalizes privileged execution without explaining the security implications. In agent workflows, this can encourage elevation with inherited environment variables (`env PATH=$PATH:...`) and lead to unintended privileged changes if the command is executed blindly on the wrong system or with a manipulated PATH.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The skill documents highly destructive PM2 commands such as `pm2 delete all`, `pm2 kill`, and `pm2 unstartup` without any warning, confirmation guidance, or scope limitations. In an agent-assisted context, these commands could be copied or suggested verbatim and cause service outages, loss of process state, or removal of boot persistence across an entire host.

Static analysis

No suspicious patterns detected.