Skip to content

fix: deny all access on the payload-migrations collection - #19206

Open
jmtorres wants to merge 1 commit into
payloadcms:mainfrom
jmtorres:fix/migrations-collection-default-access
Open

jmtorres wants to merge 1 commit into
payloadcms:mainfrom
jmtorres:fix/migrations-collection-default-access

Conversation

@jmtorres

Copy link
Copy Markdown

What?

Sets access on the internal payload-migrations collection so every operation denies.

Why?

The collection sets endpoints: false, graphQL: false and admin.hidden, but no access, so sanitize fills in defaultAccess (any admin user). GET /api/access then reports create/read/update/delete as true for every logged-in admin user, and a Local API call with overrideAccess: false is allowed. Projects can't close it themselves: the collection is pushed during sanitize after plugins run (discussions #15329 and #16461 ask for an override for this reason).

How?

Four () => false access functions on migrationsCollection. The migration CLI and the dev push go through the Local API with overrideAccess defaulting to true, so no migration flow consults them. Verified on the reproduction in the linked issue: with the same change applied post-sanitize, payload migrate and migrate:status still write and read the table, /api/access omits the collection, and the enforced find returns 403.

Fixes #19204

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 96bc50e and 3ee7033.

Files selected for processing: 1
  • packages/payload/src/database/migrations/migrationsCollection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The migration collection now denies create, read, update, and delete access. Comments state that the migration CLI and dev push use the Local API with overrideAccess: true.

Changes: Migration collection access controls

Layer / File(s) Summary
Define access rules
packages/payload/src/database/migrations/migrationsCollection.ts
The collection’s create, read, update, and delete access functions now return false. Comments describe the migration CLI and dev push access behavior.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • payloadcms/payload#17459: The migration adds a system that reads and writes the payload-migrations collection.
  • payloadcms/payload#19080: The PR changes the payload migrate CLI and its migration contract, which use the collection’s access override.

Suggested reviewers: paulpopus

Merge Risk: Minimal · up to 3ee70

The migration collection is denied through access checks without blocking the inspected migration workflows. No merge-blocking issue remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: denying all access on the internal payload-migrations collection.
Description check Passed The description directly explains what changed, why it was required, how access is denied, and why migration flows remain unaffected.
Linked Issues check Passed Issue #19204 requires that create, read, update, and delete on payload-migrations deny by default, and that the migration flows keep working. The change at head adds access with create, delete…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file, packages/payload/src/database/migrations/migrationsCollection.ts (+10/-0). The change adds one access block and a comment that explains why…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #19204 requires that create, read, update, and delete on payload-migrations deny by default, and that the migration flows keep working. The change at head adds access with create, delete, read, and update set to () => false on migrationsCollection (packages/payload/src/database/migrations/migrationsCollection.ts). Because the collection defines access, sanitize no longer applies defaultAccess to it. This meets the requested fix. The migration flows do not depend on the access functions. getMigrations calls payload.find with overrideAccess: true, and migrate calls payload.create with overrideAccess: true. migrateStatus reads through getMigrations. The migration CLI and dev push are covered by the same Local API path as described in the issue. The PR also reports a reproduction in which /api/access omits the collection and the enforced find returns 403, while payload migrate and migrate:status still work. No coding requirement in #19204 remains unmet. The issue's reproduction was not re-run; this assessment relies on the source read and the PR's reported results.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file, packages/payload/src/database/migrations/migrationsCollection.ts (+10/-0). The change adds one access block and a comment that explains why the block is needed. Both directly implement the objective in #19204. No unrelated files, refactors, or behavior changes appear in the diff. The comment's claim that only the migration CLI and dev push touch the collection is consistent with the code read in getMigrations.ts and migrate.ts.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

payload-migrations gets the default access functions, so /api/access reports create/read/update/delete as allowed for every admin user

1 participant