T09 · Insecure Skill Coding Practices
- Location
fpm.md:45- Finding
PHP-FPM Workers Inherit the Complete Service Environment
- Content
View full analysis
Vulnerability Details
File Location:
fpm.md:45,53
Vulnerability Type: Excessive environment-variable exposure
Risk Level: MediumVulnerable Configuration
ini clear_env = no ; FPM clears the environment by defaultThe accompanying guidance states:
text - `clear_env = no` is required for 12-factor configuration — by default FPM starts workers with a scrubbed environment and `getenv()` returns nothing. The alternative is explicit `env[KEY] = value` lines in the pool.Technical Analysis
PHP-FPM normally scrubs inherited environment variables before starting application workers. Setting
clear_env = nomakes the entire environment inherited from the service manager available to PHP application code.This configuration violates least privilege when an application requires only a limited set of configuration values. The inherited environment may contain database passwords, API tokens, cloud credentials, deployment secrets, or variables intended for service-management components rather than the PHP application.
The assertion that disabling environment scrubbing is required for 12-factor configuration is overly broad. PHP-FPM can retain environment isolation while explicitly forwarding only the variables required by the application through narrowly scoped
env[KEY] = valuedirectives.The Skill does not itself read or exfiltrate environment variables. Exploitation requires an application-level vulnerability, malicious application code, or an information-disclosure endpoint capable of reading the worker environment.
Attack Path
- An operator adopts the documented PHP-FPM pool configuration and sets
clear_env = no. - The FPM service inherits sensitive environment variables from systemd, a container runtime, deployment tooling, or a parent process.
- Every PHP worker receives the complete inherited environment.
- An attacker exploits an unrelated PHP v ...[truncated 1010 chars]
- An operator adopts the documented PHP-FPM pool configuration and sets
- Remediation
View remediation
Remediation Suggestions
-
Retain PHP-FPM's default environment scrubbing:
ini clear_env = yes -
Explicitly forward only variables required by the application:
ini env[APP_ENV] = production env[DATABASE_URL] = $DATABASE_URL -
Use a dedicated, application-specific service environment rather than inheriting deployment-agent, host-wide, or unrelated service credentials.
-
Prefer a secret manager with narrowly scoped identities and short-lived credentials where supported.
-
Ensure production deployments disable public
phpinfo()pages and prevent error handlers, debug endpoints, and logs from dumping$_ENV,$_SERVER, or the process environment. -
Run each application in a separate FPM pool and operating-system identity so one compromised application cannot access another application's environment or files.
-
Update the documentation to present
clear_env = noas an explicit risk-bearing exception rather than a general requirement for 12-factor configuration.
-
