Skip to content

Harden desktop navigation boundary for workspace Markdown links #339

@snowopsdev

Description

@snowopsdev

Harden desktop navigation boundary for workspace Markdown links

Summary

The desktop app should prevent untrusted workspace content from replacing the main Electron app document with an untrusted remote page.

The main window already gates window.open through an allowlist, but the app should also guard top-level navigation and redirects from renderer content. This matters for workspace Markdown previews because Markdown links are rendered inside the app chrome.

Why this matters

The BrowserWindow is configured with the app preload bridge. If untrusted workspace content can navigate the top-level app window away from the trusted app document, the preload/IPC boundary becomes much more exposed than intended.

This is a security hardening issue, not a feature request. It should be addressed before broader workspace-file and provider-hardening follow-ups, because navigation control is the first boundary that keeps untrusted document content out of the privileged app shell.

Relevant code

  • Main BrowserWindow preload setup:
    • apps/desktop/src/main/index.ts
  • Existing window.open handling:
    • apps/desktop/src/main/index.ts
  • Markdown rendering in the files tab:
    • apps/desktop/src/renderer/src/components/FilesTabView.tsx
  • Preload API exposure:
    • apps/desktop/src/preload/index.ts

Suggested fix

  • Add a main-window navigation guard for will-navigate and redirect-style top-level navigation.
  • Allow only the trusted app origin/document to remain loaded in the main BrowserWindow.
  • Route external Markdown links through the existing safe external-open path instead of default top-level navigation.
  • Consider a small shared sender-frame/origin helper for high-impact IPC handlers so sensitive channels can reject calls from unexpected documents.

Suggested tests

  • Unit coverage for trusted-vs-untrusted navigation URL classification.
  • Renderer coverage for Markdown link handling.
  • Electron/main-process coverage for blocking remote top-level navigation if the current test harness supports it.

Notes

I can take this as a focused PR scoped to the navigation/preload boundary. Follow-up PRs can separately handle workspace root approval, workspace:// preview resource access, and headless browser network policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions