-
Notifications
You must be signed in to change notification settings - Fork 44.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/ability to disallow certain shell commands #3707
Conversation
A simple "if any" to be able to set disallowed shell commands in the .env
added comment
added cmd.strip() to handle spaces
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of times agents come up with arguments against list_files() which are not accepted, this makes the agent end up in a loop, while a lot of times the args are just a replacement of the original "filename" argument, and i've also seen extension as an argument, with literally an ".ext" as search argument. Changed the function to accept all, it might be better to take care of this on the agent side, but in the meantime I couldn't take it anymore :)
added load_disallowed_commands() function to load from OS.env and pass them to the execute_shell function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
submitted
This is a mass message from the AutoGPT core team. For more details (and for infor on joining our Discord), please refer to: |
I did a similar check, but also did a whitelist as well.
|
I think this would make more sense as a docker feature. There are user-security level methods to prevent this. Hard-coding in limitations doesn't seem like a secure practice. All it takes is for an agent/human to lookup workarounds around the prohibited commands in the repo's source code or the config files. |
Those are supposed to be optional defaults in the .env, not hardcoded. Just like categories of commands that can be disallowed. |
Well the parser/filter for them is hardcoded. There are other security tools for this. I don't recommend implementing this feature this way. I do think its a good feature, just a bad implementation. All the agent has to do is read the .env file and it can come up with workarounds. |
Other than that, there's more than just one blacklist/whitelist feature now for the shell execution feature. |
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request. |
This one can be closed as it was taken care if with #3950 |
A simple "if any" to be able to set disallowed shell commands in the .env
Background
Many times I encountered an agent getting stuck when starting a GUI application like vi or nano via the execute_shell command. Resulting in auto-GPT waiting endlessly until I either killed the command through another terminal session or I had to completely abandon the session with CTRL+C.
The GUI applications nano and vi or gedit are unnecessary as auto-GPT has the write_to_file and append_to_file commands to take care of that.
Changes
To be able to set the disallowed commands, I added the parameter "DISALLOWED_COMMANDS" to the .env.template.
Documentation
In the .env file you can set the DISALLOWED_COMMANDS, comma separated like DISALLOWED_COMMANDS=nano,vi,gedit
The variable DISALLOWED_COMMANDS can contain commands with spaces. The code that checks for disallowed commands isn't designed to handle complex commands with arguments, it's just looking for specific command names in the input string. If we need to handle complex commands, we may need a more sophisticated approach.
Test Plan
Tested with various goals which might triggered commands that we want to disallow, like nano, vi, gedit.
PR Quality Checklist