SKY-D241 · Security in code
MCP server on a network transport without authentication
An MCP server can talk to its client over standard input and output (stdio), or over the network with HTTP or server-sent events (SSE). SKY-D241 reports a Python MCP server started on a network transport, or on a non-local host, with no authentication passed to run().
- Languages
- Python
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
- Catalog name
- MCP unauthenticated network transport
Why it matters
Anyone who can reach the port can list the server's tools and call them without logging in: here, refund orders. Local addresses are not a full defence either, because other programs on the machine, and web pages using DNS rebinding, can reach them.
What Skylos flags
from fastmcp import FastMCP from billing import payments mcp = FastMCP("billing-tools") @mcp.tool()def refund(order_id: str, amount_cents: int) -> str: """Refund part of an order.""" return payments.refund(order_id, amount_cents) if __name__ == "__main__": mcp.run(transport="http", port=8000)What Skylos leaves alone
from fastmcp import FastMCP from billing import payments mcp = FastMCP("billing-tools") @mcp.tool()def refund(order_id: str, amount_cents: int) -> str: """Refund part of an order.""" return payments.refund(order_id, amount_cents) if __name__ == "__main__": mcp.run(transport="stdio")Why Skylos leaves it alone
Over stdio the server only talks to the client process that started it, such as the user's own desktop app; there is no port to connect to. mcp.run() with no transport is read the same way.
How Skylos decides
- Runs with
--dangeron Python files that importmcp,fastmcpor a module undermcp.. - Looks at
X.run(...)calls whereXwas assigned from a call whose name ends inFastMCPorServer, or is simply namedserver,mcporapp. Other start-up calls, such asrun_async()oruvicorn.run(...), are not checked. - Treats the call as networked when
transport=is the literal"sse","http","streamable-http"or"streamable_http", or whenhost=is a literal other than"127.0.0.1"and"localhost". A transport or host held in a variable is not read. - Skips the call when it passes any of the keywords
auth,authenticator,auth_server_provider,middlewareorauth_middleware, whatever their value. - Otherwise reports HIGH on the
run(line. A call that also binds to"0.0.0.0"is reported a second time, as SKY-D243.
How to fix it
If only your own client uses the server, run it over stdio. If it must serve HTTP, require a credential on every request, for example with an ASGI middleware that checks a bearer token, passed to run(). FastMCP's own FastMCP(..., auth=...) providers protect the server too, but Skylos does not see them yet (see below).
from fastmcp import FastMCPAdded: from starlette.middleware import Middleware from billing import paymentsAdded: from billing.auth import RequireBearerToken mcp = FastMCP("billing-tools") @mcp.tool()def refund(order_id: str, amount_cents: int) -> str: """Refund part of an order.""" return payments.refund(order_id, amount_cents) if __name__ == "__main__":Removed: mcp.run(transport="http", port=8000)Added: mcp.run(Added: transport="http",Added: port=8000,Added: middleware=[Middleware(RequireBearerToken)],Added: )When it can be wrong
- Authentication set on the server object is not seen:
FastMCP("billing", auth=provider)in FastMCP, ortoken_verifier=andauth=AuthSettings(...)in the official MCP SDK, still leave therun()call reported. - The keyword check does not look at the value:
middleware=[cors]orauth=Nonesilence the finding although nothing checks a credential. host="::1"(the IPv6 loopback address) counts as a network host.- In a file that imports MCP, any
app.run(...)with a non-local host, such as a Flask app, is checked the same way. - A transport chosen at run time, as in
mcp.run(transport=os.environ["MCP_TRANSPORT"]), is missed.
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
Mark the
run(line when authentication is configured elsewhere, and say where.Python mcp.run(transport="http", port=8000) # skylos: ignore[SKY-D241] auth= on FastMCP()skylos baseline ., then--baseline, accepts existing findings by file and line.[tool.skylos] ignore = ["SKY-D241"]turns the check off for the project.