Skip to content

The agent that grows with you

fix(desktop): restore Skills Hub links, clipboard, and frame pinning

Brooklyn Nicholson2a400b4ade51
diff --git a/apps/desktop/electron/hub-iframe-policy.ts b/apps/desktop/electron/hub-iframe-policy.ts
new file mode 100644
index 00000000000..1a956c6732c
--- /dev/null
+++ b/apps/desktop/electron/hub-iframe-policy.ts
@@ -0,0 +1,55 @@
+/**
+ * Capability carve-outs for the embedded Skills Hub iframe ONLY.
+ *
+ * The Skills Hub picker (Bot Mode) embeds the public docs site
+ * (`https://hermes-agent.nousresearch.com/docs/skills?embed=picker`, or the
+ * GitHub Pages mirror when Vercel refuses the network). Three default denials
+ * make that embed nearly unusable — window.open is killed by the CVE-2026-70608
+ * handler, clipboard writes by the session permission handlers, and the frame
+ * can drift off the picker URL into the un-embeddable docs site. Every carve-out
+ * below is gated on the EXACT hub origin: a sandboxed artifact iframe (opaque
+ * origin `null`) or any other guest frame never qualifies.
+ */
+
+/** The docs site served from Vercel. */
+export const HERMES_HUB_ORIGIN = 'https://hermes-agent.nousresearch.com'
+/** The equivalent GitHub Pages deployment of the same site. */
+export const HERMES_HUB_FALLBACK_ORIGIN = 'https://nousresearch.github.io'
+
+const HUB_ORIGINS = new Set([HERMES_HUB_ORIGIN, HERMES_HUB_FALLBACK_ORIGIN])
+
+/**
+ * Exact-origin membership — `origin` comes from the frame's own `origin`
+ * property (URL parsing), never from a string we control. `new URL(...).origin`
+ * is `null` for sandboxed frames and unique for `data:` URLs, so those can
+ * never alias the hub.
+ */
+export function isHermesHubOrigin(origin: string | null | undefined): boolean {
+ return typeof origin === 'string' && HUB_ORIGINS.has(origin)
+}
+
+/** The URL schemes a trusted hub frame may delegate to the OS browser. */
+const HUB_EXTERNAL_SCHEMES = new Set(['http:', 'https:', 'mailto:'])
+
+/**
+ * May a trusted-origin window.open request be handed to the audited external
+ * opener? http/https/mailto only — the same allowlist `openExternalUrl` in
+ * external-open.ts enforces; anything else (file:, javascript:, custom
+ * schemes) stays denied with no side effect.
+ */
+export function isHermesHubExternalUrl(url: string): boolean {
+ try {
+ return HUB_EXTERNAL_SCHEMES.has(new URL(url).protocol)
+ } catch {
+ return false
+ }
+}
+
+/**
+ * May the requesting frame use the Chromium clipboard-sanitized-write
+ * permission? Only the exact hub origins, and ONLY the write direction —
+ * clipboard reads from embedded web content stay denied everywhere.
+ */
+export function isHermesHubClipboardWrite(origin: string | null | undefined): boolean {
+ return isHermesHubOrigin(origin)
+}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 595bea81905..b3f73ed73d5 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -613,6 +613,7 @@ import {
import { registerWindowControlIpc, windowControlState } from './window-controls'
import { revealAction, shouldFocusToTakeKeyboard } from './window-focus-policy'
import { createWindowOpenHandler } from './window-open-policy'
+import { HERMES_HUB_FALLBACK_ORIGIN, HERMES_HUB_ORIGIN, isHermesHubClipboardWrite } from './hub-iframe-policy'
import { installWindowRendererLifecycle } from './window-renderer-lifecycle'
import { wireWindowReveal } from './window-reveal'
import {
@@ -7088,7 +7089,15 @@ function installDownloadHandling() {
function installMediaPermissions() {
// Async request handler: the prompt-style path (most platforms).
- session.defaultSession.setPermissionRequestHandler((_webContents, permission, callback, details) => {
+ // clipboard-sanitized-write is granted ONLY to the exact Skills Hub origins
+ // (hub-iframe-policy.ts): the picker's Copy controls write to the clipboard,
+ // and every other frame — artifact previews included — stays denied.
+ session.defaultSession.setPermissionRequestHandler((webContents, permission, callback, details) => {
+ if ((permission as string) === 'clipboard-sanitized-write') {
+ callback(isHermesHubClipboardWrite(focusedFrameOrigin(webContents)))
+ return
+ }
+
callback(isMediaCapturePermission(permission, details))
})
@@ -7099,11 +7108,80 @@ function installMediaPermissions() {
// the shared predicate runs with `undefined` details and allows the capture
// permissions — identical policy to the request handler below, just without
// the metadata refinement (absent metadata is allowed there too).
- session.defaultSession.setPermissionCheckHandler((_webContents, permission) => {
+ session.defaultSession.setPermissionCheckHandler((webContents, permission) => {
+ if ((permission as string) === 'clipboard-sanitized-write') {
+ return isHermesHubClipboardWrite(focusedFrameOrigin(webContents))
+ }
+
return isMediaCapturePermission(permission, undefined)
})
}
+// Origin of the frame a permission request came from. The request handler is
+// given the webContents of the TOP document (Chromium routes subframe
+// permission requests through it in Electron 40 without exposing the frame
+// directly), so when the top document is NOT on a hub origin we fall back to
+// the request's own `requestingUrl` — the URL the frame actually asked for —
+// whose origin is exact for both hub deployments and `null` for anything
+// sandboxed or opaque.
+function focusedFrameOrigin(webContents: { getURL?: () => string } | null | undefined, details?: { requestingUrl?: string }): string | null {
+ try {
+ if (details?.requestingUrl) {
+ return new URL(details.requestingUrl).origin
+ }
+
+ if (webContents?.getURL) {
+ return new URL(webContents.getURL()).origin
+ }
+ } catch {
+ // Unparseable URL — report no origin; callers deny.
+ }
+
+ return null
+}
+
+/** The picker embed URL the hub iframe starts on (both deployments). */
+function isHermesHubPickerUrl(url: string): boolean {
+ try {
+ const parsed = new URL(url)
+ const isHubOrigin = parsed.origin === HERMES_HUB_ORIGIN || parsed.origin === HERMES_HUB_FALLBACK_ORIGIN
+ const isPickerPath = parsed.pathname === '/hermes-agent/docs/skills' || parsed.pathname === '/docs/skills'
+
+ return isHubOrigin && isPickerPath
+ } catch {
+ return false
+ }
+}
+
+/** Look up a subframe by its process/routing id; never throws. */
+function findFrameByIdentifier(webContents: { frames?: readonly unknown[]; framesInSubtree?: readonly unknown[] } | null | undefined, frameProcessId: number, frameRoutingId: number): { origin?: string; reload?: () => void } | null {
+ const candidates = [...(webContents?.frames ?? []), ...(webContents?.framesInSubtree ?? [])] as Array<{
+ processId?: number
+ routingId?: number
+ frameProcessId?: number
+ frameRoutingId?: number
+ origin?: string
+ reload?: () => void
+ }>
+
+ return (
+ candidates.find(
+ f =>
+ (f.frameProcessId ?? f.processId) === frameProcessId &&
+ (f.frameRoutingId ?? f.routingId) === frameRoutingId
+ ) ?? null
+ )
+}
+
+/** `frame.origin` as a safe string; destroyed frames report opaque/'null'. */
+function safeFrameOrigin(frame: { origin?: string } | null | undefined): string | null {
+ if (!frame?.origin || frame.origin === 'null') {
+ return null
+ }
+
+ return frame.origin
+}
+
// ---------------------------------------------------------------------------
// OAuth remote-gateway auth.
//
@@ -13403,9 +13481,49 @@ function wireCommonWindowHandlers(win, { zoom = true }: { zoom?: boolean } = {})
installContextMenuBridge(win)
// Always deny, never open as a side effect: GHSA-9f4c-93c8-jc8g. Trusted
// links arrive via `hermes:openExternal`, not here. See window-open-policy.ts.
+ // The trusted-hub delegation (window-open-policy.ts, #91612) also never
+ // creates a window: it hands http/https/mailto opens from the EXACT hub
+ // origin to the audited `openExternalUrl` as a deny side effect.
win.webContents.setWindowOpenHandler(
- createWindowOpenHandler(origin => rememberLog(`[window-open] denied: ${origin}`))
+ createWindowOpenHandler(
+ origin => rememberLog(`[window-open] denied: ${origin}`),
+ {
+ getOpenerOrigin: () => win.webContents.getFocusedFrame?.()?.origin ?? null,
+ openExternalUrl: (url: string) => void openExternalUrl(url)
+ }
+ )
)
+ // The embedded Skills Hub picker must stay pinned to its picker URL
+ // (#91612): the frame is free to navigate itself within the picker (search,
+ // pagination), but the moment it tries to escape to the full docs site —
+ // whose layout is not embeddable and whose links are then dead — the
+ // navigation is denied and the frame is reloaded onto the picker URL.
+ win.webContents.on('will-frame-navigate', (event, url, isMainFrame, frameProcessId, frameRoutingId) => {
+ if (isMainFrame) {
+ return
+ }
+
+ const frame = findFrameByIdentifier(win.webContents, frameProcessId, frameRoutingId)
+ const frameOrigin = safeFrameOrigin(frame)
+
+ if (frameOrigin !== HERMES_HUB_ORIGIN && frameOrigin !== HERMES_HUB_FALLBACK_ORIGIN) {
+ return
+ }
+
+ if (isHermesHubPickerUrl(url)) {
+ return
+ }
+
+ event.preventDefault()
+
+ // Reload the frame back onto the picker instead of leaving it on a
+ // half-navigated document.
+ try {
+ frame?.reload()
+ } catch {
+ // A destroyed frame is gone; nothing to restore.
+ }
+ })
win.webContents.on('will-navigate', (event, url) => {
if ((DEV_SERVER && url.startsWith(DEV_SERVER)) || (!DEV_SERVER && url.startsWith('file:'))) {
return
diff --git a/apps/desktop/electron/window-open-policy.test.ts b/apps/desktop/electron/window-open-policy.test.ts
new file mode 100644
index 00000000000..bd6ddb156e9
--- /dev/null
+++ b/apps/desktop/electron/window-open-policy.test.ts
@@ -0,0 +1,151 @@
+// @vitest-environment node
+import { describe, expect, it, vi } from 'vitest'
+
+import { HERMES_HUB_FALLBACK_ORIGIN, HERMES_HUB_ORIGIN, isHermesHubClipboardWrite, isHermesHubExternalUrl, isHermesHubOrigin } from './hub-iframe-policy'
+import { createWindowOpenHandler, describeDeniedUrl } from './window-open-policy'
+
+describe('hub-iframe-policy predicates', () => {
+ it('admits exactly the two hub origins and nothing else', () => {
+ expect(isHermesHubOrigin(HERMES_HUB_ORIGIN)).toBe(true)
+ expect(isHermesHubOrigin(HERMES_HUB_FALLBACK_ORIGIN)).toBe(true)
+
+ // Opaque sandboxed frames, data URLs, look-alikes, and absent origins
+ // never qualify.
+ expect(isHermesHubOrigin('null')).toBe(false)
+ expect(isHermesHubOrigin('')).toBe(false)
+ expect(isHermesHubOrigin(null)).toBe(false)
+ expect(isHermesHubOrigin(undefined)).toBe(false)
+ expect(isHermesHubOrigin('https://hermes-agent.nousresearch.com.evil.example')).toBe(false)
+ expect(isHermesHubOrigin('https://evil.example')).toBe(false)
+ expect(isHermesHubOrigin('file://')).toBe(false)
+ })
+
+ it('delegates only http/https/mailto external URLs', () => {
+ expect(isHermesHubExternalUrl('https://github.com/NousResearch/hermes-agent')).toBe(true)
+ expect(isHermesHubExternalUrl('http://example.com/docs')).toBe(true)
+ expect(isHermesHubExternalUrl('mailto:[email protected]')).toBe(true)
+
+ expect(isHermesHubExternalUrl('file:///etc/passwd')).toBe(false)
+ expect(isHermesHubExternalUrl('javascript:alert(1)')).toBe(false)
+ expect(isHermesHubExternalUrl('hermes://internal')).toBe(false)
+ expect(isHermesHubExternalUrl('not a url')).toBe(false)
+ })
+
+ it('grants clipboard-write to hub origins only', () => {
+ expect(isHermesHubClipboardWrite(HERMES_HUB_ORIGIN)).toBe(true)
+ expect(isHermesHubClipboardWrite(HERMES_HUB_FALLBACK_ORIGIN)).toBe(true)
+ expect(isHermesHubClipboardWrite('null')).toBe(false)
+ expect(isHermesHubClipboardWrite('https://artifact-preview.invalid')).toBe(false)
+ expect(isHermesHubClipboardWrite(null)).toBe(false)
+ })
+})
+
+describe('createWindowOpenHandler trusted-hub delegation', () => {
+ const baseDetails = { url: 'https://github.com/NousResearch/hermes-agent' }
+
+ it('still denies artifact frames (opaque origin) with NO external open', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => 'null',
+ openExternalUrl
+ })
+
+ expect(handler(baseDetails)).toEqual({ action: 'deny' })
+ expect(openExternalUrl).not.toHaveBeenCalled()
+ })
+
+ it('delegates a hub-origin http(s) open but still denies the window', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => HERMES_HUB_ORIGIN,
+ openExternalUrl
+ })
+
+ expect(handler(baseDetails)).toEqual({ action: 'deny' })
+ expect(openExternalUrl).toHaveBeenCalledExactlyOnceWith('https://github.com/NousResearch/hermes-agent')
+ })
+
+ it('delegates from the fallback (GitHub Pages) hub origin too', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => HERMES_HUB_FALLBACK_ORIGIN,
+ openExternalUrl
+ })
+
+ expect(handler({ url: 'https://docs.example.com/x' })).toEqual({ action: 'deny' })
+ expect(openExternalUrl).toHaveBeenCalledExactlyOnceWith('https://docs.example.com/x')
+ })
+
+ it('never delegates file:// or unknown schemes from a hub-origin opener', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => HERMES_HUB_ORIGIN,
+ openExternalUrl
+ })
+
+ expect(handler({ url: 'file:///C:/x.html' })).toEqual({ action: 'deny' })
+ expect(handler({ url: 'javascript:alert(1)' })).toEqual({ action: 'deny' })
+ expect(handler({ url: 'not a url' })).toEqual({ action: 'deny' })
+ expect(openExternalUrl).not.toHaveBeenCalled()
+ })
+
+ it('never delegates when the opener origin is not exactly the hub', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => 'https://hermes-agent.nousresearch.com.evil.example',
+ openExternalUrl
+ })
+
+ expect(handler(baseDetails)).toEqual({ action: 'deny' })
+ expect(openExternalUrl).not.toHaveBeenCalled()
+ })
+
+ it('a throwing opener probe or external open stays deny-only', () => {
+ const openExternalUrl = vi.fn(() => {
+ throw new Error('boom')
+ })
+ const throwingProbe = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => {
+ throw new Error('probe failed')
+ },
+ openExternalUrl
+ })
+
+ expect(throwingProbe(baseDetails)).toEqual({ action: 'deny' })
+ expect(openExternalUrl).not.toHaveBeenCalled()
+
+ const throwingOpen = createWindowOpenHandler(undefined, {
+ getOpenerOrigin: () => HERMES_HUB_ORIGIN,
+ openExternalUrl
+ })
+
+ expect(throwingOpen(baseDetails)).toEqual({ action: 'deny' })
+ })
+
+ it('a throwing logging observer cannot change the decision or the delegation', () => {
+ const openExternalUrl = vi.fn()
+ const handler = createWindowOpenHandler(
+ () => {
+ throw new Error('log failed')
+ },
+ { getOpenerOrigin: () => HERMES_HUB_ORIGIN, openExternalUrl }
+ )
+
+ expect(handler(baseDetails)).toEqual({ action: 'deny' })
+ expect(openExternalUrl).toHaveBeenCalledOnce()
+ })
+
+ it('without trusted options the handler is side-effect-free deny (CVE-2026-70608 posture)', () => {
+ const handler = createWindowOpenHandler()
+
+ expect(handler({ url: 'https://anything.example' })).toEqual({ action: 'deny' })
+ })
+})
+
+describe('describeDeniedUrl', () => {
+ it('logs origin only, never the full URL', () => {
+ expect(describeDeniedUrl('https://example.com/path?token=secret')).toBe('https://example.com')
+ expect(describeDeniedUrl('data:text/html,foo')).toBe('data:')
+ expect(describeDeniedUrl('not a url')).toBe('<unparseable>')
+ })
+})
diff --git a/apps/desktop/electron/window-open-policy.ts b/apps/desktop/electron/window-open-policy.ts
index 48821b91881..15be5aeb198 100644
--- a/apps/desktop/electron/window-open-policy.ts
+++ b/apps/desktop/electron/window-open-policy.ts
@@ -14,8 +14,19 @@
* effect, a malicious artifact forces the user's OS browser to an attacker URL.
* There is no fixed Electron 40.x, so the defence lives here regardless of the
* pin: deny every request and never open a URL from this handler.
+ *
+ * The ONE, narrow exception (#91612): the embedded Skills Hub picker — whose
+ * origin is pinned in hub-iframe-policy.ts — shows documentation and install
+ * links that must open in the OS browser. For it, and ONLY it, the handler
+ * delegates an http/https/mailto URL to the same audited `openExternalUrl`.
+ * The delegation is a SIDE EFFECT of the deny decision: no window is ever
+ * created from this path, and a frame whose origin is not EXACTLY the hub
+ * origin (an opaque sandboxed frame reports `null`) triggers no side effect at
+ * all, preserving the CVE-2026-70608 posture for every other guest.
*/
+import { isHermesHubExternalUrl, isHermesHubOrigin } from './hub-iframe-policy'
+
export interface WindowOpenRequestLike {
url: string
}
@@ -24,6 +35,16 @@ export interface WindowOpenDecision {
action: 'deny'
}
+/** How the handler learns the requesting frame's origin (dependency-injected
+ * so the policy unit-tests without Electron). */
+export interface TrustedWindowOpenOptions {
+ /** Origin of the frame that called window.open (Electron 40: the focused
+ * frame at the time of the open request). */
+ getOpenerOrigin: (details: WindowOpenRequestLike) => string | null | undefined
+ /** The audited external opener from main.ts; must never create a window. */
+ openExternalUrl: (url: string) => unknown
+}
+
/**
* `origin` only — a denied URL can carry query credentials, signed-URL tokens
* or attacker-controlled text, none of which belongs in a persisted log.
@@ -41,12 +62,27 @@ export function describeDeniedUrl(url: string): string {
/**
* Build a `setWindowOpenHandler` callback that denies unconditionally.
* `onDenied` is logging-only and receives the sanitized origin; a throwing
- * observer must not be able to change the decision.
+ * observer must not be able to change the decision or the side effect.
+ * With `trusted` set, hub-origin openers additionally get their http/https/
+ * mailto URL delegated to the audited external opener — still DENIED as a
+ * window, never a popup.
*/
export function createWindowOpenHandler(
- onDenied?: (origin: string) => void
+ onDenied?: (origin: string) => void,
+ trusted?: TrustedWindowOpenOptions
): (details: WindowOpenRequestLike) => WindowOpenDecision {
return details => {
+ const openerOrigin = trusted ? safeOpenerOrigin(trusted, details) : null
+
+ if (trusted && isHermesHubOrigin(openerOrigin) && isHermesHubExternalUrl(details.url)) {
+ try {
+ trusted.openExternalUrl(details.url)
+ } catch {
+ // A failed external open is logged by the opener itself; it must not
+ // change the decision here either.
+ }
+ }
+
try {
onDenied?.(describeDeniedUrl(details.url))
} catch {
@@ -56,3 +92,15 @@ export function createWindowOpenHandler(
return { action: 'deny' }
}
}
+
+/** The origin probe must never throw into the handler; unknown means deny. */
+function safeOpenerOrigin(
+ trusted: TrustedWindowOpenOptions,
+ details: WindowOpenRequestLike
+): string | null | undefined {
+ try {
+ return trusted.getOpenerOrigin(details)
+ } catch {
+ return null
+ }
+}
diff --git a/apps/desktop/src/plugins/hermes-bots/skills-hub-picker.test.tsx b/apps/desktop/src/plugins/hermes-bots/skills-hub-picker.test.tsx
index ae5927e43db..b4848fd200a 100644
--- a/apps/desktop/src/plugins/hermes-bots/skills-hub-picker.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/skills-hub-picker.test.tsx
@@ -165,6 +165,20 @@ describe('hub pick messages', () => {
expect(installCalls()).toEqual([['skills.manage', { action: 'install', query: 'nous/web-research' }]])
})
+ it('pins the hub frame to the required sandbox and clipboard posture (#91612)', async () => {
+ const frame = openHubBrowser()
+
+ // Same-origin (the hub's own routing), scripts, and popups — external
+ // links then reach the OS browser via the main-process window-open
+ // delegation, never as a popup window.
+ expect(frame.getAttribute('sandbox')).toBe(
+ 'allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox'
+ )
+ // The Copy controls write to the clipboard; the session permission
+ // handlers grant clipboard-sanitized-write only to the hub origins.
+ expect(frame.getAttribute('allow')).toBe('clipboard-write')
+ })
+
it('installs the picked skill when it comes from our own frame', () => {
const frame = openHubBrowser()
diff --git a/apps/desktop/src/plugins/hermes-bots/skills-hub.tsx b/apps/desktop/src/plugins/hermes-bots/skills-hub.tsx
index 8b9b26b0f27..1e3c82b1df9 100644
--- a/apps/desktop/src/plugins/hermes-bots/skills-hub.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/skills-hub.tsx
@@ -228,7 +228,17 @@ export function HubSkillsSection({ bot, onInstalled }: HubSkillsSectionProps) {
>
<iframe
ref={frameRef}
- sandbox="allow-scripts allow-same-origin"
+ // The hub page needs three capabilities beyond the bare sandbox
+ // posture (#91612): same-origin so its own routing and storage
+ // work, popups so its external links (docs, GitHub, Discord)
+ // reach the OS browser — pinned by the main-process
+ // window-open-policy delegation, never a popup window — and
+ // clipboard-write for the Copy controls, granted only to the
+ // hub origins by the session permission handlers. The
+ // will-frame-navigate guard in main keeps this frame pinned to
+ // the picker URL.
+ allow="clipboard-write"
+ sandbox="allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox"
src={hubPickerUrl}
style={{
width: '133.34%',