Group
  • Security

    Restrict my app's database user permissions

    Splits the app's database credentials away from superuser access and scopes them to what the app actually needs.

    • Improve quality
    • Plan & validate
    • Intermediate
    • General

Free Prompt

Review what database credentials my app uses at runtime and scope them to least privilege. Check my connection config and how the database was set up. Apply these principles: the app should connect with a dedicated database user, not the superuser, root, or admin account; that user needs only the permissions the app uses (typically SELECT, INSERT, UPDATE, DELETE on the app's own tables or collections), not DDL like DROP or ALTER and not access to other databases on the same server; migrations run with separate, broader credentials used only at deploy time, not the runtime ones; and credentials come from environment variables, never from committed config. Do not change the database schema or any queries. If my host provisions a single all-powerful user by default (common on managed databases), show me how to create the scoped user with the provider's tooling or SQL. Keep a path for running migrations so deploys don't break. Deliver: the current permission state, the scoped setup you recommend with the exact commands or steps, and a verification: connect as the app's new user and confirm a DROP or cross-database query fails while normal app queries work.

What This Does / How This Helps

Moves your app off its all-powerful database credentials and onto a dedicated user that can only do what the app actually needs. This is blast-radius control. If an attacker ever finds a query bug or a leaked credential, a superuser connection means they can drop tables, read every database on the server, and create their own admin users. A scoped user turns the same bug into a much smaller incident. Managed hosts hand you a god-mode user by default because it's convenient, so the prompt includes the exact steps to create the scoped one and a verification that dangerous operations now fail.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts