Skip to main content

SKY-D420 · Security in code

PostgreSQL table write privileges granted to PUBLIC

MediumCWE-266

The SQL grants table or column write privileges to PUBLIC. It can grant them on existing objects or set defaults for future tables.

Languages
PostgreSQL
Quality gate
listed, not counted by the gate (full and diff scans). The findings gate lists this advisory. The separate production migration check can block new PUBLIC writes when the target branch forbids them.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Every database role receives the listed privileges. Schema access and applicable row-level policies still affect the operations each role can perform.

What Skylos flags

migration.sql · SQLReported on line 2
ALTER DEFAULT PRIVILEGES IN SCHEMA app  GRANT UPDATE ON TABLES TO PUBLIC;
pyproject.toml · TOML
[tool.skylos.sql]dialect = "postgresql"

What Skylos leaves alone

migration.sql · SQL
ALTER DEFAULT PRIVILEGES IN SCHEMA app  GRANT UPDATE ON TABLES TO app_writers;

pyproject.toml: same as in the flagged example.

Why Skylos leaves it alone

Select the role that should write these tables. Review grants already present on existing tables separately.

How Skylos decides

  1. Skylos checks INSERT, UPDATE, DELETE, TRUNCATE and ALL on tables for the PUBLIC grantee, including default privileges.
  2. A read-only grant stays quiet.

How to fix it

Select the role that should write these tables. Review grants already present on existing tables separately.

migration.sql · SQL · the fix, against the flagged file
ALTER DEFAULT PRIVILEGES IN SCHEMA appRemoved:   GRANT UPDATE ON TABLES TO PUBLIC;Added:   GRANT UPDATE ON TABLES TO app_writers;

When it can be wrong

  • Some shared schemas intentionally accept contributions from every database role.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Review the statement in the context of its migration.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.