Skip to main content

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

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

ops/agent.py · PythonReported on line 7
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

research/agent.py · Python
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

  1. Runs with --danger on Python files that mention an agent or tool API (create_react_agent, initialize_agent, AgentExecutor, crewai, load_tools, StructuredTool, tools= and similar).
  2. 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.create or simply Agent (CrewAI and similar).
  3. Reads the tools=, tool=, toolkit= or toolkits= argument and the positional arguments, following lists and variables assigned in the same function or module.
  4. Reports HIGH when a tool is ShellTool(), PythonREPLTool() or PythonAstREPLTool(); a load_tools() call naming one of the broad tools above; an OpenAI tool {"type": "code_interpreter"} or {"type": "computer_use_preview"}; or a Tool(...) or StructuredTool.from_function(...) whose function is eval, exec, compile, os.system, os.popen, os.execve, os.execvp, shutil.rmtree or a subprocess call.
  5. 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.

ops/agent.py · Python · the fix, against the flagged file
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 @tool function that calls subprocess.run() or os.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 sandbox
  • skylos baseline ., then --baseline, accepts reviewed agents and reports new ones.

  • [tool.skylos] ignore = ["SKY-D264"] turns the rule off for the whole project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.