Skip to content

fix(nextjs): redact debug data for machine auth objects in route handlers - #10872

Open
wobsoriano wants to merge 4 commits into
mainfrom
rob/nextjs-redact-machine-auth-debug
Open

wobsoriano wants to merge 4 commits into
mainfrom
rob/nextjs-redact-machine-auth-debug

Conversation

@wobsoriano

@wobsoriano wobsoriano commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Description

In route handlers, auth().debug() returned unredacted data when the request was authenticated with an M2M token, OAuth token or API key. The machine auth object is rebuilt from the data clerkMiddleware() forwards, and its debug returned the auth options as-is instead of going through the redaction every other auth object uses.

@clerk/backend/internal now exports that redaction as createDebug, and the route handler path uses it, so debug data is redacted the same way as for session tokens.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

🤖 Generated with Claude under Rob's supervision.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 18, 2026 1:47am UTC
mosaic-docs Error Error Nov 18, 2026 1:47am UTC
swingset Ready Ready Preview Nov 18, 2026 1:47am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43f80ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@clerk/nextjs Patch
@clerk/backend Patch
@clerk/swingset Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fcd7f86 and 43f80ea.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The backend now exports createDebug through its internal entry point. Next.js uses createDebug(options) to construct debug data for machine-token auth objects. A test checks that API-key debug data exposes sk_test as the secretKey. The changeset documents the stated redaction behavior for M2M-token, OAuth-token, and API-key requests.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · previous review fcd7f

This fix applies the same debug redaction to machine-authenticated route handler requests that session-token requests already get. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: redacting debug data for machine auth objects (M2M, OAuth, API key) in Next.js route handlers. The raw summary and objectives confirm that the change exports createDeb…
Description check Passed The description states the bug: auth().debug() in route handlers returned unredacted data for M2M, OAuth, and API key requests. It explains the fix: @clerk/backend/internal exports createDebug, and th…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: redacting debug data for machine auth objects (M2M, OAuth, API key) in Next.js route handlers. The raw summary and objectives confirm that the change exports createDebug and uses it in getAuthDataFromRequest. The title is specific and accurate.

Full details: Description check

Explanation

The description states the bug: auth().debug() in route handlers returned unredacted data for M2M, OAuth, and API key requests. It explains the fix: @clerk/backend/internal exports createDebug, and the route handler path uses it. This matches the changeset summary and file changes.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Some configured repositories could not be included in this review. Cross-repository analysis may be incomplete. Please check linked-repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between faaec4e and fcd7f86.

Files selected for processing: 2

  • .changeset/tidy-machine-debug-redact.md
  • packages/nextjs/src/server/__tests__/getAuthDataFromRequest.test.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.

@blacksmith-sh

blacksmith-sh Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Matches Machine auth debug() redacts secret key

Before, M2M, OAuth and API key requests returned the full secret key while a session-token request was redacted. After, all four return the same redacted debug data.

Merge-base

Machine vs session

This PR fcd7f864

Machine vs session

Proof on fcd7f864 (from faaec4e7) · mocked: Clerk Backend API (the script supplies the encrypted machine auth object clerkMiddleware forwards a...) · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10872

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10872

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10872

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10872

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10872

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10872

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10872

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10872

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10872

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10872

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10872

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10872

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10872

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10872

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10872

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10872

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10872

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10872

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10872

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10872

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10872

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10872

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10872

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10872

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10872

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10872

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10872

commit: 43f80ea

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-11-18T01:47:36.244Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 1

@clerk/backend

Current version: 3.30.0
Recommended bump: MINOR → 3.31.0

Subpath ./internal

🟢 Additions (1)

Added: createDebug
+ createDebug: (data: AuthObjectDebugData | undefined) => () => {
+     [x: string]: any;
+ }

Added function createDebug


Report generated by Break Check

Last ran on 43f80ea.

This branch was successfully deployed

2 active deployments
Preview – swingset — 43f80eab Deployed Nov 18, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 43f80eab Deployed Nov 18, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant