Skip to content

fix: revoke grants to unused table operations - #1395

Merged
itslenny merged 1 commit into
masterfrom
lenny/revoke-unused-grants
Sep 16, 2026
Merged

itslenny merged 1 commit into
masterfrom
lenny/revoke-unused-grants

Conversation

@itslenny

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Migrations use GRANT ALL when they only need basic row level CRUD operations

What is the new behavior?

Grants on the storage tables are scoped down to just the row-level CRUD operations actually needed

@itslenny
itslenny requested a review from a team as a code owner September 15, 2026 20:50
@coveralls

coveralls commented Sep 15, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 35144246783

Coverage remained the same at 82.844%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14072
Covered Lines: 12107
Line Coverage: 86.04%
Relevant Branches: 8602
Covered Branches: 6677
Branch Coverage: 77.62%
Branches in Coverage %: Yes
Coverage Strength: 3024.0 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline finding, I also checked whether other storage tables besides objects/buckets/buckets_analytics/buckets_vectors/vector_indexes were left with stale TRUNCATE/REFERENCES/TRIGGER grants: storage.prefixes is missing from the REVOKE list here, so anon/authenticated retain those privileges on it via the same default-privilege inheritance path.

Extended reasoning...

The confirmed inline finding covers storage.buckets_vectors and storage.vector_indexes retaining INSERT/UPDATE/DELETE beyond what was explicitly granted. Separately, I verified the REVOKE statement's table list (storage.objects, storage.buckets, storage.buckets_analytics, storage.buckets_vectors, storage.vector_indexes) omits storage.prefixes, which is a table created in this schema (migrations 0026/0029) and would have inherited the same ALTER DEFAULT PRIVILEGES ALL grant from migration 0002 that motivated this cleanup. This means anon/authenticated roles still hold TRUNCATE, REFERENCES, and TRIGGER on storage.prefixes after this migration, which is inconsistent with the PR's stated goal of scoping storage grants down to CRUD-only. This is a distinct gap from the two already-ruled-out candidate findings and from the confirmed finding, so I'm noting it as an additional point for human review rather than restating what's already posted.

Comment thread migrations/tenant/0073-revoke-grants-to-unused-operations.sql Outdated
@itslenny
itslenny force-pushed the lenny/revoke-unused-grants branch from 487fff1 to 8ab9837 Compare September 15, 2026 21:36
Comment thread src/test/database-protection.test.ts Outdated
Comment thread migrations/tenant/0073-revoke-grants-to-unused-operations.sql
@itslenny
itslenny force-pushed the lenny/revoke-unused-grants branch from 8ab9837 to 9cbc02d Compare September 16, 2026 18:25
@ferhatelmas
ferhatelmas force-pushed the lenny/revoke-unused-grants branch from 9cbc02d to f64df23 Compare September 16, 2026 20:03
@itslenny
itslenny merged commit 36a3a23 into master Sep 16, 2026
38 of 40 checks passed
@itslenny
itslenny deleted the lenny/revoke-unused-grants branch September 16, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants