Replies: 3 comments
|
Funny enough I thought about adding a "container" tool such that Llama.cpp could spin up a podman container or docker container for each conversation and only execute commands in that container (much like Anthropic etc already do) but then it turns out Restricting tools to the current conversation container is another story but definitely recommend that for production. |
|
I've been looking at the We find similar matching All tools are secured, except the The shell exec is done through: which is sent to io->run -> subprocess I thus have three suggestions:
Now that we see cases of AI escaping their containers by using clever combinations of commands, we should clearly NOT allow any command to be executed. On a production server the list of allowed commands must be known and carefully chosen. And it is better if this does not require programming in the server-tools for each. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
Thanks to @ngxson for suggesting to initiate this discussion concerning the
--tools(which he has mostly contributed).This discussion is launched after PR attempt #24659, regarding a suggestion to add tools from a Markdown file.
The security aspect is vital for llama.cpp agent features. Hard-coded tools are secured by construction. This is true for all current tools except
server_tool_exec_shell_commandwhich calls a shell. This is really dangerous when enabled. The reason is that the currentserver_tool_exec_shell_commandtool implementation is calling therun_processfunction with eitherargs = {"cmd", "/c", command};orargs = {"sh", "-c", command};. This is sent tosubprocess_createwhich uses a string vector as argument, but the command is sent as a single string. So anything in the 'command' will be executed in a new shell context. This allows command injection of all kinds. This tool can be kept, but may be complemented with a new mechanism which ensures that no command injection is possible. This discussion brings a potential solution.I suggest more tools could be added by reading a Markdown file such as (or something else, but kept simple):
The
**bold**is just there for readability by humans. MD syntax is subject to discussion. Of course, the list of tools from MD must be properly defined to avoid dangerous commands. This is on the user's responsibility when launching the server.The steps for implementation could be:
lynx -dump {URL}. Add new tools as proposed in PR tools/server: support for --tools defined from e.g. Markdown files at start #24659. In my view, SKILLS specifications are quite complex to implement, when compared with a single MD file as above.{URL}would still be part of the same argument e.g. "-cmd_script=FILENAME http://xxx".server_tool_exec_shell_command), but instead we directly callsubprocess_createwith the string vector after placeholder replacement in each arg of the string vector. In the example, thelynxcall would fail as the URL would be given literally as "-cmd_script=FILENAME http://xxx".server_tool_exec_shell_commandwould be a MD tool command given asbash -c "{command}"where the command is sent as a single string to the shell. This is dangerous.The issue with PR #24659 is related to the shell call which presents a security breach, whatever checks are done in the command syntax. I suggest to still contribute something like #24659 while removing the shell call e.g. the
run_process("sh" "-c" "command")and replace it withrun_process(string_vector_command)(no shell). The security check ('is_command_safe') would be removed.In this way:
Cheers.
All reactions