DEV Community

Cover image for I Pointed 3 Static Scanners at an MCP Server That Fails 8 Auth Tests. They Found 0, Including Mine

I Pointed 3 Static Scanners at an MCP Server That Fails 8 Auth Tests. They Found 0, Including Mine

Kiell Tampubolon on November 12, 2026

In the previous post in this series I built a 10-test harness for the MCP 2026-07-28 authorization rules. A quickstart-style server passed 2 of the...
Collapse
 
cryptostrapon profile image
cryptostrapon •

Honest result, and rare to see a maintainer test their own scanner this way. Did the 3 custom Semgrep rules that worked also hold up on an MCP server you didn't write, or are they still tuned to your two test servers?

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

Fair question, and the honest answer is no: the five Semgrep rules were only ever run against my two test servers, so I can't claim they generalise. What did get run on code I didn't write is the follow-up, the seven AST rules that went into mcpscan (MCP024 to MCP030). I ran those over fastmcp, the official mcp SDK, LiteLLM and seven other MCP projects to look for false positives, found two causes and fixed them. That only shows they stay quiet on good code, though. The useful next test would be a real server with an auth bug I didn't plant myself.

Collapse
 
cryptostrapon profile image
cryptostrapon •

That split makes sense, quiet on good code is only half of it. For a bug you did not plant, older releases of MCP servers with published security advisories could work as a test set, since the fix commit shows exactly what a scanner should have flagged.

Thread Thread
 
kielltampubolon profile image
Kiell Tampubolon •

That's the test set I was missing. A vulnerable release plus its fix commit gives you ground truth for free: the scanner should fire on the old tag and go quiet on the new one. My guess is the auth slice would be small, since the advisories I remember are mostly about what tools do with their input rather than token handling. Still worth building, even a dozen pairs would say more than one server I wrote myself.

Thread Thread
 
cryptostrapon profile image
cryptostrapon •

A dozen pairs is a good size, and the thin auth slice is a finding in itself. One thing I'd keep: pairs where the fix landed in a dependency bump rather than the server code. A scanner that stays quiet on both tags there isn't blind, it just can't see it, and the write-up should say which of the two it was.

Collapse
 
x1y1co profile image
X1Y1 •

This matches what we saw from the outside. On November 4 we checked 61 login-protected vendor MCP servers against the 2026-07-28 spec with a passive probe: one unauthenticated initialize plus the public discovery documents. All 61 got the 401 and PKCE right. But 40 didn't advertise the RFC 9207 issuer parameter, and 22 gave no scope hint in the 401 or in scopes_supported. None of that is in the source a scanner reads, and all of it shows up in one anonymous request to the running server. Your tests 01 and 02 alone would make a cheap CI gate.

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

61 servers with one anonymous request each is a nice way to size this. It matches what I saw: the parts every library and tutorial pushes you toward (the 401, PKCE) are fine, and the parts you only get by reading the spec closely, like the RFC 9207 issuer parameter and scope hints, are where people drop off. And yes, 01 and 02 together cost about a second in CI. Are you planning to publish the per-check counts? That would be useful for anyone choosing between vendors.

Collapse
 
x1y1co profile image
X1Y1 •

They're in the write-up, per vendor too: all 61 return the 401 and support PKCE, 36 don't advertise a Client ID Metadata Document, 40 skip the RFC 9207 issuer check, 22 give no scope hint. x1y1.co/journal/official-mcp-serve...

Collapse
 
izgorodin profile image
Edward Izgorodin •

One runtime assertion I would add to the harness: send the request twice, once with no token and once with a token in the right header that the server cannot accept, and require the two 401s to differ. RFC 6750 already draws the line: without credentials the challenge should carry no error code, and with a rejected token it says error="invalid_token". When the two answers are identical, a client behind a proxy that strips the header, or one using the wrong header name, cannot tell whether its token ever arrived, and it debugs the token instead of the plumbing. I ran the same pair last week against six hosted memory APIs that use API keys, with a made-up key in each one's documented header: four answered both requests identically.

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

That's a good assertion and cheap to add: two requests, compare the challenges, fail if they match. As written, test 01 only cares that the challenge and resource_metadata are there at all, so a proxy that strips the Authorization header would still pass it. Four of six answering identically is higher than I'd have guessed. Did any of the four at least differ in the body, or was it the same bytes all the way down?

Collapse
 
izgorodin profile image
Edward Izgorodin •

Same bytes all the way down. I reran the pair today and compared the full responses: for all four the status, the body length and the SHA-256 of the body are the same with and without the token.

Only one of the four sends a WWW-Authenticate header at all, Bearer realm="api", identical in both answers, with no error code and no resource_metadata. The other three send no challenge, so a client has only the body to go on, and the body does not change.

Collapse
 
sudokat_ profile image
Gordon Chase •

Flagging absent code in Python AST gets messy once an ingress enters the picture: if Envoy or Cloudflare serves Protected Resource Metadata and WWW-Authenticate, MCP027/MCP028 will cry wolf until someone mutes them in CI. Did any of the ten repos you checked terminate auth at a gateway, or were they all app-handled?

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

Fair worry. The ten I ran were libraries and SDKs (fastmcp, the official mcp SDK, LiteLLM and seven more), not deployments, so none of them had a gateway in front and I can't claim the gateway case is covered. When Envoy or Cloudflare owns the 401 and the metadata, the app code never mentions them and MCP027/MCP028 have nothing to see. The way I'd scope those two: fire only when the same codebase validates tokens itself, because a server that decodes JWTs but never sets WWW-Authenticate is the real bug, and one that never touches a token is probably fronted by something else. For gateway setups a per-rule ignore in CI is fine, as long as a runtime check against the public URL proves the header actually shows up there.

Collapse
 
mp3sss31 profile image
mp3sss •

This lines up with the usual SAST blind spot: auth and authorization are runtime, cross-request decisions, so a static scanner reads the handlers but never sends an unauthenticated or cross-tenant request to see whether the guard actually fires. A dynamic harness that probes each tool without a token, with the wrong scope, and after expiry catches what pattern matching misses. On the desktop side it's the same gap: linting the IPC handlers won't prove a renderer can't invoke a privileged channel — you need integration tests that actually send those messages and assert they're rejected.

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

The IPC comparison fits well, it's the same shape of bug: the handler that should refuse the call looks fine on its own, and only a message sent across the boundary tells you whether it does. On expiry, the case I'd add is a token that expires halfway through a long tool call, since it's easy to test one that's already expired and never test that one.

Collapse
 
agentsecindex profile image
Agent Security Index •

Your result matches what the protocol docs imply. MCP authorization is optional, and the interesting failures are usually "the server shipped without audience checks or token binding," not a bad regex in source (MCP Authorization spec, 2026-07-28). A static rule can flag a missing library call, but it cannot tell whether a live server rejects a token minted for a different audience, or whether a tool description changed after the client first listed it. The harness you already built against the 2026-07-28 rules is the control I would keep as the merge gate, and I would add two runtime cases scanners also miss: a token with the wrong audience, and a second tools/list after the server has been up long enough to change a description. Your finding is the right caveat for any scanner comparison: use those tools for known patterns, not as proof the auth story works.

Collapse
 
kielltampubolon profile image
Kiell Tampubolon •

Agreed on keeping the harness as the merge gate. The wrong-audience token is test 04, and on the naive server it was the worst failure because it paired with passthrough. The second tools/list after some uptime is the one I don't have, and I like it: a description that changes mid-session never shows up in a scan of the repo. I'd hash the tools/list response at start, again after a wait, and fail on any diff.