You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
Reacted by Claas Augner, Ole Jørgen Brønner, John Bennett, Nicolas Morel, elliottyates, gmillet-matawan, Jennifer (Jenny) Bryan, AriESQ, Sergey Kanzhelev, AlekseyMalakhov-Wellsterhealth and 1 more
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 wantedContributions 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.
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.
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.
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.
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.
@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!
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:
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.
Reacted by AlekseyMalakhov-Wellsterhealth and M Laraib Ali
Activity
github-actions commentedon Feb 6, 2026
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 wantedContributions 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.
williammartin commentedon Feb 6, 2026
Hey @denieler, thanks for opening the issue.
Can you talk a little bit more about what you would expect here? If
ghprompts 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 theghconfig file.Lemme know your thoughts, and if I'm missing something in your initial proposal. Definitely keen to make
ghwork better with agents.BagToad commentedon Feb 6, 2026
Could you link to anything that talks more about this please? I'd like to understand what this is referring to.
6main1998-debug commentedon Feb 7, 2026
denieler commentedon Feb 8, 2026
Hey @williammartin 👋
I think here we have 2 dimensions:
ghCLII 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.
postinstall) from using the gh CLI for harmful purposes, given that more machines will haveghinstalled, as AI agents become more commonIn 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_TOKENenv is set or similar) 🤔Another option is to require a recent re-auth for "write" commands.
Add user confirmation for write commands
denieler commentedon Mar 2, 2026
@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!
williammartin commentedon Mar 3, 2026
Hey @denieler, mostly, I think we need a better understanding of the landscape. Starting from your problem statements:
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
ghenforce a config setting, we support a command that can be used inPreToolUsehooks. 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:There's also #8237 which might be relevant here.
https://github.com/Evaneos/kubectl-readonly was something else interesting I found.
SergeyKanzhelev commentedon Jul 24, 2026
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 allowlistgh readonly *in agent setting while human can useghas before.