high · M1 · MASVS-STORAGE-1 · PTKD-LEFTOVER-ENV-NOT-IGNORED
Secret .env file is not ignored by git
A .env file with secret-looking keys is not covered by .gitignore, so the next commit can publish it to your repository and everyone with access to it (or the whole internet, for a public repo).
How it is exploited
A vibe-coded project has .env with SUPABASE_SERVICE_ROLE_KEY and STRIPE_SECRET_KEY, but the generated .gitignore only lists node_modules. One `git add .` and the keys are in the repository. Bots scan public GitHub for exactly these names within minutes of a push.
Why it matters
Leaked server keys: database takeover, card charges and refunds, cloud bills.
How to fix it
- Add `.env*` and `!.env.example` to .gitignore.
- Check whether the file was ever committed: `git log --all -- .env`. If so, rotate every key in it and purge it from history.
- Keep a .env.example with the names only, so new developers know what to set.
.gitignore
.env*
!.env.exampleDoes your app have this?
PTKD checks your build or your source project for PTKD-LEFTOVER-ENV-NOT-IGNORED and every other check in this knowledge base.
Scan your appReferences
Related checks (M1)
- Secret returned in an API response
- App code calls Supabase admin APIs, so the service-role key ships in the app
- Hardcoded secret in the app
- Credential passed in a URL
- Hardcoded secret sent on the wire
- Secret written in eas.json
- A .env file ships inside the app
- Secret in the Expo app config `extra`, which ships inside the app