Skip to content

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

Open

Description

@jmtorres

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/access reports payload-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: false is 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

https://github.com/jmtorres/payload-migrations-default-access

Reproduction Steps

  1. 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 sqlite scaffold plus one script).
  2. pnpm payload run src/scripts/check-migrations-access.ts. It creates a plain user, builds a request for that user and prints what /api/access returns for payload-migrations (getAccessResults), the collection's access functions called directly, and a payload.find with overrideAccess: 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
  1. MIGRATIONS_ACCESS=closed pnpm payload run src/scripts/check-migrations-access.ts applies the proposed fix after sanitize (the only place a project can reach the collection): /api/access omits the collection, every function returns false, and the find is a 403. MIGRATIONS_ACCESS=closed pnpm payload migrate and migrate:status still write and read the table (batch 1, Ran: Yes), since the CLI uses the Local API with overrideAccess: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPayload OSSarea: core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions