Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: disable the pinned tab's cache so no main document arrives unpinnable (#3317)

[._.]/ Adam Eivyd6a12c5434f2
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ab37d97520..8921b8a950 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -106,7 +106,7 @@
## Stacker News stewardship
- **[issue-3315] The Stacker News vision-model picker now only offers models that can actually see an image.** It listed every installed Ollama model — coder and embedding models included — and picking one was silently accepted, so a model that cannot read an image still produced a confident-looking "vision" verdict that fed the safety policy gating the account's actions. The picker now shows the same vision-capable list the rest of PortOS uses (the server's per-model capability report unioned with the id heuristic, so a brand-new multimodal family still shows up), the text picker is untouched, a model you configured earlier is preserved even if it no longer qualifies, and the form now says whether it is still checking capabilities or has confirmed you have no vision model installed.
-- **[issue-3317] Check browser identity now works on sites whose service worker serves the page.** The SSRF pin behind every browser handoff verifies the address Chrome actually dialled for the main document, and refuses anything it cannot verify — but a service-worker-mediated document carries no peer address even when the worker passed the fetch straight through to the network, so identity checks against any PWA failed 100% of the time with "Chrome connected to an unverifiable address". The pinned tab now bypasses the site's service worker so Chrome fetches the document itself and reports a real address to verify, cookies and the signed-in session being unaffected. The fail-closed rule is unchanged: an unexplained missing address is still a refusal, and only a hop Chrome explicitly reported as served from cache — with no connection to pin — is exempt, and only when another hop in the same navigation verified a real address. Refusals now name the delivery flags that caused them, so the next one is diagnosable from the message.
+- **[issue-3317] Check browser identity now works on sites whose service worker serves the page.** The SSRF pin behind every browser handoff verifies the address Chrome actually dialled for the main document, and refuses anything it cannot verify — but a service-worker-mediated document carries no peer address even when the worker passed the fetch straight through to the network, so identity checks against any PWA failed 100% of the time with "Chrome connected to an unverifiable address". The pinned tab now bypasses the site's service worker and its cache so Chrome fetches the document itself and reports a real address to verify, cookies and the signed-in session being unaffected. The fail-closed rule is unchanged: an unexplained missing address is still a refusal, and only a hop Chrome explicitly reported as served with no connection at all is exempt — and only when another hop of the *same* navigation verified a real address and the hop's own URL host is allowed, so a cached document can never borrow an unrelated navigation's verification. Refusals now name the delivery flags that caused them, so the next one is diagnosable from the message.
- **[issue-3302] Safe Stacker News community stewardship** — Add independent account rules and effective account/territory schedules, editable ownership-aware communities, removable encrypted credentials, constrained GraphQL reads and reviewed publishing, conservative local text/vision analysis with safe image normalization, fixed-origin identity-verified browser handoffs, target-bound Review Hub approvals, and an auditable action ledger in Comms.
## Goals
diff --git a/server/services/browserService.js b/server/services/browserService.js
index ad1713bf5d..e737c715aa 100644
--- a/server/services/browserService.js
+++ b/server/services/browserService.js
@@ -400,6 +400,26 @@ export function pickMainFrameHops(messages, topFrameId = null) {
return { hops, finalUrl, mainRequestIds: [...mainRequestIds], pendingMainRequestIds };
}
+// Session-scoped CDP commands the pinned tab issues after `Network.enable` and
+// BEFORE `Page.navigate`, so that the main document arrives with a peer address
+// the SSRF pin can actually verify. Both remove a delivery path that hands
+// Chrome a response it cannot annotate with a `remoteIPAddress`:
+// - `setBypassServiceWorker`: a SW-mediated document carries no peer address
+// even when the worker passed the fetch straight through to the network,
+// which made every PWA unreadable behind the fail-closed empty-IP gate.
+// - `setCacheDisabled`: a document served from the HTTP/prefetch cache made no
+// connection at all, so nothing about the *current* resolution of its host
+// was verified — a body cached earlier from a since-blocked address would be
+// ingested unpinned. Forcing a real fetch is what the pin is for.
+// Both are scoped to this fresh, disposable tab, so the user's normal browsing
+// is unaffected; cookies are untouched, so a signed-in session still applies.
+// Ids are offset well past the navigate (2) / read (3) request ids.
+const PIN_SETUP_COMMANDS = [
+ { method: 'Network.setBypassServiceWorker', params: { bypass: true } },
+ { method: 'Network.setCacheDisabled', params: { cacheDisabled: true } },
+];
+const PIN_SETUP_ID_BASE = 10;
+
// Close a CDP tab by target id (best-effort). Used to fail closed after an
// SSRF-pin refusal so a tab that connected to a disallowed address is torn down
// rather than left open for the DOM reader.
@@ -512,8 +532,9 @@ export function ssrfPinRefusalReason(messages, verifyRemoteIp, url, topFrameId =
* BLANK tab, subscribe to CDP Network events, THEN drive `Page.navigate`, keep
* the subscription open across the settle window, and check the
* `remoteIPAddress` Chrome actually dialed for each hop. The tab also bypasses
- * the site's service worker so a PWA's main document is fetched by Chrome
- * itself and therefore carries a pinnable peer IP.
+ * the site's service worker and disables its cache (`PIN_SETUP_COMMANDS`), so
+ * the main document is fetched by Chrome itself and therefore carries a
+ * pinnable peer IP instead of arriving from a store we can't verify.
*
* `verifyRemoteIp(ip)` returns false to refuse. On ANY refusal (unverifiable /
* empty IP, a navigation that never yields a document response, or a top-level
@@ -556,7 +577,6 @@ export async function navigateToUrlPinned(url, {
}
const READ_ID = 3;
- const BYPASS_SW_ID = 4;
const { default: WebSocket } = await import('ws');
const messages = [];
const result = await new Promise((resolve) => {
@@ -605,16 +625,7 @@ export async function navigateToUrlPinned(url, {
ws.on('open', () => {
ws.send(JSON.stringify({ id: 1, method: 'Network.enable' }));
- // Bypass the site's service worker for THIS tab. A SW-mediated main
- // document carries no `remoteIPAddress` (Chrome can't annotate a response
- // the SW handed it, even when the SW passed the fetch straight through to
- // the network), which the empty-IP gate below rightly refuses — so every
- // PWA was unreadable. With the SW bypassed Chrome fetches the document
- // itself and reports the peer IP, and the fail-closed check verifies a real
- // address instead of being relaxed. The tab is fresh and disposable, so
- // this has no effect on the user's normal browsing; cookies are unaffected,
- // so a signed-in session still applies.
- ws.send(JSON.stringify({ id: BYPASS_SW_ID, method: 'Network.setBypassServiceWorker', params: { bypass: true } }));
+ PIN_SETUP_COMMANDS.forEach((cmd, i) => ws.send(JSON.stringify({ id: PIN_SETUP_ID_BASE + i, ...cmd })));
ws.send(JSON.stringify({ id: 2, method: 'Page.navigate', params: { url } }));
});
ws.on('message', (data) => {
@@ -627,11 +638,12 @@ export async function navigateToUrlPinned(url, {
if (msg.result?.frameId) topFrameId = msg.result.frameId;
return;
}
- if (msg.id === BYPASS_SW_ID) {
- // Non-fatal: a Chrome that rejects the bypass just keeps its service
- // worker in front of the document, and the empty-IP gate still fails
- // closed — never under-verifies.
- if (msg.error) console.warn(`⚠️ CDP setBypassServiceWorker rejected: ${msg.error.message || 'unknown error'}`);
+ const setupIndex = msg.id - PIN_SETUP_ID_BASE;
+ if (setupIndex >= 0 && setupIndex < PIN_SETUP_COMMANDS.length) {
+ // Non-fatal: a Chrome that rejects one of these just keeps its service
+ // worker / cache in front of the document, and the empty-IP gate still
+ // fails closed on the unpinnable response — never under-verifies.
+ if (msg.error) console.warn(`⚠️ CDP ${PIN_SETUP_COMMANDS[setupIndex].method} rejected: ${msg.error.message || 'unknown error'}`);
return;
}
if (msg.id === READ_ID) {