Repository navigation
Description
Describe the Bug
migrationsCollection (packages/payload/src/database/migrations/migrationsCollection.ts) sets endpoints: false, graphQL: false and admin.hidden, but no access. sanitizeCollection then fills all four operations with defaultAccess, which allows any user of the admin collection. The REST route answers 501 and GraphQL is off, so the collection isn't reachable over HTTP, but the access layer says yes:
GET /api/accessreportspayload-migrations: { create: true, read: true, update: true, delete: true }for every logged-in admin user, including the least privileged role a project defines.- Any Local API call on the collection with
overrideAccess: falseis allowed for that user.
Nothing in Payload reads or writes this collection with access enforced: payload migrate and friends go through the Local API with overrideAccess defaulting to true. So the collection can be closed by default without changing any migration flow. A project cannot do that itself: the collection is pushed during sanitize after plugins have run, so neither a plugin nor a collection override reaches it (discussions #15329 and #16461 ask for an override for this reason).
Proposed fix, in migrationsCollection:
access: {
create: () => false,
delete: () => false,
read: () => false,
update: () => false,
},Happy to open the PR.
Link to the code that reproduces this issue
Reproduction Steps
git clone https://github.com/jmtorres/payload-migrations-default-access && cd payload-migrations-default-access && cp .env.example .env && pnpm install && MIGRATIONS_ACCESS=closed pnpm payload migrate(an unmodified[email protected] -t website --db sqlitescaffold plus one script).pnpm payload run src/scripts/check-migrations-access.ts. It creates a plain user, builds a request for that user and prints what/api/accessreturns forpayload-migrations(getAccessResults), the collection's access functions called directly, and apayload.findwithoverrideAccess: false:
payload-migrations (via getAccessResults, the /api/access endpoint):
{ "fields": true, "create": true, "read": true, "update": true, "delete": true }
payload-migrations access functions, called directly: { create: true, read: true, update: true, delete: true }
payload.find({ overrideAccess: false }) as [email protected]: 1 migration row(s) readable
MIGRATIONS_ACCESS=closed pnpm payload run src/scripts/check-migrations-access.tsapplies the proposed fix after sanitize (the only place a project can reach the collection):/api/accessomits the collection, every function returnsfalse, and the find is a 403.MIGRATIONS_ACCESS=closed pnpm payload migrateandmigrate:statusstill write and read the table (batch 1, Ran: Yes), since the CLI uses the Local API withoverrideAccess: true; nothing in the migration flow consults these access functions.
Or in a browser: register the first user, log in, GET /api/access, and read payload-migrations.
Which area(s) are affected?
area: core
Environment Info
Payload 3.92.1 (the collection is unchanged on main as of 2026-10-29); also seen on 3.90.2 with @payloadcms/db-postgres. Node 24.21.0, pnpm 11, @payloadcms/db-sqlite in the reproduction.
Activity
fix: address six more Payload v4 database and ecommerce issues [skip ci]