Fix guide · critical · exposed_rails_database_yml
Rails config/database.yml exposed
Your Rails config/database.yml is publicly reachable. It contains the DB hostname, username, and (in most configs) the password in plaintext.
Why it matters
Rails apps configure database connections via config/database.yml. Three blocks: development:, test:, production: — each with adapter, host, database, username, password fields.
If the production block has a hardcoded password (rather than ENV['DATABASE_URL'] or Rails.application.credentials), and the file is reachable at /config/database.yml, the attacker has the database credentials and the hostname in one fetch.
How it ends up reachable: misconfigured asset pipeline serving config/*, Nginx with overly-permissive / location, an admin tool's "view config" endpoint left in production, or a deploy bug that put config/ inside public/.
How to fix it
- Pull DB credentials out of database.yml. Use
DATABASE_URLenv var, orRails.application.credentials.dig(:db, :password)— both keep secrets out of source-controlled YAML. - Block
/config/*at the web server.config/should never be reachable. - Rotate the leaked DB credentials immediately. Generate a new password, update the production config, restart the app.
- Audit your deploy script. Ensure only
public/is exposed;config/,db/,lib/,storage/should all be inaccessible.
Did vibecheck flag this on your app?
If you reached this page from a vibecheck inspection report, the redacted match in your scan output is the exact string we found in your bundle. After applying the fix above, run the inspection again — the finding should clear.
Run another inspection