Skip to content

[Bugs] Editor proxy: harden middleware matcher - #1156

Merged
Aymericr merged 1 commit into
mainfrom
cursor/editor-proxy-matcher-hardening-5540
Oct 27, 2026
Merged

Aymericr merged 1 commit into
mainfrom
cursor/editor-proxy-matcher-hardening-5540

Conversation

@Aymericr

@Aymericr Aymericr commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Hardens the matcher for the self-host proxy in apps/editor/proxy.ts.

  • The old matcher excluded _next/ plus any path ending in a file extension. The new one runs on every path except Next's own assets (_next/), app/favicon.ico and the files served from public/. Those files are listed by location: the asset folders (audios, demos, fonts, hdri, icons, items, material) and the top-level .svg files. A code comment notes that the list has to track public/.
  • So every /api/* and /project/* path, including locale-prefixed ones, now goes through gateRequest. The excluded set is limited to known static asset locations.
  • Tests in apps/editor/proxy.test.ts check config.matcher with Next's unstable_doesMiddlewareMatch (from next/experimental/testing/server):
    • Gated: /project/a.json, /api/x.json, /fr/admin and /en/api/x, among others. The test also checks that gateRequest answers each of these on a password-protected host.
    • Not gated: real static assets, namely _next/static, _next/image, favicon.ico, a top-level SVG and one real file from each public/ folder.

How to test

  1. cd apps/editor && bun test proxy.test.ts: all 9 tests pass. With main's proxy.ts, the new "runs on every page and API path" test fails at /project/a.json.
  2. Manual check, which I ran: start PASCAL_ADMIN_PASSWORD=pw bunx next dev -p 3111 in apps/editor and request pages with a non-loopback Host header and no session.
    • /project/<id> and /project/a.json both redirect to /login.
    • /api/plugins/mint/x.json answers 401.
    • /pascal-logo-shape.svg, /items/round-carpet/model.glb, /favicon.ico and /login answer 200.
  3. Ran locally: Biome on the changed files, and turbo run check-types --filter=editor....

Screenshots / screen recording

N/A — non-visual change

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch
Open in Web Open in Cursor 

Note

Medium Risk
Changes which requests hit auth middleware; misaligned public/ exclusions could block static assets or leave routes ungated, but behavior is covered by new matcher tests.

Reviewed by Cursor Bugbot for commit e5e060b. Bugbot is set up for automated code reviews on this repo. Configure here.

The matcher skipped any path ending in a file extension. It now runs on
every path except Next's own assets, app/favicon.ico and the files served
from public/, listed by folder. Tests check the matcher with Next's
unstable_doesMiddlewareMatch for API, project and locale-prefixed paths
and for real static assets.
@Aymericr Aymericr added the bot:bugs label Oct 27, 2026 — with Cursor
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T00:18:20.724046Z e5e060b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Aymericr Aymericr left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maintainer triage: the matcher hardening looks right to me. Static files are now excluded by location instead of by extension, and the new matcher tests cover both the gated and the excluded sides.

One thing to watch: the folder list now has to match public/ by hand, so adding a new public folder without updating it will gate those assets behind login on password-protected hosts. That fails closed, which is the safe direction.

Since this changes what the self-host auth gate covers, it needs Security's approval before merge, per the fleet rule. I'm leaving this as a comment rather than an approval; it can merge once CI is green and Security approves.

@Aymericr
Aymericr merged commit 5ec20e7 into main Oct 27, 2026
5 checks passed
@Aymericr
Aymericr deleted the cursor/editor-proxy-matcher-hardening-5540 branch October 27, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants