Skip to content

Add localhost:7445 to Quick Edit allowed parent origins#13046

Merged
penalosa merged 3 commits intomainfrom
penalosa-patch-19
Apr 13, 2026
Merged

Add localhost:7445 to Quick Edit allowed parent origins#13046
penalosa merged 3 commits intomainfrom
penalosa-patch-19

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Mar 24, 2026

This allows the production editor to be embedded in apps running locally.


Open with Devin

@penalosa penalosa requested a review from a team as a code owner March 24, 2026 18:37
@penalosa penalosa added the skip-pr-description-validation Skip validation of the required PR description format label Mar 24, 2026
@penalosa penalosa requested a review from NuroDev March 24, 2026 18:37
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 24, 2026

⚠️ No Changeset found

Latest commit: 08cb4a7

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.

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

@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/quick-edit/src/index.ts: [@cloudflare/wrangler]

ask-bonk[bot]

This comment was marked as resolved.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 24, 2026

I'm Bonk, and I've done a quick review of your PR.

Review posted on PR #13046. Two issues flagged:

  1. Redundancy: The addition makes LOCALHOST_ORIGIN_WILDCARDS and the isLocalDev conditional block dead code, since "http://localhost:*" is now unconditionally included. Suggested cleaning up the dead code via an inline suggestion.

  2. Security (informational): This relaxes the production CSP to allow any localhost origin to embed Quick Edit in an iframe, whereas previously this was gated to local-dev-only. Low severity but worth confirming it's intentional.

github run

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 24, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13046

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13046

miniflare

npm i https://pkg.pr.new/miniflare@13046

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13046

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13046

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13046

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13046

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13046

wrangler

npm i https://pkg.pr.new/wrangler@13046

commit: 08cb4a7

@penalosa
Copy link
Copy Markdown
Contributor Author

/bonk add a commit to this PR changing to only allow localhost:8445

@penalosa penalosa marked this pull request as draft March 30, 2026 12:01
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

The change itself is straightforward, but it introduces dead code and has a security implication worth calling out explicitly (both already noted by the bot reviews).

Dead code: After this change, LOCALHOST_ORIGIN_WILDCARDS (line 24) and the isLocalDev conditional block (lines 44-46) are redundant. "http://localhost:*" is now unconditionally present in ALLOWED_PARENT_ORIGIN_WILDCARDS, so the conditional push just adds a duplicate. If this is intentional, those should be cleaned up in the same PR.

Security posture change: Previously, http://localhost:* was only included in frame-ancestors and the postMessage allow-list when the Quick Edit worker was itself running on localhost (i.e. local dev via wrangler dev). This change makes production Quick Edit accept iframe embedding and postMessage IPC from any http://localhost:<port> origin. That means any local HTTP server on a user's machine (browser extensions, other local apps, etc.) can embed production Quick Edit and receive the MessagePort passed at workbench.ts:150. This is likely low-severity since it requires local access, but it's a deliberate relaxation of the production CSP — confirming this is intentional would be good.

If this is intentional, I'd suggest a follow-up commit that removes the now-dead LOCALHOST_ORIGIN_WILDCARDS constant and the isLocalDev conditional block to keep the code clean.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 30, 2026

I've posted a review on PR #13046. The review covers two points:

  1. Dead code -- The LOCALHOST_ORIGIN_WILDCARDS constant and the isLocalDev conditional block (lines 24, 44-46) are now redundant since "http://localhost:*" is unconditionally included in ALLOWED_PARENT_ORIGIN_WILDCARDS. These should be cleaned up if the change is intentional.

  2. Security posture -- This moves http://localhost:* from a local-dev-only allowance to an unconditional one, meaning production Quick Edit will accept iframe embedding and postMessage IPC from any localhost origin. Low severity since it requires local access, but it's a deliberate relaxation worth confirming as intentional.

github run

@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/quick-edit/src/index.ts: [@cloudflare/wrangler]

@penalosa
Copy link
Copy Markdown
Contributor Author

/bonk add a commit to this PR changing to only allow localhost:8445

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 31, 2026

Done. The commit (539750b) makes the following changes to packages/quick-edit/src/index.ts:

  1. Replaced http://localhost:* with http://localhost:8445 -- moved from ALLOWED_PARENT_ORIGIN_WILDCARDS to ALLOWED_PARENT_ORIGINS since it's no longer a wildcard pattern.
  2. Removed dead code -- deleted the LOCALHOST_ORIGIN_WILDCARDS constant, the isLocalDev variable, and the conditional block that pushed localhost wildcards, since they are no longer needed.

This tightens the allowed localhost origin from any port to only port 8445.

github run

Comment thread packages/quick-edit/src/index.ts Outdated
Comment thread packages/quick-edit/src/index.ts
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 31, 2026

Done. I've made two changes in packages/quick-edit/src/index.ts:

  1. Restored LOCALHOST_ORIGIN_WILDCARDS — brought back the LOCALHOST_ORIGIN_WILDCARDS constant (["http://localhost:*"]), the isLocalDev check (url.hostname === "localhost"), and the conditional block that pushes localhost wildcards only during local development. This restores the original security posture where http://localhost:* is only included in the CSP when Quick Edit is running locally.

  2. Changed port from 8445 to 7445 — per the other review comment on line 10, updated the explicit localhost origin from http://localhost:8445 to http://localhost:7445.

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 31, 2026

This is already addressed — commit 6058f4e changed the port to 7445 and restored the LOCALHOST_ORIGIN_WILDCARDS block. No further changes needed.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 31, 2026

The port is already set to 7445 on line 10 of packages/quick-edit/src/index.ts, and the LOCALHOST_ORIGIN_WILDCARDS / isLocalDev code is properly restored. This was all handled by the previous commit 6058f4e. No additional changes are required.

github run

@penalosa penalosa changed the title Add localhost:* to Quick Edit allowed parent origins Add localhost:7445 to Quick Edit allowed parent origins Mar 31, 2026
@penalosa penalosa marked this pull request as ready for review March 31, 2026 16:56
Copy link
Copy Markdown
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

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

Could you explain the context for this PR what's special about port 7445? 😕

@NuroDev
Copy link
Copy Markdown
Member

NuroDev commented Apr 2, 2026

Could you explain the context for this PR what's special about port 7445? 😕

+1 to this. Would love a bit more detail on why this is needed @penalosa.

penalosa and others added 3 commits April 13, 2026 20:35
Replace http://localhost:* wildcard with http://localhost:8445 and
clean up the now-unused LOCALHOST_ORIGIN_WILDCARDS constant and
isLocalDev conditional block.
@workers-devprod
Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Copy link
Copy Markdown
Contributor

@workers-devprod workers-devprod left a comment

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Apr 13, 2026
@penalosa penalosa merged commit 8c4da77 into main Apr 13, 2026
50 checks passed
@penalosa penalosa deleted the penalosa-patch-19 branch April 13, 2026 22:23
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Apr 13, 2026
petebacondarwin pushed a commit that referenced this pull request Apr 14, 2026
Co-authored-by: ask-bonk[bot] <ask-bonk[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-pr-description-validation Skip validation of the required PR description format

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants