Skip to content

User confirmation for write commands #12624

Open

Description

@denieler

Link to issue for design submission

N/A

Proposed Design

Considering that gh CLI is a very comfortable tool to use with AI agents, more and more engineers install it on their machines and give permissions. However, it's not safe, in my opinion, especially considering recent leaks and vulnerabilities in NPM that used gh CLI to compromise the repos of engineers.

Considering that, I think we need to add an additional confirmation mechanism to "write" commands of gh CLI, such as PR creation or pushing the code, etc. That we have a config in the system, that would require an additional user confirmation for such commands.

Please let me know what you think about it, and maybe such a mechanism already exists in some variant. Thank you!

Activity

  1. added
    enhancement
    on Feb 6, 2026
  2. github-actions commented on Feb 6, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  3. added
    needs-triage
    on Feb 6, 2026
  4. williammartin commented on Feb 6, 2026

    @williammartin
    Member

    Hey @denieler, thanks for opening the issue.

    Can you talk a little bit more about what you would expect here? If gh prompts for user confirmation, malicious agents are likely to approve the confirmation themselves? We could maybe have a config setting to error on non-read only commands? That might provide some protection as long as agents don't have write access to the gh config file.

    Lemme know your thoughts, and if I'm missing something in your initial proposal. Definitely keen to make gh work better with agents.

  5. added
    more-info-needed
    on Feb 6, 2026
  6. BagToad commented on Feb 6, 2026

    @BagToad
    Member

    However, it's not safe, in my opinion, especially considering recent leaks and vulnerabilities in NPM that used gh CLI to compromise the repos of engineers.

    Could you link to anything that talks more about this please? I'd like to understand what this is referring to.

  7. 6main1998-debug commented on Feb 7, 2026

    @6main1998-debug
  8. denieler commented on Feb 8, 2026

    @denieler
    Author

    Hey @williammartin 👋

    I think here we have 2 dimensions:

    1. Preventing malicious AI agents from abusing the gh CLI

    We could maybe have a config setting to error on non-read only commands?

    I think your proposition here makes sense and would meaningfully improve the situation, especially in environments where only agents are expected to run, such as Docker images built specifically for AI agents. Well, also on dev machines, but in theory, agents can modify the config file as well.

    1. Preventing scripts (e.g. npm postinstall) from using the gh CLI for harmful purposes, given that more machines will have gh installed, as AI agents become more common

    In this case, maybe additional human approval for "write" commands + blocking them in non-TTY envs (allowing only for CI cases, e.g., only if GH_TOKEN env is set or similar) 🤔
    Another option is to require a recent re-auth for "write" commands.

  9. added a commit that references this issue on Feb 14, 2026
    d2b7175
  10. removed
    more-info-needed
    needs-triage
    on Feb 19, 2026
  11. added and removed
    needs-triage
    on Feb 19, 2026
  12. denieler commented on Mar 2, 2026

    @denieler
    Author

    @williammartin you've mentioned in #12687 that this issue needs a more detailed design. Can you please be more specific? I'd be glad to work on it 🙇‍♂️ Thank you!

  13. added
    needs-design
    on Mar 3, 2026
  14. williammartin commented on Mar 3, 2026

    @williammartin
    Member

    Hey @denieler, mostly, I think we need a better understanding of the landscape. Starting from your problem statements:

    Preventing malicious AI agents from abusing the gh CLI

    Preventing scripts (e.g. npm postinstall) from using the gh CLI for harmful purposes, given that more machines will have gh installed, as AI agents become more common

    I think we need to understand what solutions are currently emerging for these problems. For example, in the case of agentic flows, maybe instead of making gh enforce a config setting, we support a command that can be used in PreToolUse hooks. To be clear, I'm not saying this is the right option, just expressing that I'm missing some kind of holistic view here. Maybe GitHub needs a better solution for minting short-lived less-privileged tokens. Anything we do on the client side feels kind of limited if an agent can do:

    curl -H "Authorization: $(gh auth token)" ...
    

    There's also #8237 which might be relevant here.

    https://github.com/Evaneos/kubectl-readonly was something else interesting I found.

  15. SergeyKanzhelev commented on Jul 24, 2026

    @SergeyKanzhelev

    it may be handy to add the argument like gh readonly <anything command that currently exist> that will only allow readonly commands. So one can allowlist gh readonly * in agent setting while human can use gh as before.

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

    configenhancementneeds-designstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions