Repository navigation
fix(auth): disable public sign-up on the OAuth provider (critical) - #19
Merged
Merged
Conversation
`emailAndPassword` was enabled with sign-up open, and brainAuth accepts any valid OAuth session. So anyone who could reach the server could POST /api/auth/sign-up/email, register an MCP client, authorize, get an access token, and read and write the whole knowledge base through /api/v1 and /mcp. Set `disableSignUp: true`. Accounts are provisioned by the operator, and existing accounts sign in exactly as before. Adds an in-process test of the real OAuth provider: outsider sign-up is refused and no user is created, a wrong password fails, and a provisioned account still completes registration -> PKCE authorize -> token, with the token accepted by getMcpSession. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
emailAndPasswordwas enabled with sign-up left open, and the API/MCP auth middleware accepts any valid OAuth session. Anyone who could reach the server could get full read/write access to the knowledge base.I reproduced the full chain against a local instance with the same config:
POST /api/auth/sign-up/email(stranger)GET /api/v1/statsPOST /api/v1/ingestFix
disableSignUp: true. Accounts are provisioned by the operator. Existing accounts sign in exactly as before.After the fix: sign-up returns 400, and authorize sends unauthenticated users to the sign-in page with no code. Dynamic client registration stays open, as MCP clients need it, but a client is useless without an account.
Testing
tests/auth-oauth.test.jsruns the real better-auth provider in-process against an isolated HOME: outsider sign-up is refused and no user is created; a wrong password fails; a provisioned account completes register → PKCE authorize → token, and the token is accepted. The sign-up test fails before the fix (got 200) and passes after.npm test: 131/131🤖 Generated with Claude Code