Skip to main content

SKY-D419 · Security in code

PostgreSQL login role bypasses row-level security

MediumCWE-266

One role declaration enables login together with BYPASSRLS. CREATE USER supplies LOGIN by default.

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

An account with both attributes can log in and bypass row-level policies on relations it can access. Other object privileges still apply.

What Skylos flags

migration.sql · SQLReported on line 1
CREATE USER reporting BYPASSRLS;
pyproject.toml · TOML
[tool.skylos.sql]dialect = "postgresql"

What Skylos leaves alone

migration.sql · SQL
CREATE USER reporting NOBYPASSRLS;

pyproject.toml: same as in the flagged example.

Why Skylos leaves it alone

Decide whether this account should be subject to the same row-level policies as ordinary application users.

How Skylos decides

  1. Skylos checks CREATE ROLE, CREATE USER and ALTER ROLE or USER.
  2. An ALTER must set both attributes in the same statement, because earlier settings are unknown.

How to fix it

Decide whether this account should be subject to the same row-level policies as ordinary application users.

migration.sql · SQL · the fix, against the flagged file
Removed: CREATE USER reporting BYPASSRLS;Added: CREATE USER reporting NOBYPASSRLS;

When it can be wrong

  • A maintenance or backup account may intentionally bypass row-level security.

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.