The vulnerability is an Insecure Direct Object Reference (IDOR) in the payload-preferences internal collection. The root cause is insufficient access control in the preferenceAccess function located in packages/payload/src/preferences/config.ts. This function is responsible for determining if a user has permission to access a preference document.
Prior to the patch, the preferenceAccess function only checked if the user.value field (the user's ID) in the preference document matched the ID of the currently authenticated user (req.user.id). In environments with multiple authentication collections (e.g., 'admins' and 'customers') and using a database like Postgres or SQLite with sequential numeric IDs, it's possible for an admin and a customer to have the same numeric ID. This allowed a malicious user from one collection to read or delete the preferences of a user in another collection by crafting a request for a preference associated with their own ID, which would also match the victim's ID.
The patch, identified in commit 2dc2e7c07f24529a28326bd7f5a3fc3597245ebf, rectifies this by adding an additional check to the access control logic. The updated preferenceAccess function now ensures that both the user.value (user ID) and the user.relationTo (the user's collection slug) match the authenticated user's ID and collection. This correctly isolates preferences to each user within their respective authentication collection, mitigating the IDOR vulnerability.