lowCWE-1059

No .env.example File

Without a .env.example file, new contributors don't know what environment variables are required, leading to insecure workarounds like hardcoding values.

How It Works

When a developer clones your repo and can't find which env vars are needed, they either spend time reading the code to figure it out or hardcode values to make it work quickly. A .env.example with all required keys (but no real values) solves both the documentation problem and reduces the temptation to hardcode.

Vulnerable Code
// BAD: no .env.example — developer has to guess what's needed
// .gitignore
.env
// No .env.example file
// developer clones repo, nothing works, they hardcode DATABASE_URL in code
Secure Code
// GOOD: .env.example documents all required variables
// .env.example (committed to git, no real values)
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
STRIPE_SECRET_KEY=sk_test_your_key_here
ANTHROPIC_API_KEY=sk-ant-your_key_here

Real-World Example

Studies of open-source repositories show that missing configuration documentation is one of the top reasons developers accidentally commit real secrets — they can't find the .env.example so they paste real values directly into code.

How to Prevent It

  • Create a .env.example with every required key and a placeholder value describing what goes there
  • Keep .env.example updated whenever you add new environment variables
  • Add a setup check in your README that tells developers to copy .env.example to .env
  • Consider using a tool like dotenv-safe that validates all .env.example keys are present at startup

Affected Technologies

Node.js

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities