Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
oakoss avatar

Database Security

  • 144 installs
  • 14 repo stars
  • Updated March 2, 2026
  • oakoss/agent-skills

Harden database access, credentials, encryption, and query patterns before production release to reduce data breach and injection risk.

About

Covers database security hardening for production systems: secure connection handling, credential management, encryption, access control, safe query patterns, and audit practices to protect sensitive application data.

  • Least-privilege access
  • Encryption standards
  • Injection prevention
  • Credential hygiene
  • Audit readiness

Database Security by the numbers

  • 144 all-time installs (skills.sh)
  • +6 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #900 of 2,203 Security skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oakoss/agent-skills --skill database-security

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs144
repo stars14
Last updatedMarch 2, 2026
Repositoryoakoss/agent-skills

What it does

Harden database access, credentials, encryption, and query patterns before production release to reduce data breach and injection risk.

Files

SKILL.mdMarkdownGitHub ↗

Security Audit

Database security auditor specialized in Row Level Security (RLS) enforcement, Zero-Trust database architecture, and forensic audit trails. Focuses on Supabase, Postgres, and Convex data layer security. For general application security (OWASP Top 10, auth patterns, security headers, input validation), use the security skill instead.

Quick Reference

NeedApproach
RLS enforcementEnable on every public table; separate policies per operation
RLS performanceIndex RLS columns; wrap auth.uid() in (select ...) subselect
Zero-Trust DBMicro-segmentation, identity propagation, TLS enforcement
Supabase auth in RLSUse (select auth.uid()) and auth.jwt(); never auth.role()
Convex auth guardsCall ctx.auth.getUserIdentity() in every public function
JIT accessTime-bound grants that expire automatically
Audit trailsDatabase triggers with immutable audit_log table
PGAuditExtension for statement-level and object-level SQL auditing
Service role safetyNever use service_role key in client-side code
Views and RLSUse security_invoker = true (Postgres 15+) to enforce RLS
Schema segmentationSeparate public, private, and audit schemas
Database complianceRLS + audit logging + encryption satisfies multiple frameworks

Audit Protocol

Follow this sequence when performing a database security audit:

1. Attack Surface Mapping: Identify all entry points to the data layer (public APIs, internal dashboards, AI agents, cron jobs) 2. RLS Coverage Check: Query pg_tables to verify every public schema table has RLS enabled and appropriate policies 3. Policy Review: Check for logical bypasses, missing WITH CHECK clauses, overly permissive FOR ALL policies 4. Service Role Audit: Search client code for service_role key exposure; verify it only appears in server-side code 5. Function Audit: Check for security definer functions in exposed schemas and Convex functions missing auth guards 6. Access Simulation: Execute queries as anon and authenticated roles to verify enforcement 7. View Audit: Verify views use security_invoker = true or are not in exposed schemas 8. Audit Trail Verification: Confirm triggers or PGAudit capture all security-relevant operations 9. Compliance Validation: Map database controls against applicable regulatory frameworks

Security Principles

PrincipleDatabase Application
Defense in DepthRLS + application checks + schema segmentation
Least PrivilegeMinimal GRANT per role; anon gets near-zero access
Zero TrustVerify identity at DB level even for internal requests
Secure by DefaultRLS enabled on creation; default-deny when no policy
Fail SecurelyPostgres default-deny on RLS; generic error responses
Assume BreachDesign assuming attacker has a valid JWT

Anti-Patterns

Anti-PatternRisk
Security by obscurity (UUIDs only)Attackers enumerate IDs via IDOR
Anon role with SELECT on sensitive tablesPublic data exposure via Supabase API
RLS columns without indexesProduction performance degradation (100x+)
Frontend-only permission checksAttackers bypass via direct API calls
Standing admin privilegesExcessive blast radius if compromised
service_role key in client-side codeBypasses all RLS policies completely
FOR ALL policies instead of per-operationUnintended write access through broad rule
Security definer functions in public schemaFunctions callable from API, bypass RLS
Views without security_invokerViews bypass RLS silently

Common Mistakes

MistakeCorrect Pattern
Using auth.uid() = user_id without wrapping in (select ...)Use (select auth.uid()) = user_id so Postgres caches the result via initPlan
Using FOR ALL instead of separate per-operation policiesCreate separate SELECT, INSERT, UPDATE, DELETE policies for clarity and safety
Leaving anon role with SELECT on sensitive tablesRestrict anon access; require authenticated role for sensitive data
Relying on UUIDs as the only access controlEnforce RLS policies and explicit auth checks alongside unique identifiers
No index on columns used in RLS USING clausesAdd B-tree indexes on all columns referenced in RLS policy expressions
Convex function missing ctx.auth.getUserIdentity() callEvery public query and mutation must validate identity before accessing data
Using service_role key in client-side codeUse anon key client-side; service_role only in server-side functions
Views bypassing RLS without security_invokerSet security_invoker = true on views in Postgres 15+
Security definer functions in exposed schemasPlace security definer functions in non-exposed schemas with search_path = ''
No audit logging for security-relevant database eventsUse triggers and PGAudit to capture all data access and modifications

Relationship to Security Skill

The application-security skill covers general application security: OWASP Top 10, authentication patterns, input validation, security headers, and compliance overviews. This database-security skill complements it by focusing on database-layer concerns: RLS policy design and performance, Supabase/Postgres-specific patterns, Convex auth guards, PGAudit configuration, and database-specific compliance implementations (SQL functions for GDPR erasure, HIPAA PHI audit triggers, etc.).

Delegation

  • Verify RLS enforcement with access simulations: Use Task agent to run anonymous and authenticated queries against every public table
  • Audit Convex functions for missing auth guards: Use Explore agent to scan all query and mutation handlers for getUserIdentity calls
  • Design zero-trust database architecture: Use Plan agent to map schemas, access policies, JIT grants, and audit log design
  • Generate database compliance evidence: Use Task agent to run audit queries and produce compliance reports

References

  • rls-performance.md -- RLS policy performance, initPlan caching, stable functions, separate policies, EXPLAIN benchmarking
  • zero-trust-database.md -- Micro-segmentation, identity propagation, connection security, JIT access controls
  • audit-logging.md -- Trigger-based auditing, PGAudit extension and log classes, log integrity, tamper-proof storage
  • convex-security.md -- Identity validation, manual RLS in functions, granular functions, role-based access via JWT claims
  • threat-modeling.md -- STRIDE applied to database access, RLS bypass vectors, data layer trust boundaries
  • application-security.md -- Service role management, schema exposure, security definer functions, views and RLS
  • compliance-frameworks.md -- Database-specific GDPR, HIPAA, SOC2, PCI-DSS requirements and SQL implementations

Related skills

Securityauditappsec

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.