Skip to main content

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

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

server/billing.py · PythonReported on line 15
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

server/billing.py · Python
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

  1. Runs with --danger on Python files that import mcp, fastmcp or a module under mcp..
  2. Looks at X.run(...) calls where X was assigned from a call whose name ends in FastMCP or Server, or is simply named server, mcp or app. Other start-up calls, such as run_async() or uvicorn.run(...), are not checked.
  3. Treats the call as networked when transport= is the literal "sse", "http", "streamable-http" or "streamable_http", or when host= is a literal other than "127.0.0.1" and "localhost". A transport or host held in a variable is not read.
  4. Skips the call when it passes any of the keywords auth, authenticator, auth_server_provider, middleware or auth_middleware, whatever their value.
  5. 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).

server/billing.py · Python · the fix, against the flagged file
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, or token_verifier= and auth=AuthSettings(...) in the official MCP SDK, still leave the run() call reported.
  • The keyword check does not look at the value: middleware=[cors] or auth=None silence 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.

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