Repository navigation
fix(security): answer malformed sign-in bodies with 400, trim provider error logs, 409 on reused desktop requests - #10471
Merged
Merged
Conversation
…r error logs, 409 on reused desktop requests
- auth before-hook narrows body.email to a string before lowercasing, so a non-string email reaches Better Auth's body validation (400) instead of throwing a TypeError (500); the signup MX check uses the same narrowed value
- credential validators log at most 200 characters of an upstream error body, with control characters collapsed, through one helper shared by readProviderErrorSnippet and the JSON path in validators/http.ts
- preparing a desktop source-connect request with an id already in use throws OrchestrationError('conflict') (409) instead of a plain Error (500); the original request is kept
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] This PR appears safe to merge. SummaryThis PR tightens three existing error paths:
Adds regression tests for malformed sign-in emails, provider log text, and reused desktop requests. No actionable issues were found. Tests were not run during this review. Reviews (2) · Last reviewed commit: "fix(security): answer malformed sign-in ..." · Reviewed by Greptile |
This was referenced Nov 28, 2026
This branch was previously deployed
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.
Summary
.toLowerCase()onbody.emailbefore Better Auth validates the body, so a non-string email threw a TypeError and returned 500. It now narrows to a string first, so a malformed email reaches Better Auth's own validation and gets a 400. The signup MX check uses the same narrowed value.readProviderErrorSnippetand the JSON path invalidators/http.ts.OrchestrationError('conflict')) instead of a plain 500. The original request is kept. The desktop client treats any failure here the same way, so its behavior doesn't change.Type of Change
Testing
errors.test.ts: added a control-character case and updated the length case. Both fail on the old code and pass now. The credential and desktop unit suites pass (636 tests).source-request.integration.ts: added a reused-id case, checked against real Redis. It fails on the old code (plain Error, no code) and passes now (409, original payload still consumable).lifecycle-audit.integration.ts: added a sign-in case that sendsemail: { $ne: null }and expects 400. CI's integration job runs it. Confirmed in Better Auth 1.6.27 that before-hooks run before body validation.Checklist
test-auditauthoring gate)