Skip to content

feat(desktop): scope TLS cert verification to individual backend connections - #12927

Open
Abhijay007 wants to merge 6 commits into
aaif-goose:mainfrom
Abhijay007:feat/tls-pin-per-connection
Open

Abhijay007 wants to merge 6 commits into
aaif-goose:mainfrom
Abhijay007:feat/tls-pin-per-connection

Conversation

@Abhijay007

Copy link
Copy Markdown
Collaborator

Fixes: #11704

Summary

Each backend connection now gets its own isolated Electron session (persist:goose-${n}) with a cert verifier scoped to that connection's trust object only — fixing the bug where two windows on the same hostname could cross-authorize each other's TLS certificates.

Testing

  • 5 new unit tests in backendCertificateVerifier.test.ts, including the key isolation case: two sessions on the same hostname each reject the other's certificate fingerprint.
  • pnpm run typecheck, pnpm run lint, and pnpm test all pass (938 tests).

@Abhijay007
Abhijay007 requested a review from a team as a code owner October 15, 2026 15:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T18:32:31.190566Z 519ccc1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae4ab13f48

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ui/desktop/src/main.ts Resolved
Comment thread ui/desktop/src/main.ts Resolved
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity for 23 days.

What happens next?

  • If no further activity occurs, this PR will be automatically closed in 7 days
  • To keep this PR active, simply add a comment, push new commits, or add the keep-open label
  • If you believe this PR was marked as stale in error, please comment and we'll review it

Thank you for your contribution! 🚀

@github-actions github-actions Bot added the stale label Nov 9, 2026
@Abhijay007 Abhijay007 removed the stale label Nov 9, 2026

@jbg jbg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The per-session verifier isolates the pins for two concurrent connections to the same hostname. The two existing CSP and storage threads still apply to this head.

One issue criterion is still unsettled: remoteBackends.ts checks that the resolved status and ACP origins match only after sending the authenticated ACP probe. The configured pin constrains redirects by hostname, so a different port still passes that check. Please settle the supported redirect and port behavior from #11704 and validate the allowed origin before sending the secret.

Could you also add a regression check that exercises two actual window sessions through the probe and WebSocket paths and verifies that both receive the renderer CSP? The current mocked verifier test covers the pin decision, and the source-text check can pass with the CSP handler attached only to the old session.

Validate the ACP origin before sending credentials, apply CSP to each renderer session, and migrate legacy desktop preferences. Exercise separate pins and CSP with real Electron windows.
@Abhijay007
Abhijay007 force-pushed the feat/tls-pin-per-connection branch from ae4ab13 to 870ac4a Compare November 18, 2026 13:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 870ac4a17d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Abhijay007
Abhijay007 requested a review from jbg November 18, 2026 13:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfa3c2e56e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread ui/desktop/src/main.ts Resolved
Comment thread ui/desktop/src/main.ts Resolved
Store chat input history separately from preferences and migrate existing history. Reuse the legacy spellchecker dictionary to preserve custom words across isolated backend sessions.

@jbg jbg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address the two findings below.

Comment thread ui/desktop/src/main.ts Outdated
let gooseServeLease: GooseServeLease | null = null;

const partitionKey = ++backendPartitionCounter;
const windowPartition = `persist:goose-${partitionKey}`;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Tie the browser partition’s lifetime to the connection. Every chat window creates a disk-backed persist:goose-N partition. Closing the window leaves its browser state on disk, and the counter starts over on relaunch. A different backend lease can then inherit the previous lease’s partition, including its cache and cookies. Use an in-memory partition or explicitly manage the stored state when a lease ends.

Comment thread ui/desktop/src/main.ts Outdated
}
event.returnValue =
key === CHAT_HISTORY_KEY
? updateChatHistory(pruneStoredMessageHistory)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Keep disk reads off the input-history shortcut. Each Cmd/Ctrl+Up or Down reads, parses, and serializes the entire history file through synchronous IPC. With large saved prompts, holding the shortcut can block Electron’s main process and stall other windows. Serve history navigation from memory or use asynchronous IPC.

@Abhijay007
Abhijay007 requested a review from jbg December 2, 2026 17:52

@jbg jbg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I’d pause revisions here and revisit which part of desktop owns the isolated connection. The latest commit addresses my two previous findings, and the two-backend test is worth keeping.

Moving the whole chat window into an in-memory session has reopened the dictionary regression. Electron doesn’t support adding custom words to an in-memory session, so copying the shared dictionary into each chat can’t preserve that behavior on Linux. I also found that the history migration leaves the original prompts in persist:goose after the new history store expires or clears them.

Let’s return to #11704 — Scope desktop backend TLS pins to individual connections and trace what it would take for the lease to own the authenticated HTTP and WebSocket traffic while the renderer keeps its persistent profile. The deciding question is whether every authenticated request, including those from standalone app windows, can use that transport. I’d settle that before asking for another implementation round.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope desktop backend TLS pins to individual connections

2 participants