Skip to content

fix(auth): close the account endpoints the app never uses - #89

Open
lorenzocorallo wants to merge 1 commit into
mainfrom
fix/close-unused-account-endpoints
Open

lorenzocorallo wants to merge 1 commit into
mainfrom
fix/close-unused-account-endpoints

Conversation

@lorenzocorallo

Copy link
Copy Markdown
Member

What was open

Better Auth puts its whole account API under /api/auth. We only closed a few paths. One that stayed open is POST /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 name and image to anything. That name is what we send to every app in the name claim. Admins see it in the user list. The e-signing picker shows it. Admins' browsers load the image URL, and apps get it as picture. 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 to disabledPaths. 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 disabledPaths only blocks HTTP requests. It is checked in the router's onRequest (better-auth/dist/api/index.mjs). auth.api.* calls skip the router. So getSession, listUserAccounts, revokeSession, revokeOtherSessions, listPasskeys, getJwks, the dev sign-in and the tests' auth.api.signUpEmail keep 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, and disabledPaths only 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.
  • Everything the pages or tests use stays open: /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

  • New unit test 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 a POST /update-user does not change the name. /get-session still works. A control instance without the list does allow the rename, so the test would catch it coming back.
  • New case in 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 check passes. vp test gives 361 passed, 126 skipped (the database suites skip without their env).

Note: the commit is not signed. The 1Password signer refused in this session.

/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.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9fe232e and 83304b3.

Files selected for processing: 4

  • src/auth/account-endpoints.test.ts
  • src/auth/account-endpoints.ts
  • src/auth/identity.integration.test.ts
  • src/auth/index.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant