Repository navigation
> /dev/null and 2>&1 should be special-cased to not require permission #211
Copy link
Copy link
Closed
Description
Describe the bug
It seems cd is a special case in that you have to approve it every time. This is probably fine, but the issue is that copilot CLI frequently wants to cd into the current directory before running other commands. So even if those commands are already approved, the fact that the cd is there means we still have to approve it.
Here is an example:
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Check desktop apps files: │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ cd /current/directory && for file in sub/dir/fileA sub/dir/fileB │ │
│ │ sub/dir/fileC; do echo "=== $file ==="; grep -n "NEEDLE" "$file" 2>/dev/null | head -3; │ │
│ │ done │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ Do you want to run this command? │
│ │
│ ❯ 1. Yes │
│ 2. No, and tell Copilot what to do differently (Esc) │
│ │
│ Confirm with number keys or ↑↓ keys and Enter, Cancel with Esc │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
And especially note that the approval is one-time.
This happens constantly with many commands so I don't think it has anything to do with the for loop.
Affected version
0.0.334
Steps to reproduce the behavior
No response
Expected behavior
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
andrewneilson commentedon Oct 4, 2025
A better example of something even more innocuous
SteveSandersonMS commentedon Oct 6, 2025
I suspect this isn't to do with
cdat all, but really it's the redirection operators that are triggering the prompt. We prompt for confirmation if it looks like the script is trying to write a file using> destinationsyntax because that could otherwise bypass rules on which directories may be written to.However we should special-case
> /dev/nulland2>&1, as they aren't going to write to a file on disk.RyanHecht commentedon Oct 6, 2025
Can confirm a simple

cd $CWD && do_something_elsedoes not trigger it, it's the output redirection:Going to rename this issue to better reflect the change needed!
[-]Frequently asking permission to `cd` into current directory[/-][+]`> /dev/null` and `2>&1` should be special-cased to not require permission[/+]dsyme commentedon Oct 10, 2025
We have hit this. We have an invocation of Copilot CLI
During the execution we see this shell command
resulting in
but then this very similar shell command
is accepted through the permissions system.
I have access to Copilot CLI source code at GitHub and I set VSCode Agent Mode analyzing this and it said this:
RyanHecht commentedon Oct 24, 2025
We've improved our permissions checking for redirection scenarios in 0.0.351!
mark-undoio commentedon Nov 19, 2025
I believe we're seeing a variant of this too - our code is running Copilot in the background with a
-pprompt to accomplish some work.I'm trying to lock down permissions as responsibly as possible, so we're being quite explicit. The relevant set of flags for this are:
What I'm seeing is that Copilot often attempts to run commands such as:
And these seem to consistently fail with permissions issues. I've replicated this by directly asking Copilot to run the command and seen the permissions failure - then removed the
2>/dev/nulland seen success.This use of redirects seems to be common to all the permissions issues we're seen. I note that it's different to the
> /dev/nulland2>&1mentioned in the issue title.mark-undoio commentedon Nov 19, 2025
@RyanHecht from the change logs on 0.0.351:
I think the
2>/dev/nullpattern should be treated in the same way here.RyanHecht commentedon Feb 25, 2026
We've since added these (and more) patterns to the list of paths that are trusted! Closing this issue; open a new one if you run into any others!