Secrets in Process-Manager Environments: What PM2, systemd and Docker Expose, and What Holds When an Agent Shares the User
Executive Summary
A common way to run a self-hosted agent platform is a few Node.js services under PM2, an agent CLI with a shell tool in a terminal multiplexer, and one operating-system user for all of it. API tokens usually reach the services as environment variables because that is the default advice and every supervisor supports it. The trouble is that an environment variable is not a secret store. It is a block of text that the supervisor records, prints, saves to disk and hands to every child, and that, under the usual conditions spelled out in section 3.1, other processes of the same user can read from /proc. An agent with shell access is typically such a process.
What the sources and my own checks show:
- PM2 stores and prints the whole environment of every app. In the PM2 source (7.0.1 and 7.1.4), the merged environment is copied into the process record.
pm2 env <id>prints its environment variables (it skips only PM2's own configuration and bookkeeping keys),pm2 jlistandpm2 prettylistserialize it, andpm2 savewrites it todump.pm2in the PM2 home directory (~/.pm2unlessPM2_HOMEsays otherwise), keeping the previous copy indump.pm2.bak. No file mode is passed, so a file thatpm2 savecreates gets the umask default (0644 under the usualumask 022). The upstream issue titled "PM2 App process environment variables are easily exposed" (#5190, opened September 2021) is still open. filter_env: truedid not work for a long time. The PM2 7.1.2 changelog saysfilter_env: true"works again (ignored since 4.4.1)". I reproduced the no-op on 7.0.1. Even when it works, it filters only the environment PM2 itself passes down (the shell of whoever ranpm2 start, and in cluster mode the daemon's), never values declared in the ecosystem file'senv, and the array form is a case-sensitive substring denylist, not an allowlist.- The Linux layer does not separate processes of the same user by default. Reading
/proc/<pid>/environis a ptrace read check: the reader's filesystem UID and GID must match the target's real, effective and saved UIDs and GIDs (or the reader needsCAP_SYS_PTRACE), the target must be dumpable, and a security module can still deny it. A typical agent process running as the services' user meets those conditions. On my host with Yamaptrace_scope=1and no security module denying the read, an unrelated (non-descendant) process with the same UID and GID could read a dumpable process'senvironbut gotEACCESon/proc/<pid>/mem. Environment variables are also inherited by every child, so an agent's shell tool starts life holding everything its parent held. - systemd and Docker say the same thing in their own documentation. systemd.exec(5): environment variables "are not suitable for passing secrets", because they are "exposed to unprivileged clients via D-Bus IPC" and "propagated down the process tree". Docker's Compose documentation says environment variables "are often available to all processes" and "can also be printed in logs". OWASP lists process listing, child inheritance, crash dumps and diagnostic logs as the exposure routes.
- What works in practice is a stack, and each layer stops something different. Read secrets from a file with strict mode at service start and keep them out of
process.env. Scrub or allowlist the environment at every spawn of an agent subprocess. Fix what PM2 persists. Put the agent and the services under different OS users, because that is the separation that does not depend on per-process settings; within one UID, the remaining barriers (a non-dumpable target, a security-module policy, a PID namespace) each cover only part of the surface. Use systemd credentials where systemd owns the service. Give the agent short-lived, narrowly scoped tokens instead of the long-lived key. - None of the same-user measures here stops a same-user process that can read the user's files and meets the ptrace conditions, and nothing here stops root or the agent asking a trusted service to act for it. Section 7 lists what each measure does not stop.
Evidence labels used below: Source means I read the code or documentation cited. Tested means I ran it on a Linux host (kernel 6.17, Node 24, systemd 255) and saw the result. Inference is my reasoning. Section 9 lists what I could not verify.
This article is about the supervisor and the operating system. For the neighboring problem of credentials that get written into an agent's own memory and chat history, see Keeping Secrets Out of Agent Memory Without Stopping the Pipeline. For the wider credential lifecycle and cloud IAM patterns, see AI Agent Credential and Secret Management in Production.
1. What PM2 does with an environment
1.1 How the environment travels
PM2 builds each app's environment in three layers: the environment of the shell that ran pm2 start, then variables from the ecosystem file's env block (or env_production and similar with --env), then anything passed on the command line. The result is merged into the app's configuration and stored by the PM2 daemon as pm2_env.
Source (lib/Common.js, lib/God.js, lib/God/ForkMode.js at the v7.0.1 tag, which I checked is identical to the npm package for these files): the merge is a plain Object.assign of the shell environment and app.env. When the daemon starts the process, God.executeApp copies every key of env up to the top level of the record, so the same value ends up both nested under env and as a top-level key. In fork mode the child's environment is built by copying every non-object top-level key of that record, which is how the secret reaches the child. The daemon itself is also launched with the environment of whatever CLI first started it (lib/Client.js passes process.env when spawning the daemon), so a secret exported in that first shell stays in the daemon's own /proc/<pid>/environ for as long as the daemon lives.
1.2 The commands that print or serialize it
Source (the 7.0.1 and 7.1.4 npm packages, read for the same functions; links point to the matching release tags: lib/API/Extra.js for env (report is in the same file), lib/API.js for jlist and prettylist, lib/API/UX/pm2-describe.js for describe, Common.safeExtend):
| Command | What it shows |
|---|---|
pm2 env <id> | The keys of the process record that remain after Common.safeExtend, one key: value per line. That function skips object values and PM2's own keys: in 7.1.4 the ecosystem option names, daemon bookkeeping such as pm_id and status, and anything starting with pm_ or axm_; in 7.0.1 a fixed list of 44 names. Environment variables sit at the top level of the record, so they are printed unless a name collides with one of those keys. There is no redaction in 7.1.4 either. |
pm2 jlist | JSON.stringify of the monitor data for all processes, including each pm2_env. The output of an agent's health check that runs this command contains every secret. |
pm2 prettylist | The same data through util.inspect with unlimited depth. |
pm2 describe <id> / pm2 show <id> | Narrower. Its "Divergent env variables from local env" table considers only names that exist in the caller's own shell environment and whose value in the process is missing or different. For each such name the process has a non-empty value for, it prints that process-side value, truncated to the terminal width minus 60 characters (240 characters when no width is known). A secret appears, possibly truncated, only if the caller's shell has a variable of the same name with a different value. |
pm2 report | Does not print the environment: the CLI formats system info and the process list, and the code never references the env field that the daemon returns. |
The upstream report is short. In issue #5190 the reproduction is export DB_PASSWORD=...; pm2 start server.js; pm2 save; pm2 env <id>. As of this writing (verified on the issue page) it is open with no assignee or linked fix. Other projects have independently filed the same finding. One downstream issue is titled around pm2 save persisting plaintext install-time secrets into a 0644 ~/.pm2/dump.pm2. Another, in a German-language security review, notes that sourcing a .env file before pm2 start leaves every secret in both dump.pm2 and the process environment. I read these as user reports, not as confirmation of the behavior; the behavior itself comes from the PM2 source above.
1.3 The dump file
Source (lib/API/Startup.js, dump, at v7.1.4, the same logic as v7.0.1; paths from paths.js): pm2 save takes each process record (modules excluded), drops instances, pm_id and prev_restart_delay, and writes the array with fs.writeFileSync(DUMP_FILE_PATH, JSON.stringify(env_arr, '', 2)). No mode is passed. DUMP_FILE_PATH is dump.pm2 in the PM2 home directory, which is $PM2_HOME when that variable is set and ~/.pm2 otherwise. Before overwriting, it copies the old dump to dump.pm2.bak in the same directory, also without a mode. Two details matter for cleanup. If the daemon manages no app processes, pm2 save without --force (or the FORCE variable) leaves an existing dump untouched and only prints a warning. And if writing the backup fails, it logs the error and still overwrites the primary. pm2 resurrect reads the primary and falls back to dump.pm2.bak if the primary cannot be read or parsed.
Tested: Node's writeFileSync with no mode and umask 022 created a file with mode 644, and rewriting an existing file kept that file's mode: a primary set to 600 stayed 600, while a backup newly created next to it got 644. So the 0644 default applies to a dump.pm2 or dump.pm2.bak that pm2 save creates, not to one that already exists. A hardened host can differ, and the file on the machine I checked was 0600, so verify both files with stat. Three consequences follow:
- The dump contains the full environment that each process was started with, in cleartext JSON, and it is read again by
pm2 resurrectand by the systemd unit thatpm2 startupgenerates. dump.pm2.bakkeeps the previous generation. If you remove a secret from the apps and runpm2 saveonce, the old value is still in the backup until a second save replaces it. Delete the.bakexplicitly after rotating, once the new primary is verified (section 5.3).- Mode 0600 protects the files from other users. It does not protect them from an agent that runs as the same user, and the agent's shell can also just run
pm2 env.
1.4 filter_env: what it is and what it is not
PM2's documentation describes filter_env as filtering "the environment of the shell running pm2 (and, in cluster mode, of the daemon) passed to the app", and adds that "Variables declared in env are always passed."
Source and Tested (lib/tools/pm2-config-keys.js, filterShellEnv, at v7.1.4, run directly, and lib/God/ClusterMode.js, read only, both unchanged from 7.1.2; Common.prepareAppConf at v7.0.1, run directly):
filter_env value | 7.1.2 and later | 7.0.1 and earlier |
|---|---|---|
true | Keep only a base set of names (listed below the table). In cluster mode the same filter also removes what the worker would otherwise inherit from the daemon's environment. | No effect. All shell variables, including a test OPENAI_API_KEY and MY_TOKEN, reached the app. |
"NAME" | Drop exactly that variable. | Dropped (the string branch worked). |
["KEY", "TOKEN"] | Drop every variable whose name contains one of the strings. Matching is key.includes(pattern), so it is case-sensitive: ["KEY"] does not drop api_key. | The same substring behavior. |
| Not set | Everything is inherited. | Everything is inherited. |
The 7.1.2+ base set on Linux is PATH, HOME, USER, LOGNAME, SHELL, TZ, TMPDIR, PM2_HOME, LANG, LANGUAGE and these named locale variables: LC_ALL, LC_CTYPE, LC_COLLATE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_ADDRESS, LC_IDENTIFICATION, LC_MEASUREMENT, LC_NAME, LC_PAPER, LC_TELEPHONE. There is no LC_* wildcard (the source comment says locales are listed one by one because ssh can forward LC_*), and Windows has its own list.
The reason true did nothing is visible in the 7.0.1 source. The code that applies the filter is guarded by app.filter_env.length > 0, and a boolean has no length, so the branch that would return an empty environment for true is unreachable. The 7.1.2 changelog (the same CHANGELOG.md ships in the 7.1.2 npm package) confirms it: its entry for filter_env: true says it "works again (ignored since 4.4.1)". It also lists two follow-on notes that matter for secrets already persisted. Apps with filter_env: true "no longer inherit other shell variables (NODE_ENV, NODE_OPTIONS, HTTP_PROXY...)", so those have to be declared in env. And "An app keeps the shell env it already received when the filter comes later", which the entry says covers apps started before 7.1.2 or without filter_env, including those restored from dump.pm2; the remedy it gives is pm2 delete and a fresh start.
So filter_env is useful, but it covers one thing: leakage of the shell's (and, in cluster mode, the daemon's) environment into apps. It does nothing for a secret you wrote into the ecosystem file's env, and it does not remove anything from a dump that was saved before the change. Treat it as a way to stop accidental inheritance from your interactive shell, not as a secrets mechanism.
The array form being a denylist is the other trap. A new variable named PLATFORM_CREDS or SERVICE_PW passes ["KEY", "TOKEN", "SECRET"]. An allowlist (true plus explicit env entries, or your own spawn wrapper in section 5.2) fails closed; a denylist fails open.
1.5 The ecosystem file
An ecosystem file with env: { API_TOKEN: "..." } is a config file in a repository, a deploy script or a home directory, and it ends up in pm2 jlist and dump.pm2 as well. Secrets in a checked-in ecosystem.config.js are the same mistake as secrets in any source file. The 12-factor guidance that config belongs in the environment is about separating config from code, so that a codebase "could be made open source at any moment, without compromising any credentials" (12factor.net, Config). It does not say the environment is confidential, and the page does not discuss who else can read the process's environment.
2. The same pattern in the other supervisors
systemd. The systemd.exec(5) manual states, under Environment=: "environment variables are not suitable for passing secrets (such as passwords, key material, …) to service processes. Environment variables set for a unit are exposed to unprivileged clients via D-Bus IPC, and generally not understood as being data that requires protection. Moreover, environment variables are propagated down the process tree, including across security boundaries (such as setuid/setgid executables), and hence might leak to processes that should not have access to the secret data." Tested: as an ordinary user, systemctl show <system service> -p Environment --value returned the Environment= values of several running system units on my host, with no privileges. Source (v255 src/core/dbus-execute.c): that probe reads the D-Bus Environment property, which is the unit's configured Environment= list. EnvironmentFile= is exposed differently: the EnvironmentFiles property carries only each file's path and a flag for the optional - prefix, so this probe does not show the file's contents, even though, per the manual, the variables read from the file are set for the executed processes just as with Environment=, so they still reach the process environment. Unit files themselves are typically world-readable text (inference from common default permissions; I did not audit this).
supervisord. The manual says subprocesses "will inherit the environment of the shell used to start the supervisord program", with the [supervisord] and per-[program:x] environment options adding to or overriding it. Nothing there scrubs anything, so the model is the same as PM2's: whatever the starting shell held reaches every program.
Docker and Compose. The Compose secrets documentation says: "If you’re injecting passwords and API keys as environment variables, you risk unintentional information exposure", and "Environment variables are often available to all processes, and it can be difficult to track access. They can also be printed in logs when debugging errors without your knowledge." Secrets are instead mounted as files at /run/secrets/<name>. The Swarm documentation says its secrets are mounted in tmpfs and "never exposed as environment variables", and the official images' *_FILE convention (for example MYSQL_PASSWORD_FILE pointing at /run/secrets/mysql_password) is the pattern worth copying: put the path, not the value, in the environment. I did not check how docker inspect renders a container's Env on my host (see section 9).
OWASP's Secrets Management Cheat Sheet gives the general rule: "Avoid passing secrets through environment variables where feasible, as environment variables risk exposure through process listing, child-process inheritance, crash dumps, and application diagnostic logs."
3. The operating-system layer: why same-UID is the boundary that matters
3.1 /proc/<pid>/environ
The proc_pid_environ(5) manual page says the file shows the process's initial environment and that if the process later modifies its environment, "this file will not reflect those changes". It also says: "Permission to access this file is governed by a ptrace access mode PTRACE_MODE_READ_FSCREDS check" (see ptrace(2)). The NOTES of ptrace(2) give the algorithm. With the FSCREDS modifier the caller's filesystem UID and GID are used, and access is denied unless "The real, effective, and saved-set user IDs of the target match the caller's user ID, and the real, effective, and saved-set group IDs of the target match the caller's group ID", or the caller has CAP_SYS_PTRACE in the target's user namespace. Access is also denied if the target's "dumpable" attribute is not 1 (see PR_SET_DUMPABLE) and the caller lacks CAP_SYS_PTRACE. Finally the security modules decide: the always-present commoncap module requires the caller's capabilities to cover the target's permitted capabilities (or CAP_SYS_PTRACE), and Yama, SELinux, AppArmor or others, where enabled, can deny it too. So a process of the same user can read another's environ when the group IDs also match, the target is dumpable (the normal state for a program that did not change credentials, execute a set-user-ID or set-group-ID binary, or call prctl(PR_SET_DUMPABLE, 0)), and no security module objects. An agent process started by the same user as the services, with no special policy, normally meets all of these.
Tested, with a dumpable secret-bearing process started in its own session and a separate non-descendant reader with the same UID and GID, on a host with Yama ptrace_scope=1, AppArmor enabled but both processes unconfined, and no other module denying access:
- Reading
/proc/<pid>/environworked and returned the secret. - After a same-user target called
prctl(PR_SET_DUMPABLE, 0), the same kind of reader gotPermission deniedon itsenviron. - Reading
/proc/<pid>/memof the dumpable target failed withPermission denied. The host runs Yamaptrace_scope=1, which the kernel documentation describes as: "a process must have a predefined relationship with the inferior it wants to call PTRACE_ATTACH on. By default, this relationship is that of only its descendants when the above classic criteria is also met." Theptrace(2)manual explains whyenvironis still readable: Yama limits operations that perform aPTRACE_MODE_ATTACHcheck, while reading/proc/pid/environis listed under the weakerPTRACE_MODE_READ. Mode 1 also has exceptions: a target can declare another process allowed to attach withprctl(PR_SET_PTRACER), and a caller withCAP_SYS_PTRACEis not restricted.
So at mode 1 Yama blocks attach-class access such as /proc/<pid>/mem between unrelated same-user processes, unless one of those exceptions applies, but it does not restrict environ, which needs only the read check above. These results hold for the conditions I tested; a different security-module policy, a non-dumpable service or a reader in another user namespace can change them. At ptrace_scope=0 the Yama document says "a process can PTRACE_ATTACH to any other process running under the same uid, as long as it is dumpable". Defaults differ by distribution and I only checked mine.
3.2 Modifying the environment after start changes what /proc shows
Because environ normally shows the initial block, a variable that a process sets at runtime does not appear there under normal Node behavior. Tested on Node 24: a variable loaded with node --env-file=secrets.env app.js is available as process.env.X and inherited by child processes, but is absent from /proc/self/environ. A variable added with process.env.LATE = 'x' after start is also absent. So loading secrets inside the process, instead of receiving them from the supervisor, removes them from the two places a casual reader looks first: the supervisor's record and /proc/<pid>/environ. It does not remove them from the process's memory or from the environment its children inherit. The file is not a guaranteed record either way: proc_pid_environ(5) also says "a process may change the memory location that this file refers via prctl(2) operations such as PR_SET_MM_ENV_START", so what it shows depends on what the process did, not only on what it was given.
Two details of --env-file from the Node documentation matter. If a variable is defined both in the environment and in the file, "the value from the environment takes precedence", so a stale value injected by the supervisor wins over the file. And the file is read relative to the current directory, so a supervisor cwd change silently changes which file loads.
3.3 Children inherit everything
Tested: a child started with child_process.execSync and no env option received the parent's DEMO_SECRET. Passing env with the secret removed delivered undefined. Node's spawn and exec default env to process.env, so every subprocess an agent platform starts (an agent CLI, its Bash tool, an MCP server, a hook, npm install) inherits all of it unless the code says otherwise.
Terminal multiplexers add a quieter version of the same thing. Tested with a private tmux server: a secret present in the shell that started the server was stored in the server's global environment (tmux show-environment -g listed it), and a new window created from a client whose own shell had no such variable still received it in the pane's environment. If an agent session lives in a long-running tmux server that was once started from a shell holding tokens, every new window inherits them. Check the server's global environment as well as your services.
3.4 Logs and crash reports
Exposure by printing is as common as exposure by reading. Node's diagnostic report, which can be triggered on uncaught exceptions, fatal errors and signals, includes an environmentVariables section. Tested: process.report.getReport() returned the full environment on Node 24. The Node documentation lists a --report-exclude-env option added in v23.3.0 and v22.13.0, and Tested: with that flag the section was absent. Core dumps and any hand-written "dump the environment on error" diagnostics have the same problem. OWASP names "crash dumps, and application diagnostic logs" as exposure routes for exactly this reason.
3.5 Real incidents that read the environment
Two public incidents show the environment being the first thing attackers take, not an exotic target:
- Codecov Bash Uploader, 2021. Codecov's security update says the modified script contained a line that sent
$(git remote -v)<<<<<< ENV $(env)to an external server, and that between January 31 and April 1 there were 108 windows of time during which the malicious uploader was in use. The payload was the environment of CI jobs that ran it. - npm worm campaigns, 2025. StepSecurity's analysis of the September 2025 Shai-Hulud compromise says the payload ran during
npm installthrough a hijackedpostinstallscript and "dumps the entireprocess.env, capturing transient tokens such asGITHUB_TOKENandAWS_ACCESS_KEY_ID", in addition to scanning the filesystem for secrets with TruffleHog.
Neither involved PM2. They matter here because an agent that runs npm install or executes code it fetched is in the same position as those CI jobs: whatever is in its environment is what a hostile install script gets.
4. What this means for an agent platform
An agent with a shell tool changes the threat model of ordinary supervisor advice. In a normal service, the people who can run pm2 env or read /proc are administrators. Here, the shell's operator is a language model that can be steered by a web page, an issue comment or a tool result. Anthropic's Claude Code documentation states the motivation for its own subprocess scrub directly: it "reduces what a prompt injection attack can read".
The attack surfaces that a same-user agent has, in order of effort:
- Run
envorprintenv. This shows whatever its own parent passed down. - Run
pm2 env,pm2 jlistorpm2 prettylist, or read~/.pm2/dump.pm2and its.bak. - Read
/proc/<pid>/environof same-user processes that pass the ptrace read check (matching UIDs and GIDs, dumpable, no security-module denial), which normally includes the PM2 daemon and every service. - Read any file the user can read: a secrets file, a
.envin a repository, an ecosystem file. - At
ptrace_scope=0(or, at 1, for its own descendants), attach to a dumpable same-user process and read its memory. - Ask a trusted service to perform the privileged action.
An organization can close 1 and 2 cheaply. A different user closes 3 and 4 most generally; within one UID, 3 can be narrowed per process (a non-dumpable service, a security-module policy, or a PID namespace for the agent's subprocesses as in section 5.2) and 4 by a security-module policy, but I did not test any of these as a deployment. 5 depends on kernel settings. Number 6 is not an environment problem at all.
On one single-host agent machine I ran the first check in section 8 as the agent's user (one snapshot, repeated three times with the same result). It counted 73 processes whose real, effective and saved UIDs were all that user's, not counting the scanning shell. 68 of them had a readable environ, 5 refused the read, and none exited during the scan. 31 of the 68 readable ones carried at least one variable whose name contains KEY, TOKEN, SECRET, PASSWORD or CREDENTIAL (names only; values were never printed or saved). That is the size of what a same-user agent can enumerate without any special skill.
5. What works in practice, from cheapest to most separating
5.1 Take secrets out of the supervisor's view
The goal is that the PM2 record, dump.pm2, pm2 jlist and /proc/<pid>/environ contain no secret at all.
- Put the secret in a file readable only by the service's user, outside every repository and outside the agent's working area. Mode 0600 (or 0400) in a directory with mode 0700.
- Put only the path in the environment, the
*_FILEconvention used by Docker's official images. - Have the service read the file at startup, into a module-local variable. Do not assign it back to
process.env, because then children inherit it.
import { openSync, fstatSync, readFileSync, closeSync, constants } from 'node:fs';
// File format: the token on one line; a single trailing newline is removed.
function loadSecret(path) {
// O_NOFOLLOW: refuse a symlink. O_NONBLOCK: a FIFO cannot block the open.
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
try {
const st = fstatSync(fd); // checks apply to the file actually opened
if (!st.isFile()) throw new Error(`${path} is not a regular file`);
if (st.uid !== process.getuid()) throw new Error(`${path} is not owned by this user`);
if (st.mode & 0o077) throw new Error(`${path} is accessible to group or others`);
return readFileSync(fd, 'utf8').replace(/\n$/, '');
} finally {
closeSync(fd);
}
}
// Only the path travels through the environment and through PM2.
const botToken = loadSecret(process.env.BOT_TOKEN_FILE);
The file is opened once and every check applies to the descriptor that was opened, so the file that is checked is the file that is read; checking by path and then reading by path again, as a statSync followed by readFileSync(path) would, leaves a window in which the path can be swapped. O_NOFOLLOW refuses a symlink as the last path component, and O_NONBLOCK keeps a FIFO from blocking the open (a FIFO opened read-only without it waits for a writer); the isFile() check then rejects the FIFO, a directory or a device. The expected format is a single-line token, and only one trailing newline is removed, so a value with deliberate surrounding whitespace survives. Tested on Node 24 with throwaway files: a 0600 file owned by the service user loaded; a 0640 file, a symlink, a FIFO (without hanging) and a directory were rejected. I could not create a file owned by another user that this user could open, so the owner check is untested; an unprivileged service cannot open another user's 0600 file anyway, and the check matters mainly when the service has elevated file access.
If a library insists on process.env, node --env-file is the next best option. It keeps the value out of the supervisor record and out of /proc/<pid>/environ (tested), but the value is then in process.env and every child inherits it, so it must be combined with the spawn scrub below. Remember the precedence rule: an old BOT_TOKEN still exported in the shell wins over the file.
What this stops: pm2 env, jlist, prettylist and the dump no longer contain the token; neither does the environ file of the service. What it does not stop: a same-user process reading the secrets file, or reading the service's memory.
5.2 Scrub the environment at every point where an agent subprocess is created
Do this in the code that spawns the agent CLI and its tools, and prefer an allowlist.
import { spawn } from 'node:child_process';
// Allowlisted names. Their values are copied as they are, so the service's
// own environment must be trusted (see the note below).
const ALLOW = ['PATH', 'HOME', 'LANG', 'LC_ALL', 'TZ', 'TERM', 'TMPDIR'];
export function cleanEnv(extra = {}) {
const env = {};
for (const k of ALLOW) if (process.env[k] !== undefined) env[k] = process.env[k];
return { ...env, ...extra }; // extra: explicit, per-session, non-secret values
}
spawn(agentBinary, args, { env: cleanEnv({ SESSION_ID: id }), cwd: workdir });
agentBinary, args, id and workdir stand for your own values; with those defined the snippet runs as is (Tested on Node 24: the child saw only the allowlisted names that were set, plus SESSION_ID).
An allowlist fails closed on names: a new variable named SERVICE_PW is dropped without anyone remembering to add it to a list. It does nothing about the values of the names it keeps. PATH, HOME, TMPDIR and the rest are copied through unchanged, so they must come from a service environment you trust; a PATH that someone else could set would still decide which binaries the child runs. The cost is that tools that need HTTPS_PROXY, NODE_OPTIONS or a credential helper stop working until someone adds them, which is the intended friction.
Agent runtimes ship their own versions of this, and they are worth using, as one layer:
- Codex CLI has a
shell_environment_policysection whose documented keys includeinherit(all,coreornone),filters(pattern entries where include entries "create an allowlist"),set(explicit values injected after exclusions) andignore_default_excludes. The reference describes the last as "Keep variables containing KEY, SECRET, or TOKEN before other filters run (default: true)" and says to set it to false "to apply automatic secret-name exclusions". My reading is that name-based exclusion is off by default, so the allowlist form is the one to rely on (see section 9 on the wording). - Claude Code has
CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1, which removes credentials from the environments of Bash commands, hooks and stdio MCP servers, recognizing them "by its variable name or by the shape of its value". The documentation is explicit about gaps: it leavesGITHUB_TOKEN,GH_TOKEN, proxy settings (including a password inside a proxy URL) andGIT_CONFIG_*in place, and its table of cases says that a secret whose variable name and value both do not look like a credential is also left in place. It also says to use it "as one layer alongside narrow permission rules rather than as the only control". On Linux, according to the same page, it also runs Bash subprocesses in an isolated PID namespace so that they cannot read the environments of host processes through/proc, with the side effect thatps,pgrepandkillcannot see host processes. That PID namespace is one way to address item 3 in section 4 without a second OS user, at least for those subprocesses. I did not test it.
Do the same for the terminal multiplexer that hosts the agent: start its server from a clean environment (for example env -i PATH=... HOME=... tmux ...), and check tmux show-environment -g.
What this stops: the agent's env, and everything the agent runs, inheriting your tokens, including npm install hooks. What it does not stop: the agent reading /proc or files by other means, unless combined with a PID namespace or a different user.
5.3 Fix what PM2 persists, then rotate
If secrets have ever been in PM2's environment, treat them as exposed to anything that could run as that user and rotate them.
-
Move the secrets to files (5.1) and remove them from the ecosystem file and from the shell that starts PM2.
-
Run PM2 7.1.2 or later if you want
filter_env: trueto work, and declare what the app needs inenv. Then for each app:pm2 deleteand start it again, because the changelog says an app "keeps the shell env it already received" otherwise. -
Before saving, keep a protected copy of the current primary as the baseline to verify against, and protect the files the save will touch:
D=${PM2_HOME:-$HOME/.pm2} if [ -e "$D/dump.pm2.baseline" ]; then echo "STOP: $D/dump.pm2.baseline exists; verify with it or remove it first" >&2 elif install -m 600 "$D/dump.pm2" "$D/dump.pm2.baseline" && # pre-change dump, 0600 chmod 600 "$D/dump.pm2" && { [ ! -e "$D/dump.pm2.bak" ] || chmod 600 "$D/dump.pm2.bak"; }; then (umask 077 && pm2 save) || echo "STOP: pm2 save failed" >&2 else echo "STOP: baseline copy or chmod failed; nothing saved" >&2 fiThe save runs only if a fresh baseline was written and every permission change succeeded; a missing
.bakis normal, but a.bakthat exists and cannot be set to 0600 stops it, because PM2's overwrite would keep its old mode. An existing baseline from an earlier attempt is never overwritten. Tested with a stand-in forpm2that performs the same twowriteFileSynccalls: with and without an existing backup, all three files ended at 0600; a failinginstall, a failingchmodon the backup and a leftover baseline each stopped before the save was called (the previous version of this block called it in both injected cases). The save runs in the CLI process and copies the old dump to the backup withwriteFileSyncand no mode (source), so a backup it creates takes the caller's umask, while an existing file keeps its mode; achmodafter the save would leave the old, secret-bearing copy readable in between. Check that it reported saving rather than skipping: with no app processes it leaves the old dump in place unless given--force, and a failed backup write does not stop it (section 1.3). That last point is why the check below uses the baseline you copied, notdump.pm2.bak: a fresh primary does not prove the backup is the pre-change dump. -
Verify the new primary before anything else. Its modification time (
stat) must be from this save, and the credentials you moved out must be gone. A name scan cannot show that: a password insideDATABASE_URLmatches none of the patterns in section 8, while the recommendedBOT_TOKEN_FILEdoes. Check every moved app and key against the baseline instead:# Run after the save, before deleting anything. CHECK lists every app:KEY pair # you moved out; VALUES_FILE (optional, mode 0600) lists one credential per line # that must also be gone on its own, such as a password that sat inside a URL. CHECK='api:BOT_TOKEN api:DATABASE_URL' VALUES_FILE= node -e ' const fs = require("fs"), dir = process.env.PM2_HOME || require("os").homedir() + "/.pm2"; const isObj = x => x !== null && typeof x === "object" && !Array.isArray(x); const load = f => { try { const a = JSON.parse(fs.readFileSync(f, "utf8")); if (Array.isArray(a) && a.every(isObj)) return a; } catch {} console.error("FAILED: cannot parse " + f); process.exit(2); }; const base = load(dir + "/dump.pm2.baseline"), cur = load(dir + "/dump.pm2"); const pairs = process.env.CHECK.split(/\s+/).filter(Boolean) .map(p => [p.slice(0, p.lastIndexOf(":")), p.slice(p.lastIndexOf(":") + 1)]); const recs = (dump, app) => dump.filter(r => r.name === app) .flatMap(r => [r, isObj(r.env) ? r.env : {}]); // top level and env const vals = new Set(); let incomplete = 0, apps = 0, keys = 0; for (const [app, key] of pairs) { const v = recs(base, app).map(o => o[key]).filter(x => typeof x === "string" && x !== ""); if (v.length === 0) incomplete++; else v.forEach(x => vals.add(x)); if (recs(cur, app).length === 0) apps++; if (recs(cur, app).some(o => key in o)) keys++; } if (process.env.VALUES_FILE) { let t = ""; try { t = fs.readFileSync(process.env.VALUES_FILE, "utf8"); } catch { console.error("FAILED: cannot read VALUES_FILE"); process.exit(2); } t.split("\n").filter(Boolean).forEach(x => vals.add(x)); } const strs = []; const walk = x => { if (typeof x === "string") strs.push(x); else if (x && typeof x === "object") Object.values(x).forEach(walk); }; walk(cur); const hits = [...vals].filter(v => strs.some(s => s.includes(v))).length; console.log(`pairs: ${pairs.length}; not in baseline: ${incomplete}; app missing: ${apps}; ` + `key still present: ${keys}; old values still in dump: ${hits}`); if (pairs.length === 0 || incomplete) { console.log("INCOMPLETE: verification did not cover every pair"); process.exit(3); } process.exit(apps || keys || hits ? 1 : 0);'It prints counts only. For each
app:KEYpair it takes the old value from that app's record in the baseline; a pair with no value there means the baseline cannot vouch for it, and the script reportsINCOMPLETEand exits 3 rather than passing. Otherwise it fails (exit 1) if a listed app is missing from the new dump, a listed key is still set for its app, or any old value appears anywhere in the new dump, including under another name or inside a longer string. The value check compares each whole recorded value. When the old value was a composite, such as a connection URL with the password inside it, a copy of just the password under a new name does not contain the whole URL and is not caught; put each embedded credential on its own line inVALUES_FILE(or check it separately) so it is searched for by itself. Tested with throwaway dumps: a clean dump passed; a leftover key, a value moved under a new name, a missing app and an unreadable file each failed; a baseline missing one listed pair reportedINCOMPLETE; a password copied out of a URL passed withoutVALUES_FILEand failed with it; no fixture value was printed. Keep the section 8 name scan as a separate heuristic. -
Only after that, delete
dump.pm2.baselineanddump.pm2.bak, both of which hold the old secrets, and only after that rely onpm2 resurrector the boot unit, which fall back to the.bakwhen the primary cannot be read. A file PM2 creates later, such as the next.bak, gets the umask of whoever runs that save, so keepumask 077for PM2 commands or recheck withstat -c %a. If the PM2 daemon itself was started from a shell holding secrets, restart the daemon from a clean environment, because its/proc/<pid>/environkeeps them.pm2 killfollowed by a start from a clean shell does that. I did not run these commands against a live instance; stage them in a maintenance window. -
Make health checks and dashboards use a field allowlist. If something calls
pm2 jlist, it should selectname,pm_id,pm2_env.status,pm2_env.restart_timeandpidand discard the rest before logging, because rawjlistoutput in a log is a copy of every secret. -
Rotate. Removing a value from the supervisor does not un-expose it. See the rotate-first reasoning in the related secrets-in-memory article.
5.4 Separate OS users
A different UID is the separation that does not depend on per-process settings such as dumpability or on a security-module policy. Put the services under one user, the agent and its shell under another, and make the secrets files readable only by the first.
- PM2: the
uidandgidapplication options exist ("run the app as this user", per the PM2 documentation: "PM2 must run as root"). Source (lib/God/ForkMode.jsat v7.1.4): PM2 passes them tospawn. So per-app users mean a root-owned PM2 daemon, which is a much bigger trust decision than the problem you started with. The simpler layout is one PM2 daemon per user, each with its ownPM2_HOME, started by that user's own boot unit (pm2 startup systemd -u <user> --hp <home>). - Agent side: the agent's user must not be able to read the service user's home,
~/.pm2, secrets directory or/proc/<pid>/environof the service processes. Different UIDs fail the UID comparison in the same ptrace read check, so the agent's user cannot read the services'environunless it holdsCAP_SYS_PTRACE. Withhidepid=2on/proc, perproc(5)the/proc/piddirectories of other users "become invisible", but that mount option only affects other users, so it adds nothing for processes of the same UID. - Cost: shared workspaces need group permissions or an ACL, the agent can no longer restart services directly (it needs a narrow
sudorule or an API), and file ownership problems appear in every shared directory. An over-broadsudorule for the agent removes the whole benefit.
What this stops: the agent reading the service's secrets files, environment, dump and memory. What it does not stop: root, and anything the service does when the agent asks it to.
5.5 systemd credentials, when systemd owns the service
If the service runs as a systemd unit, not under PM2, LoadCredential= is the intended replacement for EnvironmentFile=.
Source (systemd.exec(5)): credentials are exposed "via the file system, at a read-only location that (if possible and permitted) is backed by non-swappable memory". "The data is only accessible to the user associated with the unit, via the User=/DynamicUser= settings (as well as the superuser)". The location is exported as $CREDENTIALS_DIRECTORY, and the unit sees only a copy: "the credential files/IPC sockets must be accessible to the service manager, but do not have to be directly accessible to the unit's processes". LoadCredentialEncrypted= decrypts at start from files produced by systemd-creds, optionally bound to the host's TPM2, "so that they cannot easily be analyzed offline". A path to a Unix socket is also allowed, so a secrets broker can hand over the value at start. The documented limit is 1 MB per unit.
Properties that matter for this article:
- Source (v255
src/core/dbus-execute.c): forLoadCredential=,systemctl showexposes the credential name and source path (the D-BusLoadCredentialproperty), not the content, and the content is not in theEnvironmentproperty.SetCredential=, which writes the value into the unit itself, is different: its D-Bus property carries the data. - It is not stored in the process environment, so child processes inherit only the path variable, not the content.
- Access is granted to the unit's user, but the documented UID condition does not by itself say which other processes can see the directory. Source (read, not tested): in v255
src/core/exec-credential.c,exec_setup_credentialsassembles the store in a forked helper with its own mount namespace when it can create one, and otherwise, on a permission or support error, in a fixed inaccessible directory with a fallback to a plain directory. Read access for the unit's UID is granted by an ACL or, where ACLs are unsupported, by file ownership. Whether another process of the same UID can reach the final directory therefore depends on which path was taken and on the mount namespaces of both processes, and I did not test it. If the agent runs as a different user, the UID condition keeps it out. If it runs as the same user, assume it can read the credentials unless you have verified otherwise, so this layer adds little against a same-UID agent. - Inference: systemd's system manager and a user manager both support credentials, but a user manager's credential directory sits under the user's own runtime directory. A PM2 daemon started in a user session therefore gets no isolation from the user's other processes by this route. I could not test a user-manager unit because the host I used has no user bus, so treat that as unverified.
5.6 Short-lived and narrowly scoped tokens
The most valuable control for the agent is often not hiding the key but making the key worth little.
- A service holds the long-lived credential. The agent receives a derived token with the smallest scope and a short life. GitHub's REST documentation says installation access tokens "expire one hour from the time you create them" and can be restricted to selected repositories and permissions. AWS STS credentials are documented as lasting from "a few minutes to several hours".
- When the agent only needs to call an API through a service, give it a local endpoint that adds the credential on the server side and never hands the key to the agent at all.
- Scope per task: a token that can read one repository and comment on pull requests is a different loss from a token that can push to every repository.
What this stops: the useful lifetime and scope of anything the agent can read. What it does not stop: use of the token within its lifetime, so shorter lifetimes and tighter scopes only shrink the window and blast radius.
5.7 Logs, crash reports and health checks
- Start Node services with
--report-exclude-envif diagnostic reports are enabled (Node 22.13+ and 23.3+). - Search code for
JSON.stringify(process.env),console.log(process.env), framework "debug" pages and error handlers that print configuration. - Keep
pm2 jlistandpm2 envout of scripts whose output is logged or shown to an agent. - Scan the supervisor's own files for credential-looking names (section 8).
6. Where each layer sits
The measures above defend different things. A compact way to keep them straight:
| Measure | Hides from pm2 env, jlist, dump | Hides from /proc/<pid>/environ | Stops agent children inheriting | Stops a same-UID agent reading the secret |
|---|---|---|---|---|
filter_env: true (7.1.2+) | Only shell (and cluster-mode daemon) leakage; not env: values | Same | Partly | No |
Secret file, read at startup, not in process.env | Yes | Yes | Yes | No (file readable; memory too where attaching is allowed) |
node --env-file | Yes | Yes under normal Node behavior (tested) | No | No |
| Spawn env allowlist | n/a | n/a | Yes for children it spawns | No |
| Runtime scrub with PID namespace (documented, not tested) | n/a | n/a | Yes for scrubbed names | Partly: no /proc view of host processes from those subprocesses |
| Separate OS user | Yes | Yes | Yes | Yes, except root, CAP_SYS_PTRACE holders and confused-deputy requests |
systemd LoadCredential= | Yes | Yes | Yes | If the agent is a different user; for a same-user agent not established, so assume no |
| Short-lived, scoped token | n/a | n/a | n/a | No, but limits damage |
7. The honest limits
- Same user means same trust, in the usual configuration. A process with the same UID can read the user's files and, when its GIDs also match, the target is dumpable and no security module objects,
/proc/<pid>/environof the user's processes; with Yama off (or for its own descendants, a target that named it withPR_SET_PTRACER, or withCAP_SYS_PTRACE) it can also attach and read memory. Atptrace_scope=1it cannot attach to non-descendants without one of those exceptions, but the secret is still in the service's memory (reachable via core dumps and anything with a debugger relationship) and in any file it was read from. None of the same-user measures in this article hides a secret from a typical process of the service's own user; only the per-process barriers listed in section 4 change that, and I did not test them as a deployment. - The service itself is a lever. If the agent can send a request that makes the service call an API with the service's credentials, the agent has used the secret without reading it. Environment hygiene does not address this. Scope what the service will do for an agent, and log it.
- Root is out of scope.
ProtectProc=insystemd.exec(5)says "the root user is unaffected by this option", andCAP_SYS_PTRACEbypasses it too. - Scrubs are heuristics when they are denylists. Claude Code's own documentation says a secret whose name and value do not look like a credential is left in place. PM2's array
filter_envis a case-sensitive substring denylist. Use allowlists when you control the code. - A file with mode 0600 is only as private as the user. It helps against other users and against a leaked backup with different permissions; it does nothing against a same-user agent.
- Short-lived tokens shift the problem to the minting credential. Whoever can mint can mint more. Keep the minting credential with the service user (section 5.4), not in anything the agent can read.
- Rotation is the real recovery. Every measure above reduces the chance of an exposure. Once a long-lived token has been in a place an agent or a log could read, only rotation removes the exposure.
8. A short audit you can run today
These commands print names and counts only, never values.
#!/usr/bin/env bash
# Save as audit.sh and run: bash audit.sh. Exits non-zero if a check could not run.
set -o pipefail; rc=0
# 1. Which of my processes carry credential-looking variable names?
# Counts only processes whose real, effective and saved UIDs are all mine.
me=$(id -u); owned=0; readable=0; unreadable=0; vanished=0; flagged=0
for d in /proc/[0-9]*; do
[ "$d" = "/proc/$$" ] && continue # skip this shell
uids=
while read -r k r e s _; do [ "$k" = Uid: ] && uids="$r $e $s"; done 2>/dev/null < "$d/status"
[ "$uids" = "$me $me $me" ] || continue
owned=$((owned + 1)); n=0
if { while IFS= read -r -d '' rec || [ -n "$rec" ]; do
name=${rec%%=*} # text before the first '='
[[ $name =~ KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL ]] && n=$((n + 1))
:
done; } 2>/dev/null < "$d/environ"; then
readable=$((readable + 1))
if [ "$n" -gt 0 ]; then
flagged=$((flagged + 1)); read -r comm 2>/dev/null < "$d/comm"
echo "${d#/proc/} $comm $n"
fi
elif [ -d "$d" ]; then unreadable=$((unreadable + 1))
else vanished=$((vanished + 1)); fi
done
echo "owned=$owned readable=$readable unreadable=$unreadable vanished=$vanished flagged=$flagged"
# 2. PM2's saved files: mode, modification time, and credential-looking
# variable names (the JSON is parsed; values are never printed, and a
# file that cannot be parsed is reported without its contents)
for f in "${PM2_HOME:-$HOME/.pm2}/dump.pm2" "${PM2_HOME:-$HOME/.pm2}/dump.pm2.bak"; do
[ -e "$f" ] || continue
stat -c '%a %y %n' "$f" || rc=1
out=$(node -e '
let apps = null;
try { apps = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); } catch {}
const isObj = x => x !== null && typeof x === "object" && !Array.isArray(x);
if (!Array.isArray(apps) || !apps.every(isObj)) process.exit(2); // details withheld
for (const app of apps) {
const names = new Set(Object.keys(app)); // flattened record
if (isObj(app.env)) Object.keys(app.env).forEach(k => names.add(k));
for (const k of names) if (/KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/.test(k)) console.log(JSON.stringify(k));
}' "$f" 2>/dev/null) || { echo "FAILED: $f is not a readable PM2 dump" >&2; rc=1; continue; }
[ -z "$out" ] || printf '%s\n' "$out" | sort | uniq -c
done
# 3. A tmux server's global environment (names only). -s prints shell code
# (NAME="value"; export NAME; or unset NAME;) with \ " $ ` escaped;
# a value may still span lines, so parse whole records, not lines.
tmux show-environment -g -s | node -e '
const s = require("fs").readFileSync(0, "utf8");
const rec = /(?:([^="\n]+)="(?:[^"\\]|\\[\s\S])*"; export \1;|unset [^;\n]+;)\n/y;
while (rec.lastIndex < s.length) {
const m = rec.exec(s);
if (!m) { console.error("FAILED: unexpected show-environment output"); process.exit(2); }
if (m[1] && /KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL/.test(m[1])) console.log(m[1]);
}' || { echo "FAILED: tmux check" >&2; rc=1; }
# 4. Kernel setting that decides whether same-user memory reads are possible
cat /proc/sys/kernel/yama/ptrace_scope || rc=1
exit $rc
The first command is how I got the figures in section 4. It runs in bash, counts only processes whose real, effective and saved UIDs are all yours, skips the shell running it, and reports how many processes refused the read (for example non-dumpable ones) or exited during the scan. It reads each NUL-terminated record whole and takes the name before the first =, so a value that contains a newline followed by something like FOO_TOKEN=... cannot produce a fake name. The second parses the JSON and prints only the property names of each saved app record and of its env object, so a value is never printed even when it contains one of the patterns; a file that cannot be read, is not JSON or is not an array of app records is reported by path only, with Node's error suppressed because it can quote the input. The third parses show-environment -s output record by record, honoring the escaping (a value ending in a backslash is printed as \\ before the closing quote) and values that span lines, and stops with an error on anything it does not recognize. A check that cannot run makes the script exit non-zero instead of printing nothing. Tested with throwaway processes, dump files and a private tmux server holding fixture values: the earlier versions of these commands printed a fixture value, counted a name taken from inside a value, exited 0 after a parse failure that echoed part of the input, or missed a variable whose value ended in a backslash; these versions did not. The patterns are plain substring matches, so harmless names that contain KEY (a keyring or keyboard setting, for example) are counted too. Read the list instead of trusting the count.
9. What I could not verify
- Live PM2 behavior end to end. I read the PM2 7.0.1, 7.1.2 and 7.1.4 npm packages (7.1.4 was the latest release at the time of writing; the cited files match the GitHub release tags) and ran their
filterShellEnvandprepareAppConffunctions directly, plus the 7.1.4 key classifier behindCommon.safeExtendon a synthetic record. I did not start a PM2 daemon, so whatpm2 env,describe,jlistandpm2 saveprint, the cluster-mode filtering, the empty-list skip, the continue-after-backup-failure path and the fact that the backup is written by the CLI process (so its umask applies) come from source, not from running them. The section 5.3 verification script was tested on throwaway dump files only. Thefilter_env: trueno-op on 7.0.1 was reproduced throughprepareAppConf, not through a fullpm2 start. - The default mode of
dump.pm2anddump.pm2.bakon every platform. The code passes no mode. I tested Node's behavior underumask 022directly, not throughpm2 save: a new file gets 0644 and a rewritten existing file keeps its mode. The 0644 reports in downstream issues are consistent with that, but I did not verify those reports beyond the issue titles. The dump file on the host I used was 0600, so a different umask or a manual change is possible. docker inspect. I did not confirm on my host that it prints a container'sEnv. The Docker documentation I cite makes the general point about exposure but does not mentioninspectby name.- systemd credentials end to end. The credential behavior is quoted from
systemd.exec(5)and read in the v255 source, including the mount-namespace and fallback paths. I could not start a transient unit withLoadCredential=because the host has no user systemd bus, so the permissions of the credentials directory, whether another process of the unit's UID can see it, and the user-manager case are unverified. - The owner check in
loadSecret. I could not create a file owned by another user that my test user could open, so that branch is untested; the other rejections were tested. - Claude Code's PID-namespace scrub and Codex's filters. I read the documentation of both and did not run either. The Codex
ignore_default_excludeswording is ambiguous and my reading of the default may be wrong; check the behavior on your version before relying on name-based exclusion. - Yama defaults by distribution, and other security modules. I confirmed
ptrace_scope=1and its effect on my host only, with unconfined processes. I did not test SELinux, AppArmor or other policies that confine the reader or the target, which can deny reads that my tests allowed. - PM2 Plus and
pm2 link. I searched for documentation on whether the monitoring agent uploads process environments and found none, so I make no claim either way. - CISA's alert on the 2025 npm worm. The page did not render in my fetch, so the npm worm facts come from StepSecurity's write-up alone.
- Dated facts about the PM2 issue. Issue #5190 was open on the page when I fetched it; its status may change.
Sources
- PM2: Unitech/pm2 issue 5190, "PM2 App process environment variables are easily exposed"; application declaration (ecosystem file) and
filter_env,uid/gidoptions; startup andpm2 save/resurrect; PM2 source as released: v7.0.1 and v7.1.4 tags, matching the npm packages pm2-7.0.1.tgz and pm2-7.1.4.tgz for the cited files; 7.1.2CHANGELOG.mdat the v7.1.2 tag, the same file as in pm2-7.1.2.tgz, entries forfilter_env(#6176) - Downstream reports (read as user reports): dialog-survey issue 193 (
pm2 saveand 0644dump.pm2); HHTTPS issue 118 (.envsourced, secrets indump.pm2) - Linux: proc_pid_environ(5); proc(5),
hidepid; ptrace(2), access mode checking and Yama (NOTES); kernel Yama documentation; PR_SET_DUMPABLE(2const) - systemd: systemd.exec(5):
Environment=,LoadCredential=,ProtectProc=; v255 source:src/core/dbus-execute.c, D-Bus properties,src/core/exec-credential.c, credential setup - Other supervisors and containers: supervisord, subprocess environment; Docker Compose, secrets; Docker Swarm secrets
- General guidance: OWASP Secrets Management Cheat Sheet; The Twelve-Factor App, Config
- Node.js: CLI options,
--env-file; Diagnostic report and--report-exclude-env - Agent runtimes: Claude Code, environment variables and the subprocess environment scrub; Codex configuration reference,
shell_environment_policy - Short-lived credentials: GitHub REST API, create an installation access token; AWS IAM, temporary security credentials
- Incidents: Codecov, Bash Uploader security update; StepSecurity, Shai-Hulud npm compromise analysis
