Repository navigation
fix(agents): keep ~/.copilot/config.json owner-only when Orca trusts a folder - #25087
Conversation
…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).
…config-owner-only
Review summaryProblem. Before Orca starts GitHub Copilot in a workspace, it adds that workspace to User-facing change. Starting Copilot from Orca no longer widens who can read What changed. One line: the Copilot trust write passes Deferred (pre-existing, not caused by this PR):
Verified
New tab menu offering Copilot on the SSH host: Not verified
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Copilot trust update now writes Priority: ⬆️ High Merge Risk: ⚪ Minimal · up to The Copilot trust update keeps the config owner-only while preserving existing tokens. No issue identified here prevents merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to 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 Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Owner-only Copilot config rewrite —
markCopilotFolderTrustednow passes{ mode: 0o600 }towriteFileAtomically, so the replacement~/.copilot/config.jsonis owner-only before it is renamed into place (src/main/agent-trust-presets.ts:101). The shared writer already supportedoptions.modeand is deliberately left unchanged for its other callers. - Tests — two new umask-pinned (
0o022) cases cover a token-bearingconfig.jsonstaying0600with its tokens preserved, and a missingconfig.jsonbeing created0600; both skip onwin32and both fail at0644without 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.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…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)




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
trustedFoldersin~/.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 (usually0644, readable by everyone). So a file that was owner-only (0600) came out readable by all local users. The file can containcopilotTokens.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.
markCopilotFolderTrustednow passesmode: 0o600to 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:
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
Two new tests, both with the umask pinned to
022: a0600token-bearingconfig.jsonstays0600after Orca adds a trusted folder and keeps its tokens, and a freshconfig.jsonis created0600. Both fail with0644without the fix.Manual SSH check, dev build of this branch, driving the UI over a throwaway Linux SSH host (Docker): seeded
/root/.copilot/config.jsonat0600with a fake token, then launched GitHub Copilot from the New tab menu in a remote workspace. With the fix the file stayed0600(new inode, folder added totrustedFolders, token kept). With{ mode: 0o600 }removed, on a fresh host, the same launch left it0644. 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)