SKY-D264 · Security in code
AI agent given a shell, code runner or other broad tool
An AI agent is a model that can call tools on its own: functions your code hands it, which it runs with your program's permissions. SKY-D264 reports an agent built with a tool that can do almost anything: a shell, a Python interpreter, unrestricted file or HTTP access, or a tool that wraps os.system, subprocess, eval or shutil.rmtree.
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- Excessive agent tool privilege
Why it matters
The agent decides which commands to run from text it reads, and that text can come from a log line, a web page or a ticket written by an attacker. With a shell tool, one injected sentence can read secrets, delete data or open a connection out of your network.
What Skylos flags
from langchain_community.tools import ShellToolfrom langchain_openai import ChatOpenAIfrom langgraph.prebuilt import create_react_agent model = ChatOpenAI(model="gpt-4o-mini", max_tokens=800, timeout=30) ops_agent = create_react_agent( model, tools=[ShellTool()], prompt="Help the on-call engineer read service logs.",)What Skylos leaves alone
from langchain_community.agent_toolkits.load_tools import load_toolsfrom langchain_openai import ChatOpenAIfrom langgraph.prebuilt import create_react_agent model = ChatOpenAI(model="gpt-4o-mini", max_tokens=800, timeout=30) research_agent = create_react_agent( model, tools=load_tools(["wikipedia", "arxiv"]), prompt="Answer questions about papers and cite your sources.",)Why Skylos leaves it alone
load_tools() is the same call that hands out a terminal, but these two tools only search public sites. Skylos reads the tool names given to load_tools() and reports only terminal, shell, python_repl, python_repl_ast, file_management and requests_all.
How Skylos decides
- Runs with
--dangeron Python files that mention an agent or tool API (create_react_agent,initialize_agent,AgentExecutor,crewai,load_tools,StructuredTool,tools=and similar). - Finds agent constructors: calls whose name ends in
create_react_agent,create_openai_tools_agent,create_openai_functions_agent,create_structured_chat_agent,initialize_agent,AgentExecutor,.assistants.createor simplyAgent(CrewAI and similar). - Reads the
tools=,tool=,toolkit=ortoolkits=argument and the positional arguments, following lists and variables assigned in the same function or module. - Reports HIGH when a tool is
ShellTool(),PythonREPLTool()orPythonAstREPLTool(); aload_tools()call naming one of the broad tools above; an OpenAI tool{"type": "code_interpreter"}or{"type": "computer_use_preview"}; or aTool(...)orStructuredTool.from_function(...)whose function iseval,exec,compile,os.system,os.popen,os.execve,os.execvp,shutil.rmtreeor asubprocesscall. - The finding sits on the line where the agent is created.
How to fix it
Give the agent small tools that do one job with fixed inputs, here reading one of two known log files. Anything that changes state should go through a person's approval, and the process should run with only the permissions those tools need.
Removed: from langchain_community.tools import ShellToolAdded: from pathlib import PathAdded: Added: from langchain_core.tools import toolfrom langchain_openai import ChatOpenAIfrom langgraph.prebuilt import create_react_agent model = ChatOpenAI(model="gpt-4o-mini", max_tokens=800, timeout=30)Added: LOG_FILES = {Added: "api": Path("/var/log/shop/api.log"),Added: "worker": Path("/var/log/shop/worker.log"),Added: } Added: Added: @toolAdded: def tail_service_log(service: str) -> str:Added: """Return the last 200 lines of the api or worker log."""Added: log_file = LOG_FILES.get(service)Added: if log_file is None:Added: return "unknown service"Added: return "\n".join(log_file.read_text(encoding="utf-8").splitlines()[-200:])Added: Added: ops_agent = create_react_agent( model,Removed: tools=[ShellTool()],Added: tools=[tail_service_log], prompt="Help the on-call engineer read service logs.",)When it can be wrong
- A shell or code tool that runs inside a throwaway sandbox (a container with no secrets and no network, or OpenAI's hosted code interpreter) is still reported.
- Missed: your own
@toolfunction that callssubprocess.run()oros.remove()inside its body, MCP servers handed to an agent, tools built in another module, and agents in TypeScript or other languages.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Put the marker on the line where the agent is created and say what contains the tool.
Python ops_agent = create_react_agent( # skylos: ignore[SKY-D264] runs in no-network sandboxskylos baseline ., then--baseline, accepts reviewed agents and reports new ones.[tool.skylos] ignore = ["SKY-D264"]turns the rule off for the whole project.