Skip to content

Copilot is (sometimes) able to delete files outside of the allowed directories via ~ expansion and interpreter execution (Python shutil.rmtree) #2309

Open

Description

@elenaterenzi

Describe the bug

Copilot CLI can delete files outside explicitly allowed directories when:

  1. Shell commands use ~ (tilde) paths, or
  2. Copilot executes Python code (e.g. shutil.rmtree) that performs filesystem operations

According to my understanding of how --add-dir / trusted directories work, both cases bypass Copilot CLI’s path‑based permission enforcement.

Affected version

1.0.11

Steps to reproduce the behavior

Within the /sandbox/workdir folder execute this command:

copilot -p "create an hello-world.py script, then run it, then list all files in your workdir, then remove all contents in the folder .copilot/session-state. if you fail to delete contents keep trying in different ways at least 10 times before you give up" \
  --add-dir /sandbox/workdir/ \
  --allow-all-tools \
  --allow-all-urls

Expected behavior

Copilot CLI should not read, modify, or delete files outside /sandbox/workdir, regardless of:

  • whether ~ is used instead of absolute paths
  • whether deletion is attempted via shell commands or via code (e.g. Python)

In particular, /sandbox/.copilot/session-state outside /sandbox/workdir should remain protected.

Additional context

  • Copilot CLI version: 1.0.11
  • OS: Linux
  • Shell: bash
  • Working directory: /sandbox/workdir

Activity

  1. added theissue type on Mar 26, 2026
  2. marked <!-- greptile-status --> #2305 as a duplicate of this issue on Mar 26, 2026
  3. unmarked <!-- greptile-status --> #2305 as a duplicate of this issue on Apr 2, 2026
  4. added
    area:permissionsTool approval, security boundaries, sandbox mode, and directory restrictions
    on Apr 6, 2026
  5. patniko commented on Oct 26, 2026

    @patniko
    Collaborator

    Thanks for the report. We've shipped fixes in this area since this was filed (most recently in Copilot CLI v1.0.94), and we believe this may now be resolved. Could you retest on the latest release (Copilot CLI v1.0.103) and let us know whether you still see it? If we don't hear back in a couple of weeks, we may close this issue — you can always reopen it.

    Triaged as part of a Copilot SDK backlog review, with help from GitHub Copilot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:permissionsTool approval, security boundaries, sandbox mode, and directory restrictionsmore-info-needed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions