`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
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 68/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- bash, javascript, json, node.js
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Python
- Étoiles
- 11.5k
- Forks
- 2k
- Merge moyen
- 6 h 34 min
- PR mergées (30 j)
- 3
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/copilot-cli
-
area:plugins
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
github/copilot-cli#5567 ·
-
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncationOuvertearea:tools
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/copilot-cli#5476 ·
-
triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
github/copilot-cli#5377 ·
-
area:platform-windows area:tools
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
github/copilot-cli#5340 ·
Toutes les issues de github/copilot-cli
Issues similaires
-
fidelity
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
backlog
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
sagemathinc/sagebrush#3434 ·
Les mainteneurs répondent en général sous 1 jour
-
marketing
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
documentation good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
wuisabel-gif/MemWhale#576 ·
Les mainteneurs répondent en général sous 1 jour
-
Status: Triage Suggestion
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
Les mainteneurs répondent en général sous 1 jour