An environment variable supplies a secret to an application at runtime instead of embedding it in source code. Common uses include passwords, API keys, and database connection strings. section 11.8 section 8.7.3
Keep the secret out of the code, but make sure the surrounding security is sound:
- For local development, store secrets in a .env file excluded from source control and load it with a suitable library, such as python-dotenv or dotenv for Node.js. section 11.8
- For deployment, developer-focused platforms can inject secrets through encrypted environment-variable settings. Cloud compute can instead retrieve secrets through an assigned identity. section 11.5.2
- Limit database account permissions too: keeping a password out of source code does not make an overprivileged account safe. section 11.8 section 8.7.3























