Skip to content

fix(security): answer malformed sign-in bodies with 400, trim provider error logs, 409 on reused desktop requests - #10471

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/probe-hardening
Nov 28, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/probe-hardening

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Sign-in/sign-up: the auth before-hook called .toLowerCase() on body.email before 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.
  • Credential validators: they logged up to 500 characters of an upstream error body from a host the user typed. That's now at most 200 characters with control characters collapsed, through one helper shared by readProviderErrorSnippet and the JSON path in validators/http.ts.
  • Desktop source-connect: preparing a request with an id that's already in use now returns 409 (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

  • Bug fix

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 sends email: { $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.
  • biome on all changed files

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…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
@vercel

vercel Bot commented Nov 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 28, 2026 11:17am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · This PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

This PR tightens three existing error paths:

  • Sign-in and sign-up reject malformed email values with 400.
  • Credential provider errors now produce shorter, cleaner log snippets.
  • Reused desktop request IDs now return a conflict without replacing the first payload.

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

@waleedlatif1
waleedlatif1 merged commit c283160 into staging Nov 28, 2026
90 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/probe-hardening branch November 28, 2026 11:24

This branch was previously deployed

1 inactive deployment
Preview — 8ddbfea6 Deployed Nov 28, 2026 by vercel[bot]
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