Skip to main content

SKY-D418 · Security in code

PostgreSQL schema creation privilege granted to PUBLIC

MediumCWE-266

A GRANT gives every role permission to create objects in one or more schemas. An ALTER DEFAULT PRIVILEGES grant can apply the same permission to future schemas.

Languages
PostgreSQL
Quality gate
listed, not counted by the gate (full and diff scans). This PostgreSQL finding is report-only.
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

Other roles may resolve names through a schema where anyone can create objects. The effective exposure depends on schema usage and the search paths in use.

What Skylos flags

migration.sql · SQLReported on line 1
GRANT CREATE ON SCHEMA app TO PUBLIC;
pyproject.toml · TOML
[tool.skylos.sql]dialect = "postgresql"

What Skylos leaves alone

migration.sql · SQL
GRANT CREATE ON SCHEMA app TO app_owners;

pyproject.toml: same as in the flagged example.

Why Skylos leaves it alone

Grant schema creation to the roles that manage its objects and review existing grants separately.

How Skylos decides

  1. Skylos checks explicit CREATE and ALL grants on schemas to the PUBLIC grantee.
  2. Grants to a named role, USAGE alone and revocations are outside this review.

How to fix it

Grant schema creation to the roles that manage its objects and review existing grants separately.

migration.sql · SQL · the fix, against the flagged file
Removed: GRANT CREATE ON SCHEMA app TO PUBLIC;Added: GRANT CREATE ON SCHEMA app TO app_owners;

When it can be wrong

  • A shared workspace schema may intentionally permit every role to create objects.

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.