Repository navigation
fix(auth): close the account endpoints the app never uses - #89
Open
lorenzocorallo wants to merge 1 commit into
Open
lorenzocorallo wants to merge 1 commit into
lorenzocorallo wants to merge 1 commit into
Conversation
/update-user let anyone signed in set their own name and picture, which applications, administrators and the e-signing picker all trust. Close it and the other core account endpoints no page calls over HTTP.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was open
Better Auth puts its whole account API under
/api/auth. We only closed a few paths. One that stayed open isPOST /api/auth/update-user. In production it answers 401 without a session, so it is live.What someone could do with it
Anyone signed in could set their own
nameandimageto anything. That name is what we send to every app in thenameclaim. Admins see it in the user list. The e-signing picker shows it. Admins' browsers load the image URL, and apps get it aspicture. So a member could rename themselves as someone else. Nothing in the app offers renaming.What is closed now
All in
unusedAccountPaths(src/auth/account-endpoints.ts), added todisabledPaths. Closed paths answer 404./update-user: the bug above./update-session: nothing here edits a session. It does nothing today, but no page uses it./get-access-token,/refresh-token,/account-info: they give the browser the Google, Entra or Telegram tokens and profile behind a linked account. No page needs that./delete-user,/delete-user/callback: Better Auth's own deletion is off. People are deleted from the user pages, which check permissions./change-email,/change-password,/sign-up/email,/sign-in/email,/request-password-reset,/reset-password,/send-verification-email,/verify-email,/verify-password: email and password sign-in and email changes are off here, so these already fail. Closing them makes sure they stay shut if a setting ever changes.I checked that
disabledPathsonly blocks HTTP requests. It is checked in the router'sonRequest(better-auth/dist/api/index.mjs).auth.api.*calls skip the router. SogetSession,listUserAccounts,revokeSession,revokeOtherSessions,listPasskeys,getJwks, the dev sign-in and the tests'auth.api.signUpEmailkeep working. The tests that sign in by email build their own Better Auth instance, so they are not affected.What is left open
/reset-password/:token: it has a variable in the path, anddisabledPathsonly matches exact paths. It only checks a reset token and redirects. No reset tokens can exist here, because password reset is off./set-password: it is server-only in Better Auth. It has no HTTP route, so there is nothing to close./get-session,/sign-in/social,/callback/:id,/link-social,/list-accounts,/sign-out, the session revoke and list paths,/error,/ok, passkey, generic OAuth and OAuth provider routes.How it was tested
src/auth/account-endpoints.test.ts(no database). With the same closed list, every path answers 404 for a signed-in person over HTTP, and aPOST /update-userdoes not change the name./get-sessionstill works. A control instance without the list does allow the rename, so the test would catch it coming back.src/auth/identity.integration.test.ts. I ran it against a production build (vp run build,scripts/start.mjs) on a throwaway Postgres. All closed paths answer 404 with a real session, and the user's name and image in the database do not change. The identity suite gave 27 passed, 6 skipped. The skipped ones need the OAuth resource settings and are unrelated.vp checkpasses.vp testgives 361 passed, 126 skipped (the database suites skip without their env).Note: the commit is not signed. The 1Password signer refused in this session.