GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO PUBLIC; gives every role in the database, including ones created later, full rights on every existing table in public: SELECT, INSERT, UPDATE, DELETE, TRUNCATE and more. Revoke it now, then check what other roles did with it.
How to recover the data
- Revoke the grant:
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM PUBLIC; - Check that no grants to
PUBLICremain:SELECT table_name, privilege_type FROM information_schema.role_table_grants WHERE grantee = 'PUBLIC';and look forALTER DEFAULT PRIVILEGESthat grant toPUBLICon new tables. - Review what ran in the meantime (database logs,
pg_stat_statements) for reads or changes by roles that should not have had access, and restore data from a point-in-time copy if something was changed.
Why it happens
PUBLIC is not a role you created: it is the implicit group every role belongs to. A grant to it is often a shortcut to fix a "permission denied" quickly, written by a person or generated by a tool, and it silently opens access far wider than the one role that needed it.
How to fix it
Create roles per use (application, reporting, agents), grant each only what it needs, and manage those grants in code that is reviewed, not in ad-hoc SQL:
GRANT SELECT ON orders, products TO reporting;For tables created later, use ALTER DEFAULT PRIVILEGES ... GRANT ... TO reporting rather than granting to PUBLIC.
How to stop it from happening again
VERICTO-082 · GRANT / REVOKE · Severity: High · AST node: GrantStmt
The statement the rule reports
-- grants.sql
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO PUBLIC;
Real CLI output
$ npx @vericto/vericto-cli@2.3.0 check --offline grants.sql
note: offline mode: 42 standard rules at default severities, engine 5.1.0. Custom rules, overrides, sensitive columns, allowlists and the audit trail apply online only.
✖ grants.sql BLOCKED VERICTO-082 high
GrantStmt
fix: Manage privileges through your access-control / IaC pipeline
1 blocked · 0 allowed · 0 flagged · 0 monitored (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
✖ Vericto blocked 1 statement (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
✖ grants.sql BLOCKED VERICTO-082 high
GrantStmt
fix: Manage privileges through your access-control / IaC pipeline
This is Vericto enforcing a rule — the exit code is intentional, not a crash.
To allow a finding on purpose, add an inline comment on the statement:
-- vericto:ignore[VERICTO-082] <reason> (a reason is required)
The CLI blocks it and exits with code 1, so the CI job fails before the merge.
Try it free, no account
The CLI checks your .sql files on your machine with the 42 standard rules: no sign-up, no API key, and no SQL leaves your computer. It is open source (AGPL-3.0-only).
npx @vericto/vericto-cli@2.3.0 check --offline migrations/
On every pull request
The vericto/check-sql GitHub Action (Apache-2.0) runs the same offline check on the .sql files a PR changes and annotates the findings on the PR. Save it as .github/workflows/vericto.yml:
on: pull_request
jobs:
vericto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with: { fetch-depth: 0 }
- uses: vericto/check-sql@v1
with: { offline: true, upload-sarif: false }
At runtime, for AI agents
The SQL an AI agent writes never goes through a PR. The Vericto TCP proxy checks each statement between the application or agent and the database, and the MCP check_sql tool lets the agent check SQL before it runs it. Both use the runtime profile, which also blocks schema changes.
The AST condition in the engine
The rule is a deterministic predicate over the AST, in src/rules/evaluator.rs of the open source engine (AGPL-3.0-only), at this page's commit:
"VERICTO-082" => find(stmts, |s| s.kind == StatementKind::Grant)
.map(|s| {
let mut v = violation(
rule,
s,
Some("Manage privileges through your access-control / IaC pipeline".to_string()),
);
v.ast_node_path = "GrantStmt".to_string();
v
}),
Frequently asked questions
Related rules
- VERICTO-019: ALTER TABLE DISABLE TRIGGER / RLS
- VERICTO-080: COPY … TO/FROM PROGRAM (shell execution)
- VERICTO-051: SELECT * without WHERE clause