Is fastmcp-slim safe?
- Unsafe deserialization
- Code writes to an AI agent's MCP configuration, settings or instruction files
- Python shell/command execution
What to do: Read the findings below before installing: each one opens the exact line of code it was found on.
fastmcp-slim is a PyPI package analyzed by SkillTotal's deterministic static scanner. The scan found no malicious indicators, though 2 risky constructs are reported for review. It can: delegated authentication, filesystem read, filesystem write, mcp tools detected and shell execution — capabilities are what the code can do, not a verdict on intent. Risk score 40/100 (medium).
fastmcp-slim 4.2.4
Get notified when this component changes
Change alerts aren't live yet. Leave your email and we'll let you know when they launch. We use it only for this and delete it on request.
Automated static-analysis result. It can contain false positives and false negatives, and is not a claim about the intent of fastmcp-slim'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 (7)
The component writes to a config file of a separate AI client (Claude Desktop, Cursor, VS Code, Continue, Windsurf), or, in the user's home directory, to an AI agent's settings, skills, subagents, commands or instruction and memory files (Claude Code, Codex, Gemini CLI, Cursor rules, AGENTS.md, CLAUDE.md). A server, hook or instruction added there loads in the agent's next session. That is expected from a command the user runs to set the agent up, and unexpected from code that runs on install or import.
config_file.write_text('{"mcpServers": {}}')Fix: Confirm why the component edits an agent's configuration or instructions. A tool that registers itself should ask the user and write only what it says it writes.
It loads data with a format that can rebuild arbitrary objects (e.g. pickle, or unsafe YAML).
parsed = yaml.load(frontmatter_text, Loader=yaml.BaseLoader) # noqa: S506
value = yaml.load(match.group(1), Loader=_FrontmatterLoader) # noqa: S506 - SafeLoader subclass rejects duplicate keys
Why it matters: Feeding such a loader untrusted data can execute code hidden inside that data.
Fix: Deserialize untrusted data with a safe format/loader: JSON, or yaml.safe_load / Loader=SafeLoader. Reserve pickle/marshal for data you fully control.
The component can run operating-system commands or spawn processes.
process = await asyncio.create_subprocess_exec(
*cmd,
env=env,
start_new_session=sys.platform != "win32",
)subprocess.run([cmd, "--version"], check=True, capture_output=True)
process = subprocess.run(
[npx_cmd, inspector_cmd, *uv_cmd],
check=True,
env=env,
)process = subprocess.run(cmd, check=True, env=env)
process = subprocess.run(cmd, check=True, env=env)
subprocess.run(
[
"powershell.exe",
"-NoLogo",
"-NoProfile",
"-NonInteractive",
"-Command",
_WINDOWS_ACL_SCRIPT,
], …result = subprocess.run(
[claude_in_path, "--version"],
check=True,
capture_output=True,
text=True,
)result = subprocess.run(
[str(path), "--version"],
check=True,
capture_output=True,
text=True,
)subprocess.run(
[gemini_in_path, "--version"],
check=True,
capture_output=True,
)subprocess.run(
[str(path), "--version"],
check=True,
capture_output=True,
)return subprocess.run(
windows_batch_command_line(command),
executable=_windows_command_processor(),
check=True,
capture_output=True,
text=True,
)return subprocess.run(command, check=True, capture_output=True, text=True)
subprocess.run(["open", url], check=True, capture_output=True)
os.startfile(url)
subprocess.run(["xdg-open", url], check=True, capture_output=True)
process = subprocess.run(cmd, check=True)
process = await asyncio.create_subprocess_exec(
*cmd,
stdin=None,
stdout=None,
stderr=None,
# Own process group so _terminate_process can kill the whole tree …subprocess.run(
[
"uv",
"init",
"--project",
str(output_dir),
"--name",
"fastmcp-env",
] …subprocess.run(
[
"uv",
"python",
"pin",
self.python,
"--project",
str(outpu …subprocess.run(
[
"uv",
"add",
*dependencies,
"--no-sync",
"--project",
str(output_dir), …subprocess.run(
[
"uv",
"add",
"-r",
str(req_path),
"--no-sync",
"--project" …subprocess.run(
[
"uv",
"add",
"--editable",
*editable_paths,
"--no-sync",
" …subprocess.run(
["uv", "sync", "--project", str(output_dir)],
check=True,
capture_output=True,
text=True,
)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.
app_bridge_js = app_bridge_cache.read_text(encoding="utf-8")
with open(Path(server_spec), encoding="utf-8") as f:
data = json.loads(path.read_text(encoding="utf-8"))
return model.model_validate_json(path.read_text(encoding="utf-8"))
text = path.read_text(encoding="utf-8")
text = path.read_text(encoding="utf-8")
text = path.read_text(encoding="utf-8")
content = config_file.read_text(encoding="utf-8").strip()
with open(config_path, encoding="utf-8") as f:
with open(config_path, encoding="utf-8") as f:
content := file_path.read_text(encoding="utf-8").strip()
if file_path.exists() and file_path.read_text(encoding="utf-8").strip():
content: str | bytes = await self._async_path.read_bytes()
content = await self._async_path.read_text(encoding=self.encoding)
with open(path, "rb") as f:
content = path.read_bytes()
return main_file_path.read_bytes().decode("utf-8")content = main_file.read_text(encoding="utf-8")
files = {file.relative_to(root).as_posix(): file.read_bytes() for file in paths}contents[relative] = entry.read_bytes()
with open(config_path, encoding="utf-8") as f:
with open(self.path, "rb") as f:
with open(self.path, "rb") as f:
with open(self.path, "rb") as f:
data = json.loads(cache_path.read_text())
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.
app_bridge_cache.write_text(app_bridge_js, encoding="utf-8")
with open(output_path, "w") as f:
output_path.write_text(script, encoding="utf-8")
skill_path.write_text(skill_content, encoding="utf-8")
config_file.write_text('{"mcpServers": {}}')file_path.write_text(self.model_dump_json(indent=2), encoding="utf-8")
target.write_bytes(content)
shutil.rmtree(previous)
shutil.rmtree(staging)
with open(output, "w") as f:
file_path.write_text(content.text, encoding="utf-8", newline="")
file_path.write_bytes(base64.b64decode(content.blob))
cache_path.write_text(
json.dumps({"latest_version": latest_version, "timestamp": time.time()})
)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.
An OAuth 2.0 / OpenID Connect delegated-authentication flow was detected (authorization-code / refresh-token / token-exchange grant, an OIDC authorize/discovery endpoint or id_token, or a delegation library). Tools authenticate with the end user's delegated, scoped credentials rather than a long-lived embedded service credential. (25 occurrence(s) shown as evidence).
upstream_authorization_endpoint="https://login.example.com/oauth/authorize",
f"/.well-known/openid-configuration{issuer_path}","/.well-known/openid-configuration",
"(`{issuer}/.well-known/openid-configuration`) unless overridden in "Fetches ``{issuer}/.well-known/openid-configuration`` and returns itsconfig_url = issuer.rstrip("/") + "/.well-known/openid-configuration"from authlib.common.security import generate_token
access_token, and for OIDC providers may include id_token,
to verify a different token (e.g., the OIDC id_token for providers
Replaces `authlib.integrations.httpx_client.AsyncOAuth2Client` for the OAuth
proxy's upstream token-endpoint calls. authlib's httpx integration imports the
legacy `httpx` package — which authlib does not declare as a dependency and
authlib's wire behavior exactly:
- form-encoded POST token requests with authlib's default headers
- `client_secret_basic` (latin-1 basic auth, authlib-style), `client_secret_post`,
- `OAuthError` (authlib's httpx-free core error class) raised for RFC 6749
from authlib.integrations.base_client import OAuthError
Drop-in replacement for the slice of authlib's `AsyncOAuth2Client` that
Falsy parameters are dropped from the request body, matching authlib.
injected into the returned dict, matching authlib.
data: dict[str, Any] = {"grant_type": "refresh_token"}authorization_endpoint: AnyHttpUrl | str | None = None # Strict
enforce("authorization_endpoint", True)verify_id_token: If True, verify the OIDC id_token instead of the access_token.
id_token is always a standard JWT verifiable via the provider's JWKS.
Fix: Delegated auth is a lower-blast-radius execution context than an embedded static credential. Confirm the requested scopes are minimal and that tokens are never logged or forwarded off-host.
An MCP tool surface (manifest or tool definitions) was found.
server = FastMCP(self.name)
mcp = FastMCP()
mcp = FastMCP(
mounted = FastMCP(
@mounted.tool("greeting")mcp = FastMCP()
class _CurrentFastMCP(Provider["FastMCP"]):
def CurrentFastMCP() -> FastMCP:
return cast(FastMCP, _CurrentFastMCP())
s.add_request_handler("tools/list", PaginatedRequestParams, self._on_list_tools)s.add_request_handler("tools/call", CallToolRequestParams, self._on_call_tool)class FastMCP(
mcp_server.add_tool(tool)
async with stdio_server() as (read_stream, write_stream):
self.add_tool(component)
added = super().add_tool(tool)
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 fastmcp-slim.
The free Claude Code plugin scans each npm, PyPI or MCP package with this report's open-source engine before the install command runs. It runs on your machine and needs no account.
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 →