Skip to content

fix(auth): disable public sign-up on the OAuth provider (critical) - #19

Merged
willynikes2 merged 1 commit into
masterfrom
fix/disable-public-signup
Oct 4, 2026
Merged

willynikes2 merged 1 commit into
masterfrom
fix/disable-public-signup

Conversation

@willynikes2

Copy link
Copy Markdown
Owner

Problem

emailAndPassword was 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:

Step Result
POST /api/auth/sign-up/email (stranger) 200, account created
Dynamic client registration 201
Authorize (PKCE) 302 with code
Token exchange 200, access token
GET /api/v1/stats 200
POST /api/v1/ingest 201

Fix

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

  • New tests/auth-oauth.test.js runs 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

`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>
@willynikes2
willynikes2 merged commit 98e7596 into master Oct 4, 2026
9 checks passed
@willynikes2
willynikes2 deleted the fix/disable-public-signup branch October 4, 2026 22:11
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