Introducing a new way to review your PRs.

Read the announcement

raroque / vibe-security-skill

Agent skill that audits vibe-coded apps for common security vulnerabilities introduced by AI coding assistants

View on GitHub

15 documents · Updated Oct 30, 2026

docs / database-security

Database security

Database security protects stored data from unauthorized reads, writes, and administrative changes. A sound review checks the full path from an untrusted request to the database, then checks the permissions and operational settings that limit what each actor can do.

Security boundary

The database is a security boundary, not only a storage layer. Client requests, public database APIs, and application services must all be treated as untrusted until the system proves who is acting and which records that actor may use.

Actor and record ownership

Access decisions must bind an authenticated actor to the specific record or resource. A rule that only checks that a user is logged in still permits one user to read or change another user's data.

The review should confirm that:

  • Read access is limited to records the actor may see.
  • Create and update access preserves the record owner.
  • Related tables, such as join tables and audit records, have their own access rules.
  • Child collections and stored files do not inherit protection by assumption.

References: vibe-security/…/database-security.md• L21-37 vibe-security/…/database-security.md• L39-68 vibe-security/…/database-security.md• L121-123

Privileged operations

Administrative database actions need a separate trust path. A privileged server key or elevated database function can bypass normal row rules, so it must stay on trusted server paths and must validate its inputs and caller context.

Use narrow privileged operations for tasks such as changing roles, credits, or subscription state. Do not expose a general-purpose elevated function through a public data interface.

References: vibe-security/…/database-security.md• L55-75 vibe-security/…/secrets-and-env.md• L23-35

Query and write safety

Query safety keeps attacker-controlled values from changing the meaning of a query. Write safety also limits which fields a request may change, because a valid record update can still become a privilege escalation if it accepts protected fields.

Query construction

The application should pass external values as data through parameterized queries or safe ORM methods. Runtime validation is needed before database calls because compile-time types do not constrain hostile requests.

The review should look for:

  • SQL text built by joining user input into a string.
  • Raw query escape hatches that accept untrusted values.
  • Unvalidated objects passed as ORM filters.
  • Request bodies copied into update data without an allowlist.

References: vibe-security/…/data-access.md• L3-43 vibe-security/…/data-access.md• L45-66 vibe-security/…/data-access.md• L68-79

Field and value control

Database permissions must protect sensitive fields as well as whole rows. Users may need to edit a display name while never being allowed to edit an administrator flag, account balance, owner ID, or subscription level.

The system should validate data type, size, and allowed values at the request boundary. Database rules should then enforce the same ownership and field limits so a second access path cannot weaken the control.

References: vibe-security/…/database-security.md• L39-64 vibe-security/…/database-security.md• L109-140 vibe-security/…/data-access.md• L45-79

Database service exposure

Managed database services often expose tables, collections, functions, or file objects through a public client API. This model is safe only when every exposed resource has an explicit policy and the public credential has limited power.

Resource policy coverage

Each resource needs a policy that matches its role in the product. Main tables are not enough: junction tables, metadata, logs, subcollections, and storage objects can reveal or change sensitive data when they are left outside the policy review.

An enabled policy system with no matching rule usually denies access. That is safer than an open rule, but it can still break product flows. Review both unauthorized access and the intended access paths.

References: vibe-security/…/database-security.md• L7-19 vibe-security/…/database-security.md• L66-79 vibe-security/…/database-security.md• L91-107 vibe-security/…/database-security.md• L121-145

Public and server credentials

Public client credentials must not grant administrative database power. Connection strings, service-role keys, and other secrets belong only in server-side configuration, while client code should receive only the narrow public credential intended for it.

If a database secret has entered source control or a client bundle, treat it as compromised. Remove exposure, rotate the credential, and review the access it could have granted.

References: vibe-security/…/secrets-and-env.md• L3-10 vibe-security/…/secrets-and-env.md• L12-39

Review flow

Database-focused review starts with the data boundary and follows a request through identity, authorization, query construction, and operational access. This flow helps separate a missing permission from a query bug or an exposed credential.

The review path is:

  1. Identify every client, API, function, and service that can reach stored data.
  2. Map each resource to its allowed actors and allowed actions.
  3. Check ownership and field rules for reads, creates, updates, and deletes.
  4. Check that external values are validated and passed safely to queries.
  5. Check privileged functions, database credentials, and storage rules.
  6. Test both denial cases and the intended user flows.

This page complements identity and data protection, data access security, and secrets and environment security. Use those pages for identity-wide controls, detailed input handling, and secret storage.

References: vibe-security/SKILL.md• L15-42 vibe-security/…/database-security.md• L147-151

Change checklist

When these files or sections are changed, remember to consider these:

  • A new table, collection, child collection, storage bucket, or public function needs its own access policy and ownership check.
  • A new mutable field must be reviewed for mass assignment and for client-side changes to roles, balances, ownership, or plan state.
  • A change from a server-only database client to a browser or mobile client must be checked for credential scope and policy coverage.
  • A new raw query or ORM filter must preserve parameter binding and runtime input validation.
  • A change to a privileged function must preserve a restricted schema, a fixed search path where applicable, and input checks.

Important failure modes

TriggerConsequenceGuard
Row-level rules are disabled or use an authenticated-only conditionAny client with the public credential can read or change other users' rowsEnable rules on every exposed resource and bind access to the actor and record owner
Update rules omit the post-update ownership checkA user can move a row to another owner or change a protected identity fieldEnforce both the current owner and the resulting owner or allowed field set
A request body is passed directly to an ORM update or filterAn attacker can set protected fields or broaden a queryValidate input at the boundary and construct an allowlisted database operation
A privileged key or function is exposed through client code or a public APIAn attacker can bypass normal row rules and alter the whole data setKeep elevated credentials and functions on trusted server paths
A child collection or storage object has no separate policyData or files outside the main table become readable or writableReview every related resource as an independent security boundary

Key files

FileWhy to read it
vibe-security/…/database-security.mdDefines the database policy model for Supabase, Firebase, Convex, and storage resources.
vibe-security/…/data-access.mdDefines safe query construction, runtime validation, and protection against mass assignment.
vibe-security/…/secrets-and-env.mdDefines which database credentials may be public and how to handle exposed secrets.
vibe-security/SKILL.mdPlaces database review within the wider security audit and sets the trust boundary.