Skip to content

fix(desktop): let dev canvas artifacts load past local network access checks - #83057

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog/fix-canvas-artifact-lna-dev
Aug 14, 2026
Merged

fix(desktop): let dev canvas artifacts load past local network access checks#83057
trunk-io[bot] merged 1 commit into
masterfrom
posthog/fix-canvas-artifact-lna-dev

Conversation

@k11kirky

Copy link
Copy Markdown
Contributor

Problem

A published canvas in the local dev desktop app renders nothing: the artifact iframe fails with "Access to internal resource at 'http://localhost:8010/canvas-artifacts/…' from origin 'null' has been blocked by CORS policy".

  • Chromium's Local Network Access checks treat the localhost artifact origin as local network.
  • The canvas iframe is sandboxed without allow-same-origin, so its opaque origin counts as public and cannot be granted the permission.
  • Found while manually testing canvases against a local stack (raised in the canvas phase 4 testing thread).

Changes

  • The Electron main process disables the LocalNetworkAccessChecks feature, in dev only.
  • Production artifact origins are public, so release builds keep the checks.

How did you test this code?

  • Not run: a local Electron session against a dev stack — this sandbox cannot launch the app. The reporter reproduces the block on every published canvas locally; this is Chromium's documented kill switch for the feature.

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude diagnosed the reported CORS error as a Chromium Local Network Access block on the sandboxed artifact iframe and added the dev-only feature switch. Skills invoked: posthog-desktop, writing-pr-descriptions.


Created with PostHog Desktop

… checks

Chromium blocks the sandboxed canvas iframe's navigation to the localhost artifact origin because the frame's opaque origin counts as public and the permission cannot be granted. Dev-only switch; production artifact origins are public and unaffected.

Generated-By: PostHog Desktop
Task-Id: 1df9582a-9666-4504-9721-0fcd1ada0554
@trunk-io

trunk-io Bot commented Aug 14, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @k11kirky! 👋

It looks like your git author email on this PR isn't your @posthog.com address (k11kirky@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 2dbb760.

@hosthog

hosthog Bot commented Aug 14, 2026

Copy link
Copy Markdown

HostHog preview — posthog-desktop-web

The previews for this PR have been torn down and no longer serve.

@trunk-io

trunk-io Bot commented Aug 14, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@k11kirky k11kirky added the stamphog Request AI approval (no full review) label Aug 14, 2026
@k11kirky
k11kirky marked this pull request as ready for review August 14, 2026 14:18
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team August 14, 2026 14:19
@k11kirky

Copy link
Copy Markdown
Contributor Author

/trunk merge

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Security Review

The process-wide development switch allows third-party MCP app content running in opaque, script-enabled iframes to access localhost or private-network services without Chromium's Local Network Access enforcement.

How this was verified: The MCP app iframe path was traced through its script-enabled opaque-origin sandbox into the same Electron session affected by the new process-wide switch, with no equivalent network lockdown on that session.

Prompt To Fix All With AI
### Issue 1
products/desktop/apps/code/src/main/bootstrap.ts:97
**Process-wide local network bypass**

When a configured third-party MCP app executes script in its sandboxed opaque-origin iframe during an unpackaged desktop session, this process-wide switch also disables Local Network Access enforcement for that content, allowing it to probe or interact with localhost and private-network services that Chromium would otherwise block.

**How this was verified:** The MCP app iframe path was traced through its script-enabled opaque-origin sandbox into the same Electron session affected by this process-wide switch, without the artifact preview's network lockdown.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(desktop): let dev canvas artifacts l..." | Re-trigger Greptile

// as public, so the artifact navigation is blocked with no way to grant the
// permission. Production artifact origins are public and unaffected.
if (isDev) {
app.commandLine.appendSwitch("disable-features", "LocalNetworkAccessChecks");

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.

P1 security Process-wide local network bypass

When a configured third-party MCP app executes script in its sandboxed opaque-origin iframe during an unpackaged desktop session, this process-wide switch also disables Local Network Access enforcement for that content, allowing it to probe or interact with localhost and private-network services that Chromium would otherwise block.

How this was verified: The MCP app iframe path was traced through its script-enabled opaque-origin sandbox into the same Electron session affected by this process-wide switch, without the artifact preview's network lockdown.

Knowledge Base Used: Desktop App and Agent Framework

Prompt To Fix With AI
This is a comment left during a code review.
Path: products/desktop/apps/code/src/main/bootstrap.ts
Line: 97

Comment:
**Process-wide local network bypass**

When a configured third-party MCP app executes script in its sandboxed opaque-origin iframe during an unpackaged desktop session, this process-wide switch also disables Local Network Access enforcement for that content, allowing it to probe or interact with localhost and private-network services that Chromium would otherwise block.

**How this was verified:** The MCP app iframe path was traced through its script-enabled opaque-origin sandbox into the same Electron session affected by this process-wide switch, without the artifact preview's network lockdown.

**Knowledge Base Used:** [Desktop App and Agent Framework](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/posthog/-/docs/desktop-app.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@stamphog

stamphog Bot commented Aug 14, 2026

Copy link
Copy Markdown

Note

🤖 stamphog reviewed 2dbb760b4f7347defbc6b92189fb492efd4a6504 — verdict: ESCALATE

Greptile raised a substantive, traced security concern (dev-only LNA bypass is process-wide, so third-party MCP iframes in the same Electron session also lose Local Network Access enforcement) and it remains unresolved and unaddressed despite one human approval; this is security-sensitive surface and needs that concern resolved before auto-approval.

  • greptile-apps[bot], tatoalo reviewed the current head.
  • Unresolved Greptile security finding: process-wide disabling of LocalNetworkAccessChecks also removes network protection for third-party MCP app iframes, not just the canvas artifact iframe
  • No response from author or scoping of the switch to the artifact session specifically
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 8L, 1F substantive — within ceiling
tier T1-agent / T1a-trivial (8L, 1F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 92acee3 · reviewed head 2dbb760

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Aug 14, 2026
@trunk-io
trunk-io Bot merged commit c0c4e5a into master Aug 14, 2026
333 checks passed
@trunk-io
trunk-io Bot deleted the posthog/fix-canvas-artifact-lna-dev branch August 14, 2026 14:54
@deployment-status-posthog

deployment-status-posthog Bot commented Aug 14, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-14 15:38 UTC Run
prod-us ✅ Deployed 2026-08-14 15:56 UTC Run
prod-eu ✅ Deployed 2026-08-14 15:57 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants