Skip to content

fix(agents): keep ~/.copilot/config.json owner-only when Orca trusts a folder - #25087

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/copilot-config-owner-only
Oct 4, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/copilot-config-owner-only

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​39
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

ELI5

When Orca tells GitHub Copilot "this folder is trusted", it edits Copilot's settings file. That file can also hold your Copilot login tokens. Orca's edit accidentally made the file readable by every user on the machine. Now it stays readable only by you.

What Changed

Problem. Before Orca starts Copilot in a workspace, it adds the workspace to trustedFolders in ~/.copilot/config.json, so Copilot opens straight to its prompt instead of asking "Do you trust this folder?". It does this by writing a new temporary file and renaming it over the old one. The temporary file got the default permissions (usually 0644, readable by everyone). So a file that was owner-only (0600) came out readable by all local users. The file can contain copilotTokens.

The rewrite itself is old, but #23744 made it run on every launch path and, new, on SSH hosts. Shared SSH hosts are exactly where other users can read the file. The daily release scan flagged this as release-blocking (STA-9263).

User-facing change. Starting Copilot from Orca no longer changes who can read ~/.copilot/config.json. After Orca adds a trusted folder, the file is owner-only (0600), locally and on SSH hosts. Nothing else changes: the trust prompt is still skipped, and the other keys in the file are kept. A file that an older Orca already widened stays as it is until Orca next adds a new folder to it; Orca does not touch the file when the folder is already listed.

Mechanism. markCopilotFolderTrusted now passes mode: 0o600 to the atomic write, so the replacement file is owner-only before it is renamed into place.

Why

Writing agent config files owner-only on every rewrite is the common pattern for agent config that can hold credentials. Alternatives considered:

  • Revert feat(agents): pre-trust the folder wherever Orca starts an agent #23744. Rejected. v1.4.218 already had the same mode-dropping write on local launches, so a revert would only shrink how often it happens. It would also remove the folder-trust feature, and several later PRs are built on the same files.
  • Make the shared atomic writer keep each file's existing mode. Rejected for this fix. It changes about 30 unrelated callers, and the common pattern for agent config files is to force owner-only rather than copy whatever mode the file had.

Linked Issue

Linear STA-9263 (release-blocking finding from the v1.4.219 daily scan).

Visual Proof

N/A: no UI change. The change is the permission bits of one file.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Two new tests, both with the umask pinned to 022: a 0600 token-bearing config.json stays 0600 after Orca adds a trusted folder and keeps its tokens, and a fresh config.json is created 0600. Both fail with 0644 without the fix.

Manual SSH check, dev build of this branch, driving the UI over a throwaway Linux SSH host (Docker): seeded /root/.copilot/config.json at 0600 with a fake token, then launched GitHub Copilot from the New tab menu in a remote workspace. With the fix the file stayed 0600 (new inode, folder added to trustedFolders, token kept). With { mode: 0o600 } removed, on a fresh host, the same launch left it 0644. Screenshots are in the PR comment.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

brennanb2025 and others added 3 commits October 3, 2026 14:12
…a folder

Marking a folder trusted for Copilot rewrote ~/.copilot/config.json through a
temp file created with the default umask mode (usually 0644), so an owner-only
file that can hold copilotTokens became readable by other local users. Since
the folder-trust change this write also runs on SSH hosts, where other users
exist. The rewrite now always writes the file owner-only (0600).
@OrcaWin

OrcaWin commented Oct 4, 2026

Copy link
Copy Markdown
Collaborator

Review summary

Problem. Before Orca starts GitHub Copilot in a workspace, it adds that workspace to trustedFolders in ~/.copilot/config.json. That file can hold Copilot login tokens (copilotTokens), which are typically stored in plain text on Linux SSH hosts that have no keyring. Orca rewrote the file through a temporary file created with the default permissions, so an owner-only (0600) file came out readable by every user on the machine (0644 under a 022 umask). #23744 made this rewrite run on every launch path and on SSH hosts, where other users are most likely to be present. The release scan flagged it (STA-9263).

User-facing change. Starting Copilot from Orca no longer widens who can read ~/.copilot/config.json, locally or on SSH hosts. The trust prompt is still skipped and every other key in the file is kept. This matches what Copilot itself does: it writes this file 0600, and also tightens a 0644 one.

What changed. One line: the Copilot trust write passes mode: 0o600, so the replacement file is owner-only before it is renamed into place. Two tests pin the umask to 022 and fail with 0644 without the fix. I also merged main into the branch; that cleared a typecheck error main had already fixed, and CI is green.

Deferred (pre-existing, not caused by this PR):

  • Newer Copilot versions (1.0.35 and later) put // comment lines at the top of config.json. Orca's plain JSON.parse rejects those, so for those users Orca's Copilot folder trust silently does nothing (they see Copilot's trust prompt). This needs its own follow-up PR, which also keeps this fix in place.
  • A file an older Orca already widened stays as it is until Orca adds a new folder to it.
  • Hook installs rewrite ~/.claude/settings.json and similar files without keeping their mode. Antigravity and Qoder settings have the same mode drop.
  • Orca ignores COPILOT_HOME and creates ~/.copilot as 0755 (Copilot uses 0700).

Verified

  • Unit tests: agent-trust-presets, fs-utils, execution-host-workspace-trust, and the relay trust tests (116 passing). Node typecheck is clean.
  • Live over SSH, on a dev build of this branch driven through the UI, against a throwaway Linux SSH host (Docker, umask 022). I seeded /root/.copilot/config.json at 0600 with a fake token, then picked GitHub Copilot from the New tab menu in the remote workspace.
    • With the fix: the file stayed 0600. It got a new inode, the workspace was added to trustedFolders, and the token was kept.
    • With { mode: 0o600 } removed, on a fresh host that got a newly deployed relay: the same launch left the file 0644.
    • No trust or permission errors appeared in the app or relay logs.

New tab menu offering Copilot on the SSH host:
03-new-tab-menu.png
With the fix (config.json stays 0600):
04-copilot-pane-fix.png
Without the fix (config.json becomes 0644):
07-copilot-pane-nofix.png

Not verified

  • The real Copilot binary over SSH. The live check used a stand-in copilot script, because the change is in Orca's write, not in Copilot. Copilot's own 0600 behavior was checked separately with Copilot 1.0.91 in an isolated home.
  • A real shared multi-user SSH host. The container ran as root; the check is about permission bits, not which user owns the file.
  • Windows. There the mode only controls the read-only flag, and 0600 keeps the file writable.
  • A packaged build. Only the dev build was tested.

@OrcaWin
OrcaWin marked this pull request as ready for review October 4, 2026 04:51
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a8ac37d-0c23-443e-8282-970ecac2a372
📥 Commits

Reviewing files that changed from the base of the PR and between 3284b4c and deb217e.

📒 Files selected for processing (2)
  • src/main/agent-trust-presets.test.ts
  • src/main/agent-trust-presets.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The Copilot trust update now writes ~/.copilot/config.json with mode 0600. Tests verify the mode for an existing config and a newly created config under umask 022. The existing-config test also verifies that copilotTokens remains present.

Priority: ⬆️ High

Merge Risk: ⚪ Minimal · up to deb21

The Copilot trust update keeps the config owner-only while preserving existing tokens. No issue identified here prevents merging after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to deb21

The change restricts access to a credential-bearing file without changing folder-trust decisions. No newly introduced security weakness was established. Windows access controls remain unverified, and files widened by older versions are not necessarily repaired.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The control affects the full Copilot configuration for the supplied home, including credentials stored alongside trustedFolders. On filesystems enforcing POSIX modes, 0600 excludes ordinary other-user access; it does not isolate processes sharing the owner's identity or privileged administrators.

Security Findings and Attack Paths

  • inferred — The supplied before/after evidence describes a prior replacement path that could make token-bearing configuration readable to other local users. Applying 0600 at temporary-file creation narrows that exposure during successful POSIX writes, including before rename. Prior exposure is not an introduced PR finding, and no retained Security findings were supplied.

Trust Boundaries and Controls

  • observed — The visible change tightens filesystem access to stored configuration rather than changing which workspace is trusted. The updater still derives the workspace identity and writes it to trustedFolders; the changed call adds only the owner-only mode request.

Resilience and Maintainability Implications

  • inferred — Interruption after temporary-file creation can leave a credential-bearing temporary file. The requested POSIX mode protects newly created temporary files as well as the published configuration. The existing absence of interruption recovery and concurrent-update serialization was not shown to be worsened by this change.

Hardening Proposals

  • proposed — Consider a separately designed permission-repair path for previously widened files, independent of whether the workspace is already trusted. Such repair should preserve configuration contents and ownership and use platform-appropriate access controls.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: keeping Copilot’s config file owner-only when Orca trusts a folder.
Description check ✅ Passed The description covers the required sections and explains the problem, change, rationale, testing, and lack of UI impact. It identifies the linked issue by name but does not provide a direct issue lin…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

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.

✅ No new issues found.

Reviewed changes

  • Owner-only Copilot config rewrite — markCopilotFolderTrusted now passes { mode: 0o600 } to writeFileAtomically, so the replacement ~/.copilot/config.json is owner-only before it is renamed into place (src/main/agent-trust-presets.ts:101). The shared writer already supported options.mode and is deliberately left unchanged for its other callers.
  • Tests — two new umask-pinned (0o022) cases cover a token-bearing config.json staying 0600 with its tokens preserved, and a missing config.json being created 0600; both skip on win32 and both fail at 0644 without the fix (src/main/agent-trust-presets.test.ts:126-162).

The single local/SSH write path (applyWorkspaceTrustOnThisHost → markCopilotFolderTrusted, src/main/execution-host-workspace-trust.ts:110) means the fix covers the shared-SSH-host case the finding called out. The documented non-goal — already-widened files stay as they are until Orca next adds a folder — is a reasonable scope choice for a code-pattern release finding, since the rewrite only happens when a new folder is added.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025
brennanb2025 merged commit 2576783 into main Oct 4, 2026
57 checks passed
LaPaGaYo pushed a commit to LaPaGaYo/Axiom that referenced this pull request Oct 20, 2026
…a folder (stablyai#25087)

* fix(agents): keep ~/.copilot/config.json owner-only when Orca trusts a folder

Marking a folder trusted for Copilot rewrote ~/.copilot/config.json through a
temp file created with the default umask mode (usually 0644), so an owner-only
file that can hold copilotTokens became readable by other local users. Since
the folder-trust change this write also runs on SSH hosts, where other users
exist. The rewrite now always writes the file owner-only (0600).

* test(agents): cover a fresh owner-only Copilot config.json under a permissive umask

---------

Co-authored-by: m4air <[email protected]>
(cherry picked from commit 2576783)
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.

2 participants