Skip to content

fix: require a shared secret on auth internal routes - #1389

Merged
Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/auth-internal-shared-secret
Nov 4, 2026
Merged

Zach Dunn (zachdunn) merged 1 commit into
mainfrom
fix/auth-internal-shared-secret

Conversation

@zachdunn

@zachdunn Zach Dunn (zachdunn) commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

In plain terms

Auth routes that only the API should call were guarded by a header anyone can send, plus the hope that Cloudflare always attaches a client IP. That fails open if an edge request shows up without the IP header. Those routes now require a shared secret that is already installed on both workers.

What it does / what it is not

  • uploads-auth accepts /internal/* only when x-uploads-internal-key matches AUTH_INTERNAL_KEY. A missing or wrong key is still a 404.
  • uploads-api sends that key on every service-binding call to those routes. It also still sends x-uploads-internal: 1, so an API deploy that lands first keeps working against the current auth worker.
  • A client IP on the request no longer decides the check.
  • This does not change public sign-in, session, or billing routes. BILLING_INTERNAL_KEY stays the billing secret.
  • Deploy refuses to ship either worker if AUTH_INTERNAL_KEY is missing. The value is already set on uploads-api and uploads-auth.

How to try it

Nothing to run in the CLI. After this merges, Workers Builds deploys both workers. Org lookups, invites, and the admin paths that call /internal/* should keep working. If auth deploys first, those calls 404 until the API deploy lands.

Technical notes

The compare hashes both sides and then checks the digests, so it runs under plain-Node vitest. The API helper is authInternalHeaders. Public proxies do not forward the key.

Test plan

  • pnpm --filter @uploads/auth exec vitest run src/internal.test.ts src/index.test.ts src/internal-routes.test.ts
  • pnpm --filter @uploads/api exec vitest run on the internal callers, header helper, admin UI, webhook queue, usage alerts, CLI upgrade, and weekly digest tests (248 tests)
  • pnpm --filter @uploads/auth typecheck and pnpm --filter @uploads/api typecheck
  • After deploy, confirm an org or invite action that uses /internal/* still succeeds

The /internal/* gate treated a missing cf-connecting-ip plus
x-uploads-internal: 1 as proof the caller was the API. That fails open
if an edge request arrives without the IP header. Compare
x-uploads-internal-key to AUTH_INTERNAL_KEY instead. The API still
sends the old header so an API-first deploy keeps working.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 2
  • coderabbit:review
  • review
🚫 Excluded labels (none allowed): 1
  • wip

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: afd7a94a-a1d6-485b-acff-1bcdbc24d359

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@changeset-bot

changeset-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 208a73a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@zachdunn
Zach Dunn (zachdunn) merged commit cde459c into main Nov 4, 2026
4 checks passed
@zachdunn
Zach Dunn (zachdunn) deleted the fix/auth-internal-shared-secret branch November 4, 2026 22:05
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