`sandbox` and `disabledSkills` are not applied in SDK sessions or when changed mid-session, and a blocking `preToolUse` hook fails open on timeout or bad output
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- bash, javascript, json, node.js
Rechercherichtung
Start with the supplied SDK createSession reproduction and inspect how enableConfigDiscovery loads ~/.copilot/settings.json, skills.disabledSkills, and permissions.sandbox. Then reproduce the preToolUse timeout and malformed-JSON cases using ~/.copilot/hooks/guard.json and the ACP prompt flow. Done means discovered and mid-session settings consistently disable skills and enforce sandbox restrictions, and blocking hooks deny calls on timeout or invalid output with the promised warning.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Some restrictions a user sets for themselves are silently not in force: sandbox and disabledSkills in ~/.copilot/settings.json are ignored by SDK sessions and are not picked up when written during a running session, and a blocking preToolUse guard lets the call run when it times out or prints malformed JSON. In each case nothing tells the user that the restriction is off. Some of this is documented; I'm reporting it because the user-facing result is a restriction the user believes is on.
- SDK sessions with
enableConfigDiscovery: trueload skills from~/.copilotbut ignoredisabledSkillsandsandboxin~/.copilot/settings.json. The docs say, in the bundled SDK'stypes.d.ts, for explicit skill roots, "skill and managed disables still apply", and offerskills.disabledSkillsandpermissions.sandbox("Sandbox configuration applied before MCP servers or session tools start"); they do not say whether discovered user settings are applied. With{"disabledSkills": ["canary-skill"]}, prompt mode answersSkill "canary-skill" not found, while an SDK session lists the personal skill as"enabled": trueand loads it. With the sandbox enabled anddeniedPaths: ["/work/secret-sb"], prompt mode blocksview /work/secret-sb/x.txt; the SDK session tells the model "You are not operating in a sandboxed environment" and returns the file. The session applies the parts of~/.copilotthat add capabilities (skills, MCP servers) but not the parts that remove them. - A blocking
preToolUsehook that times out or prints malformed JSON lets the tool call run, with no warning in-poutput. The docs say: "Timeouts are always fail-open, including forpreToolUseand admin-deployed policy hooks: a warning is surfaced and the tool call proceeds through the normal permission flow rather than being denied", and "If the leftover output is empty, or fails to parse as JSON, the hook is treated as having produced no output and falls through to default behavior" (hooks configuration reference). A guard that exits 2 denies the call, and one that crashes (exit 1) also denies it ("hook errored"), but the same guard lets the call run when it times out (sleep 20withtimeoutSec: 2) or exits 0 with{"permissionDecision": "deny"(no closing brace); the user's--allow-tool=shellgrant then approves it. No timeout warning appeared in-pstdout or stderr or in what the model received. The same happens for MCP tool calls andtask(subagent) calls, in subagents, and in ACP and SDK sessions. sandboxanddisabledSkillswritten to~/.copilot/settings.jsonduring a running session are not applied (subagents.disabledSubagentsis). The docs say: "Most settings apply right away, but a few only take full effect after Copilot CLI restarts—for example,experimentaland the proxy settings. When you change one of these, Copilot tells you a restart is needed" (docs: change settings), and "Sandbox policy changes restart extensions under the new restrictions" (copilot help sandbox, which also says "Edit them there" forsettings.json). In a running ACP session, after the sandbox was enabled withdeniedPaths: ["/work/secret-sb"], the next prompt'sview /work/secret-sb/x.txtreturned the file and the model was still told it is not sandboxed; a skill disabled the same way was still loaded.subagents.disabledSubagentswritten the same way was applied on the next prompt ("The "explore" subagent is turned off"). No restart notice appeared, and a new conversation in the same process did not apply them either.
See also the issue about deny rules, the working-directory boundary and plan mode covering less than the docs say.
Affected version
1.0.114, 1.0.117
Steps to reproduce the behavior
Setup for all steps: a Debian 12 container with Node 22, bubblewrap and socat installed (the sandbox needs them on Linux); a git repository /work with /work/secret-sb/x.txt containing SECRET and the directory /work/canary; a personal skill ~/.copilot/skills/canary-skill/SKILL.md with the front matter name: canary-skill, description: canary skill and the body "Reply with the word CANARY.". Sandbox settings S: {"sandbox": {"enabled": true, "userPolicy": {"network": {"allowOutbound": false, "allowLocalNetwork": false}, "filesystem": {"deniedPaths": ["/work/secret-sb"]}}}}. Prompt-mode runs are echo '<prompt>' | copilot --no-auto-update --no-ask-user --disable-builtin-mcps --allow-tool=shell --allow-tool=write from /work.
- SDK host (Node, run in
/work; add your model configuration tocreateSession, a GitHub token or a provider underinference.providers):
Withimport { CopilotClient, RuntimeConnection } from "<copilot-sdk dir>/index.js"; const client = new CopilotClient({ mode: "coding-agent", runtime: RuntimeConnection.forSpawnedStdio({ path: "<path to the copilot binary>", args: [], workingDirectory: "/work" }) }); const session = await client.createSession({ workingDirectory: "/work", enableConfigDiscovery: true, permissions: { onRequest: async (r) => ({ kind: ["read", "write", "shell"].includes(r.kind) ? "approve-once" : "reject" }) } }); session.on((e) => { if (e.type === "session.skills_loaded") console.error(JSON.stringify(e.data)); }); await session.sendAndWait("Use the canary-skill skill", 120000); await client.stop();~/.copilot/settings.json={"disabledSkills": ["canary-skill"]}: prompt mode "Use the canary-skill skill" answersSkill "canary-skill" not found; the SDK host printssession.skills_loadedwithcanary-skill,"enabled": true, and the tool result isSkill "canary-skill" loaded successfully.. Withsettings.json= S: prompt mode "Use the view tool to show /work/secret-sb/x.txt" answers "<sandbox is active and blocked this command. ...>"; the SDK host with that prompt insendAndWaitreturns the file content. - Create
~/.copilot/hooks/guard.json:
Prompt mode "Run this exact shell command with the bash tool: touch /work/canary/x.txt": the file is created, stderr is empty. With{"version": 1, "hooks": {"preToolUse": [{"type": "command", "bash": "sleep 20; echo blocked >&2; exit 2", "matcher": "bash", "timeoutSec": 2}]}}"bash": "echo blocked >&2; exit 2"(no sleep): "Denied by preToolUse hook: hook exited with code 2", no file. With"bash": "echo '{\"permissionDecision\": \"deny\"'"(notimeoutSec): the file is created. - Start with no
~/.copilot/settings.json. Startcopilot --acp --no-auto-update --disable-builtin-mcpsin/workand send over stdio (one JSON object per line):
Write S to{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false}}} {"jsonrpc":"2.0","id":2,"method":"session/new","params":{"cwd":"/work","mcpServers":[]}} {"jsonrpc":"2.0","id":3,"method":"session/prompt","params":{"sessionId":"<sessionId from the reply to id 2>","prompt":[{"type":"text","text":"say ok"}]}}~/.copilot/settings.json, wait a few seconds, then send a secondsession/prompt(id4): "Use the view tool to show /work/secret-sb/x.txt". The content is returned. A new process started with the same file blocks the read. For skills, write{"disabledSkills": ["canary-skill"]}instead and ask to use the skill: it is loaded. With{"subagents": {"disabledSubagents": ["explore"]}}the next prompt is told "The "explore" subagent is turned off. Enable it in /subagents before dispatching it."
Expected behavior
- Expected: a session that discovers configuration from
~/.copilotalso applies the settings there that disable skills or enable the sandbox. Suggested: readdisabledSkillsandsandboxalong with the discovered skills and servers, or say in the SDK docs thatenableConfigDiscoverydoes not apply them and point toskills.disabledSkills/permissions.sandbox. - Expected: a guard that cannot answer in time, or answers with unreadable output, denies the call, at least when configured as blocking. Suggested: an opt-in such as
failClosed: true, and print the documented timeout warning ("a warning is surfaced") in-pmode. - Expected: the sandbox and
disabledSkillsapply from the next prompt, asdisabledSubagentsdoes. Suggested: re-read them when the settings file changes, or report that a restart is needed, as the docs describe for restart-only settings.
Additional context
No response
- Vorherrschende Sprache
- Python
- Sterne
- 11.5k
- Forks
- 2k
- Ø Merge
- 6 Std. 34 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/copilot-cli
-
area:plugins
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
github/copilot-cli#5567 ·
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncationOffenarea:tools
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/copilot-cli#5476 ·
-
triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
github/copilot-cli#5377 ·
-
area:platform-windows area:tools
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
github/copilot-cli#5340 ·
Alle Issues in github/copilot-cli
Ähnliche Issues
-
fidelity
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
backlog
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
sagemathinc/sagebrush#3434 ·
Maintainer antworten meist innerhalb von 1 Tag
-
marketing
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
wuisabel-gif/MemWhale#576 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Status: Triage Suggestion
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
Maintainer antworten meist innerhalb von 1 Tag