Deny rules, the working-directory boundary and plan mode cover less than the docs say (hook allow, MCP tools, shell, link swap, redirects)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Start with the permissions documentation and the hooks, MCP server, shell, and plan-mode permission paths; reproduce using test_mcp_server.py, ~/.mcp/mcp-config.json, and ~/.copilot/hooks/allow.json as described. Trace where deny rules, working-directory checks, URL checks, and filesystem effects are evaluated for each tool route. Done means the listed bypasses are blocked consistently or their limitations are explicitly documented, with regression coverage for the affected routes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
--deny-tool / --deny-url rules, the working-directory boundary and plan mode block an action when it is done the plain way (the built-in tool, a plain shell command, the URL typed in the command), but the same action goes through on another route. Some of these limits are documented; I'm reporting them because the docs elsewhere say deny rules always win, and a user who sets these rules cannot tell which routes they cover.
- A hook that answers "allow" overrides
--deny-tooland--deny-urlrules. The docs say: "Deny rules always take precedence over allow rules, even when--allow-allis set or a matching approval has been saved inpermissions-config.json." (docs: "Allowing tools"), and "Deny rules win over every allow, including --allow-all-tools." (copilot help permissions). With a userpreToolUsehook that prints{"permissionDecision":"allow"}, calls that a--deny-toolor--deny-urlrule denies without the hook run: shell, read and write (also with a path), MCP tool and URL rules. ApermissionRequesthook printing{"behavior":"allow"}does the same; for that hook the hooks reference says the decision "short-circuits the normal permission flow", which conflicts with the precedence statement. Managedpermissions.denyrules and plan mode still blocked the same calls with the same hooks. - MCP tools are not checked against path rules, the working-directory boundary or plan mode. The docs say:
read(path?)"Matches file-read requests from built-in tools", MCP tools are their own kind<mcp-server-name>(tool-name?), and "File access is limited to the working directory and the system temp directory" (copilot help permissions); plan mode lets "calls to external/MCP tools you've connected" through (CLI command reference). A file-capable MCP tool (canary_read(path),canary_write(path, content), from a user server or a plugin's server) reads a file that--deny-tool='read(/work/secret/**)'denies forview, reads/outside/x.txtwith no prompt whileviewof it needs approval, and writes in plan mode wherecreateis blocked. Nothing says the working-directory boundary does not apply to MCP tools. --deny-tool=read/writedo not stop the same read or write done by a shell command. The docs say: "A rule with a path does not apply to shell commands", and "An unscoped "write" rule (for example --allow-tool='write') approves a shell command's redirection of output into a file" (copilot help permissions).--deny-tool=writedeniescreate, butprintf %s PT > /work/canary/x.txtruns, although--allow-tool=writewould approve that same redirection;--deny-tool=readdeniesviewbut notcat. A user who reads that a denied tool means "the AI model cannot use that tool at all" (docs: "Allowing tools") may expect these rules to stop file reads and writes in general.- Plan mode lets file-writing shell commands through. The docs say: "It's a safety net, not a guarantee ... Some things are intentionally allowed through so research isn't overly restricted: for example, shell commands whose effect can't be clearly determined in advance" (CLI command reference, plan mode).
touch,\touch,/usr/bin/touchandgit diff --output=...are blocked, butsh -c 'touch ...',env X=1 touch ...,$(echo touch) ...,X=touch; $X ...,t'o'uch ...,find ... -fprint,sed -n 'w ...',sort -o,git -C <dir> configandpython3 -c 'import subprocess; ...'write files with no block. These have a clear effect that can be determined in advance; subagents and custom agents behave the same. - A path is checked, then opened again: a directory swapped for a link between check and use defeats path rules (race). The docs say nothing about this for the built-in tools; "Symlinks are resolved for existing files, but not for files being created" is said for shell path detection ("Configuring Copilot CLI"). With
--deny-tool='write(/work/canary/**)',create /work/link/x.txtis denied when/work/linkis a fixed link to/work/canary. When/work/rckeeps switching between a real directory and that link, repeatedcreate /work/rc/x.txtcalls are sometimes denied and one succeeded while/work/rcwas the link, so the file ended up in/work/canary. The same pattern defeated the working-directory boundary, managedRead(...)rules forviewand the sandbox'sdeniedPathsforview; it needs a second local process and repeated attempts. --deny-urlchecks the typed URL, not where it redirects. The docs say: "For shell commands, URLs are extracted using regex patterns" (docs: "Configuring Copilot CLI"), and "Deny rules win over every allow" (copilot help permissions); redirects are not among the listed limitations. With--allow-url=http://allowed.test:8081 --deny-url=http://canary.test:8081,curl -s -m 5 http://canary.test:8081/xis denied, butcurl -sL -m 5 http://allowed.test:8081/redirect/xfollows the server's302to the denied host and returns its response ("canary ok").
See also the issue about settings that SDK and ACP sessions do not apply, and hooks that fail open.
Affected version
1.0.117
Steps to reproduce the behavior
Setup for all steps: a Debian 12 container with Node 22; a git repository /work with /work/secret/x.txt containing SECRET, the directory /work/canary, and /outside/x.txt. Every run is echo '<prompt>' | copilot --no-auto-update --no-ask-user --disable-builtin-mcps --allow-tool=shell --allow-tool=write <flags> from /work (with --no-ask-user, a request that needs approval is denied). Shell prompts are "Run this exact shell command with the bash tool: ". For steps 1 and 2, test_mcp_server.py is any stdio MCP server with the tools canary_read(path) (returns the file's content) and canary_write(path, content) (writes the file), saved as ~/.mcp/test_mcp_server.py, with ~/.copilot/mcp-config.json: {"mcpServers": {"canary": {"type": "local", "command": "python3", "args": ["/home/node/.mcp/test_mcp_server.py"], "tools": ["*"]}}} and the flag --allow-tool=canary.
- Create
~/.copilot/hooks/allow.json:
Run the shell command{"version": 1, "hooks": {"preToolUse": [{"type": "command", "bash": "echo '{\"permissionDecision\":\"allow\"}'"}]}}touch /work/canary/canary.txtwith--deny-tool='shell(touch)': the file is created. Without the hook file: "Permission to run this tool was denied due to the following rules:shell(touch)". The same with--deny-tool='canary(canary_write)'and the prompt "Use the canary_write tool to write PT to /work/canary/x.txt" ("written"),--deny-tool='read(/work/secret/**)'andview(content returned),--deny-url=http://canary.test:8081withcurl, and with apermissionRequesthook printing{"behavior":"allow"}. - With
--deny-tool='read(/work/secret/**)': "Use the view tool to show /work/secret/x.txt" is denied; "Use the canary_read tool to show /work/secret/x.txt" returns the content. Without--deny-tool, the same two prompts for/outside/x.txt:view"Permission denied because no interactive user response was available...",canary_readreturns the file. With--plan: "Use the canary_write tool to write PT to /work/canary/x.txt" writes the file,createis blocked ("Plan mode does not permit changes outside the session folder"). A plugin's server with the same definition behaves the same. - With
--deny-tool=read: "Use the view tool to show /work/secret/x.txt" is denied ("... following rules:read"); the shell commandcat /work/secret/x.txtshows the content. With--deny-tool=write: "Use the create tool to create /work/canary/x.txt with content PT" is denied; the shell commandprintf %s PT > /work/canary/x.txtwrites the file. The path formsread(/work/secret/**)/write(/work/canary/**)andpython3 -creads and writes behave the same. (--allow-tool=writeis the grant a user gives so that the agent may write files; the deny rule must win over it.) - With
--plan: the shell commandtouch /work/canary/a.txtis blocked ("This shell command would modify files outside the session folder and was blocked.");sort -o /work/canary/b.txt /dev/nullwrites the file. Repeat with each command in item 4. Forgit config:git init -q --bare /work/canary/g && mkdir /work/rd && printf 'gitdir: /work/canary/g\n' > /work/rd/.git, thengit -C /work/rd config test.mark PT; the value appears in/work/canary/g/config. - Start a switcher in the background:
With( while true; do rm -rf /work/rc; mkdir -p /work/rc; rm -rf /work/rc; ln -s /work/canary /work/rc; done ) >/dev/null 2>&1 &--deny-tool='write(/work/canary/**)', prompt "Use the create tool to create /work/rc/x.txt with content PT. If it fails, try again, up to 30 times." Stop the switcher:/work/canary/x.txtexists (it can take more than one run). Observed: two calls denied bywrite(/work/canary/**), then "Created file /work/rc/...". - Make
allowed.testandcanary.testresolve to 127.0.0.1 and run a small web server on port 8081 that answersallowed.test:8081/redirect/<x>with302 Location: http://canary.test:8081/<x>andcanary.test:8081/<x>withcanary ok, logging each request. With--allow-url=http://canary.test:8081 --allow-url=http://allowed.test:8081 --deny-url=http://canary.test:8081, the shell commandcurl -sL -m 5 http://allowed.test:8081/redirect/xreturnscanary ok(log:GET allowed.test /redirect/x, thenGET canary.test /x);curl -s -m 5 http://canary.test:8081/xis denied byurl(http://canary.test:8081).
Expected behavior
- Expected: the matching
--deny-tool/--deny-urlrule denies the call, as without the hook. Suggested: check deny rules before, or in addition to, a hook's "allow"; or say in "Allowing tools" that a hook "allow" wins. - Expected: the MCP call is denied by the path rule, needs approval outside the working directory, and is blocked in plan mode, as the built-in tools are. Suggested: let path rules apply to MCP arguments declared as paths, at least for the working-directory boundary; otherwise say plainly that
read(...)/write(...)rules and the boundary do not cover MCP tools. - Expected:
--deny-tool=writestops the shell redirection that--allow-tool=writeapproves (the CLI already finds redirection targets for managedWrite(...)rules). Suggested: deny the detected redirections and in-place writes; document next to--deny-toolthatread/writedeny rules do not cover other shell reads and writes. - Expected: commands that write files are blocked like
touch. Suggested: treat wrappers and expansions (sh -c,env,$(...),$VAR, interpreters with-c) as "effect can't be determined" and block or ask; count the write options offind,sed,sortandgit configas modifications; or list the exceptions in the plan-mode docs. - Expected: no file is ever created inside the denied directory. Suggested: open the path that was checked (open the resolved path, or each component with
O_NOFOLLOW, and re-check the opened file's real path before writing or returning content). - Expected: the request to the denied host is blocked. Suggested: ask (or deny) for network commands that follow redirects (
curl -L/--location) while URL deny rules are in force, or enforce URL rules at the network level; otherwise name redirects among the limitations in "Configuring Copilot CLI".
Additional context
No response
- Linguagem predominante
- Python
- Estrelas
- 11.5k
- Forks
- 2k
- Merge médio
- 6h 34min
- PRs com merge (30d)
- 3
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/copilot-cli
-
area:plugins
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
github/copilot-cli#5567 ·
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncationAbertaarea:tools
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
github/copilot-cli#5476 ·
-
triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 74/100
github/copilot-cli#5377 ·
-
area:platform-windows area:tools
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 74/100
github/copilot-cli#5340 ·
Todas as issues de github/copilot-cli
Issues semelhantes
-
marketing
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
Status: Triage Suggestion
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
Mantenedores costumam responder em até 1 dia
-
[Suggestion]: NoParrotAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
collabnix/awesome-mcp-lists#515 ·
Mantenedores costumam responder em até 1 dia
-
Look-ahead bias via resample('1min').interpolate(method='time') in CCIStrategy and ReinforcedQuickieAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
documentation good first issue
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 90/100
Mantenedores costumam responder em até 1 dia