secrets.md
| source_url | https://github.com/nuke-on-rails/nuke-on-rails/blob/67c72332e6eea2a2897f3ed72a061ac8fc175140/arsenal/secrets.md |
|---|
Weapon: Committed Secrets
API keys pasted into code and key files committed to git — alongside IDOR, the signature mistake of unreviewed AI-generated apps. No engine in the pipeline covers this; the highest-signal checks are deterministic and need no extra tooling.
Deterministic checks (run these, don't guess)
git ls-files | grep -E 'master\.key|credentials.*\.key|\.env($|\.)|\.kamal/secrets' # key files under version control
git log --diff-filter=D --name-only --format= | sort -u | grep -E 'master\.key|\.env|\.kamal/secrets' # deleted ≠ gone
config/master.key(or anycredentials/*.key) committed —credentials.yml.encis now plaintext for anyone with repo access. Critical..env/.env.productionversioned — same class, no decryption needed..kamal/secretscommitted — holds the registry password,RAILS_MASTER_KEY, and infra credentials in plaintext; it must be gitignored.- A key file that was committed once and later deleted is still compromised: it lives in history.
Code reading (on initializers, config, and hotspot files)
- Hardcoded credentials:
sk_live_/sk-(Stripe/OpenAI),AKIA(AWS), Twilio SIDs, SMTP passwords, JWT secrets, webhook signing secrets — especially inconfig/initializers/and service classes. - Devise
pepper/secret_keyinline (the authentication weapon checks this too). - Secrets in seeds, fixtures, or
database.ymlwith production credentials. - Secrets baked into a
Dockerfile/docker-compose.yml— anENV/ARGholding a real secret, or aCOPYof a key file. Image layers preserve it forever, recoverable even if a later layer deletes it. Rails 8 ships aDockerfileby default, so this surface is common. ENV.fetch("X", "actual-secret-as-fallback")— the fallback ships the secret.
# Problem — a live secret pasted into code (now in git history forever, even if deleted later)
STRIPE = Stripe::Client.new("sk_live_51H8xQ2eZvKYlo3kQ...")
secret = ENV.fetch("JWT_SECRET", "super-secret-prod-value") # the fallback ships the secret
# Fix — read from credentials / ENV, keep the secret out of the repo, then ROTATE the leaked one
STRIPE = Stripe::Client.new(Rails.application.credentials.dig(:stripe, :secret_key))
secret = ENV.fetch("JWT_SECRET") # no fallback — fail loudly if it's unset
Severity and reporting
A live credential in the repo is a confirmed critical finding — it competes with IDOR for the top of the report. State the blast radius ("this Stripe live key can issue refunds"). A key in history but rotated since, or clearly a test/dummy key, goes to "theoretical" — verify before accusing; a false "your key is leaked" burns trust like any false security claim.
Preferred Remedies
- Rotate first. Removing the file or rewriting history does not un-leak a key. Rotation is step one, always.
- Move secrets to Rails credentials (
rails credentials:edit) or real ENV injection; keepmaster.keyand.envin.gitignore. - Replace committed
.envwith a.env.exampleof empty placeholders. - Add a preventive pre-commit guard so it can't happen again: git-secrets or gitleaks.
Copyright (c) 2026 Nuke on Rails contributors License files are attached. MIT
MIT notice
MIT License
Copyright (c) 2026 Nuke on Rails contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Children
No children yet.
Like how this is organised?
Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.