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
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
ALTER DEFAULT PRIVILEGES IN SCHEMA app GRANT UPDATE ON TABLES TO PUBLIC;[tool.skylos.sql]dialect = "postgresql"What Skylos leaves alone
ALTER DEFAULT PRIVILEGES IN SCHEMA app GRANT UPDATE ON TABLES TO app_writers;Why Skylos leaves it alone
Select the role that should write these tables. Review grants already present on existing tables separately.
How Skylos decides
- Skylos checks INSERT, UPDATE, DELETE, TRUNCATE and ALL on tables for the PUBLIC grantee, including default privileges.
- 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.
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.