Is claude-agent-sdk safe?
- Python shell/command execution
- Python filesystem read
- Python filesystem write/delete
What to do: Nothing here argues against installing it. Grant the capabilities it lists only if you expect the tool to need them.
claude-agent-sdk is a PyPI package analyzed by SkillTotal's deterministic static scanner. The scan found no malicious indicators. It can: filesystem read, filesystem write, mcp tools detected, network egress and shell execution — capabilities are what the code can do, not a verdict on intent. Risk score 0/100 (low).
claude-agent-sdk 0.2.165
Automated static-analysis result. It can contain false positives and false negatives, and is not a claim about the intent of claude-agent-sdk's authors. Report a false positive.
Behavioral traits
How this component maps to the CSA agentic threat model. Descriptive — it never affects the risk score.
Findings (5)
The component can run operating-system commands or spawn processes.
result = subprocess.run(
cmd,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)result = subprocess.run(
[
sys.executable,
"-m",
"wheel",
"tags",
"--platform-tag",
platform_tag,
"--remove",
str(wheel_path),
] …result = subprocess.run(
[sys.executable, "-m", "twine", "check", "dist/*"],
check=False,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)subprocess.run(
command,
check=True,
capture_output=True,
stdin=subprocess.DEVNULL,
env=env,
)result = subprocess.run(
[
"security",
"find-generic-password",
"-a",
user,
"-w",
"-s",
_KEYCHAIN_SERVICE_NAME, …result = subprocess.run(
["git", "worktree", "list", "--porcelain"],
cwd=cwd,
capture_output=True,
text=True,
timeout=5,
check=False,
)Why it matters: Powerful and often legitimate — confirm the commands aren't built from untrusted input.
Fix: Confirm the command and its arguments are fully controlled and not derived from untrusted input; avoid shell=True.
The component reads files from disk.
match = CLI_VERSION_PATTERN.search(CLI_VERSION_FILE.read_text())
with Path(gh_out).open("a", encoding="utf-8") as f:head = Path(script_path).read_bytes()[:64]
with Path(script_path).open("rb") as f:body = Path(script_path).read_bytes()
json.loads(config_path.read_text(encoding="utf-8"))
content = version_path.read_text()
content = pyproject_path.read_text()
content = version_path.read_text()
content = file_path.read_bytes()
return src.read_bytes()
return (project_dir / file_name).read_text(encoding="utf-8")
content = match.read_text(encoding="utf-8")
_agent_metadata_sidecar_path(transcript_path).read_text(encoding="utf-8")
Why it matters: Usually legitimate, but worth confirming it can't be steered into reading sensitive files.
Fix: Confirm which files are read and that paths cannot be influenced by untrusted input to reach sensitive locations.
The component writes or deletes files on disk.
shutil.rmtree(dist_dir)
shutil.copy2(cli_path, target_path)
config_path.write_text(json.dumps(config, indent=2) + "\n", encoding="utf-8")
version_path.write_text(new_content)
pyproject_path.write_text(content)
version_path.write_text(content)
shutil.rmtree(path.parent / session_id, ignore_errors=True)
shutil.rmtree(path)
shutil.rmtree(path, ignore_errors=True)
shutil.rmtree(path, ignore_errors=True)
dst.write_text(out, encoding="utf-8")
dst.write_bytes(transform(content) if transform else content)
meta_file.write_text(json.dumps(meta_content), encoding="utf-8")
Why it matters: Usually legitimate, but worth confirming the paths can't be controlled by untrusted input.
Fix: Confirm which files are written/deleted and that paths cannot be influenced by untrusted input.
The component makes outbound network requests.
import urllib.request
req = urllib.request.Request(
f"https://pypi.org/simple/{package}/",
headers={
"Accept": "application/vnd.pypi.simple.v1+json",
"User-Agent": "claude-agent-sdk-quota-check",
},
)with urllib.request.urlopen(req, timeout=30) as resp:
Why it matters: Usually legitimate, but confirm the destinations are expected and no sensitive data leaves.
Fix: Confirm the destination hosts are expected and that no sensitive data is sent off-host.
An MCP tool surface (manifest or tool definitions) was found.
>>> @tool("greet", "Greet a user", {"name": str})>>> @tool("add", "Add two numbers", {"a": float, "b": float})>>> @tool("divide", "Divide two numbers", {"a": float, "b": float})>>> @tool(
tools: List of SdkMcpTool instances created with the @tool decorator.
>>> @tool("add", "Add numbers", {"a": float, "b": float})>>> @tool("multiply", "Multiply numbers", {"a": float, "b": float})>>> @tool("add_item", "Add item to store", {"item": str})Why it matters: Just context — review which tools it offers and their permissions.
Fix: Review the declared MCP tools and their permissions.
How attackers abuse these capabilities
Interactive labs on the attack class behind the rules above. They show the technique, not anything found in claude-agent-sdk.
Check your own component
Run the same evidence-backed scan on any MCP server, agent skill, or package.
Scan your own componentHow we determine this: deterministic static analysis (regex + AST), evidence-anchored, no code execution. Methodology →