Separate environment configs for dev/staging/prod
Why it matters
Using the same environment configuration across development, staging, and production means a developer mistake in a test environment can hit production data, a staging webhook fires against live Stripe, or a misconfigured query runs against the production database. CWE-1188 (Use of Hardcoded Default Values) and OWASP A05 both flag shared configurations as a misconfiguration risk. NIST CM-6 requires controlled configuration management — shared .env files with no environment separation make that impossible to enforce. Beyond security, shared configs make incident response harder: you cannot revoke a staging credential without also revoking the production one.
Severity rationale
High because shared environment configs mean a misconfiguration, test, or breach in any environment can directly impact production systems and data.
Remediation
Create distinct configuration files for each environment and load them based on NODE_ENV. Each file must use environment-specific credentials, endpoints, and API keys — never the same values.
.env.development # local dev: localhost DB, Stripe test keys, sandbox API endpoints
.env.staging # staging server: staging DB, Stripe test keys, staging endpoints
.env.production # production server: production DB, Stripe live keys, production endpoints
// At server startup
import dotenv from 'dotenv'
dotenv.config({ path: `.env.${process.env.NODE_ENV ?? 'development'}` })
All three files go in .gitignore. Maintain a .env.example with placeholder values for each variable so new developers know what to fill in.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Environment Security Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-1188 — Initialization of a Resource with an Insecure Default
- owasp:2021 · A05 — Security Misconfiguration
- nist:rev5 · CM-6 — Configuration Settings
- soc2:2017 · CC8.1 — Change management
Taxons
History
- 2026-04-18·v1.0.0·Initial import from environment-security·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC8.1) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2