Repository navigation
Description
Describe the Bug
A password minimum set with the documented password field override ({ name: 'password', type: 'text', hidden: true, minLength: 8 }) is enforced when creating or updating a user, but not on reset password: through Forgot password, a user can set their password to abc and log in with it.
resetPassword (payload/dist/auth/operations/resetPassword.js) hashes the new password with generatePasswordSaltHash. That runs the password validator against a hardcoded field with no minLength, so the default of 3 applies. It then writes with payload.db.updateOne, so the collection's field validation never runs. The beforeValidate hook approach suggested in #11982 doesn't help either: on reset it runs after hashing, and data holds salt and hash but no password.
We've worked around this by patching the password validator's default minLength in payload/dist/fields/validations.js, since the reset path falls back to it.
Related: #7582 (closed). It fixed the hook running at all, but not this.
Link to the code that reproduces this issue
Reproduction Steps
Copy .env.example to .env and point DATABASE_URL at an empty Postgres database.
The repro's config includes a minimal email adapter that writes each email to the server log, so the reset link can be followed.
pnpm dev, open/admin, and create the first user with passwordlongenough1.- Users > Create New, with any email and password
abc, then Save. It's refused with "minimum length of 8 characters", as expected ✅ - Log out, choose "Forgot password?", enter the first user's email and submit.
- Open the reset link from the email in the server log, on
http://localhost:3000. The link is relative because noserverURLis set. - Enter
abcas the new password, confirm it, and press Reset Password.
Expected: step 5 is refused with "minimum length of 8 characters", as step 2 is.
Actual: "Password reset successfully." The user is signed in, and can log in again with abc.
Which area(s) are affected?
area: core
Environment Info
Binaries:
Node: 22.18.0
npm: 10.9.3
Yarn: N/A
pnpm: 10.14.0
Relevant Packages:
payload: 3.91.0
next: 16.4.0
@payloadcms/db-postgres: 3.91.0
@payloadcms/drizzle: 3.91.0
@payloadcms/graphql: 3.91.0
@payloadcms/next/utilities: 3.91.0
@payloadcms/richtext-lexical: 3.91.0
@payloadcms/translations: 3.91.0
@payloadcms/ui/shared: 3.91.0
react: 19.2.6
react-dom: 19.2.6
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 27.0.0: Tue Aug 11 21:06:24 PDT 2026; root:xnu-13432.1.9~1/RELEASE_ARM64_T6030
Available memory (MB): 36864
Available CPU cores: 11
Activity
akshatshahh commentedon Oct 19, 2026
I can take this. I'll validate the new password against the collection's actual
passwordfield (including itsminLengthoverride) before hashing in the reset-password path, mirroring create/update validation.lazerg commentedon Oct 19, 2026
It is a bug, and your read of the source matches 3.x today. The reset path hashes through
generatePasswordSaltHash, which validates against a barepasswordfield, then writes withpayload.db.updateOne, so yourminLengthnever gets a say.mainhas the same code, so v4 doesn't fix it either.Until it's fixed, you can drop the
distpatch and use abeforeOperationhook instead. It runs before the hashing step and still has the plain password inargs.data.password:Add it to
hooks.beforeOperationon the users collection. Throwing there rolls back before anything is written.fix: run the password field's validation on reset password (3.x) (#18980
fix: run the password field's validation on reset password (#19006)
github-actions commentedon Oct 27, 2026
🚀 This is included in version v4.0.0-beta.5
github-actions commentedon Oct 27, 2026
🚀 This is included in version v3.92.1