Dev.to Security 🔐 Cybersecurity 👁 0 📖 6 min read

Hardening a public MCP server: two scanners, a spec change and a kill switch

Earlier this month I wrote about shipping HireGPS's remote MCP server with its own OAuth 2.1 server. This is the follow-up: what two independent MCP scanners found, what changed in the spec, and how we added a new client

Earlier this month I wrote about shipping HireGPS's remote MCP server with its own OAuth 2.1 server. This is the follow-up: what two independent MCP scanners found, what changed in the spec, and how we added a new client registration method without risking the one that already works.

Quick context: HireGPS reads a CV against a target role the way a recruiter would. We run two MCP servers. mcp.hiregps.app/mcp is the main one and needs sign-in. risk-checker.hiregps.app/mcp is a free, read-only server with five tools and no sign-in.

What the scanners saw

We ran our servers through two public scanners, VerifyMCP and mcpprobe. The most useful lesson came before any finding: a scanner can only grade what it can see.

On the free server, which needs no sign-in, VerifyMCP could test everything and gave it 73/100 before the fixes below. On the main server it gave 36/100, and its own report explains why: it couldn't authenticate, so six of its seven categories scored zero. mcpprobe, on the same main server, passed 4 of the 5 checks that could run and marked 19 others as not assessable for the same reason.

So the low score was mostly a statement about the scanner's view, not about the server. Still, every check that could run found something real, and all of it was cheap to fix.

Five small fixes

1. HSTS on the MCP hosts. Our marketing site already sent Strict-Transport-Security, but the two MCP hosts did not. We added max-age=31536000 in nginx, without includeSubDomains or preload for now. A test checks the header on every host.

2. DNSSEC. The domain wasn't signed. With Cloudflare DNS and a separate registrar this is two steps: enable DNSSEC in Cloudflare, then add the DS record (key tag, algorithm 13, digest type 2, digest) at the registrar. Before saving, we computed the DS digest ourselves from the published DNSKEY and compared it with what we had typed. A wrong DS record can take a domain offline, so the order matters if you ever need to undo it: remove the DS record at the registrar first, wait, then disable DNSSEC at the DNS provider.

3. Tool annotations. Every tool on the free server only reads published content and pure engine functions. It stores no input and makes no outside or model calls. We already declared readOnlyHint: true, destructiveHint: false, idempotentHint: true and openWorldHint: false, and checked each value against the code rather than trusting it.

4. Named output schemas. Our outputSchemas existed but had no named fields, just additionalProperties: true. A scanner reads that as "declared, no fields", and a model learns nothing from it either. Each tool now declares its fields and types with additionalProperties: false. A test calls every tool with every response shape we know (all 40 rules, 20 countries, an unknown country, seven seniority levels, several date sets) and validates structuredContent against the schema.

The cost: our full tools/list grew from about 1,070 to about 2,040 tokens, measured with a local tokenizer, so the numbers are approximate. Most of that growth is the output schemas.

5. One example per tool, and one missing header. Each tool description now ends with a single line such as Example input: {"country": "Germany"}, and a test calls all five examples. mcpprobe's only finding on the main server was a missing X-Content-Type-Options: nosniff on /mcp. That's one more line next to the HSTS header.

The spec moved: Client ID Metadata Documents

In the first post I cited the 2025-11-25 revision, where Client ID Metadata Documents (CIMD) became a SHOULD and Dynamic Client Registration (DCR) a MAY. The 2026-07-28 authorization spec goes one step further. DCR is still a MAY, but the spec now says it "is deprecated and retained for backwards compatibility".

With CIMD the client_id is an HTTPS URL. The authorization server fetches the JSON document at that URL, checks it, and uses its redirect_uris. There's no registration endpoint to defend, and a client gets one stable identity instead of a new registration on every connect.

The catch: once your authorization server advertises CIMD support, new connections depend on your server being able to fetch those documents. So we did two things before writing the feature.

We measured from production first. From the production container, with the exact request the feature would make (no redirects, 5 second limit), we fetched Claude's, Claude Code's and ChatGPT's client documents three times at different hours. All three returned 200 with application/json every time, in 69 to 256 ms, and none hit a bot challenge. If they had, we would have shipped a login that works in staging and fails for real users.

We put it behind a kill switch. A CIMD_ENABLED setting, off by default. When it's off, the metadata doesn't advertise CIMD or the none client auth method, URL-shaped client_ids are rejected, and DCR works exactly as before. Changing the value recreates the container from the same image, so turning it off is a deploy, not a code change.

The fetch rules we ended up with:

  • HTTPS only. Hosts that resolve to private addresses are refused, and redirects aren't followed.
  • Only claude.ai and chatgpt.com for now, with no subdomains.
  • 5 second timeout and a 5 KB size limit.
  • The document's client_id must equal the URL it was fetched from.
  • redirect_uris must be a subset of the redirect addresses we already allow.
  • Cached according to its HTTP cache headers, with an upper bound.
  • Every failed fetch is logged and counted, and repeated failures raise an alert.

Two details surprised us.

The consent screen. For a DCR client we showed the client's self-declared name. For a CIMD client we now show the host of the client_id URL, because the host is the part we actually verified. Our first draft produced "chatgpt.com at chatgpt.com" when the client host and the redirect host were the same. Now the second half is dropped when they match.

Revocation. Users can disconnect a client from their account settings. With CIMD the client_id is a URL, and the web layer that forwards the request to the backend rejected IDs containing /. The disconnect button would have silently failed for every CIMD client. We caught it while writing the feature, and connections are now revoked by connection ID. A test checks that one user can't revoke another user's connection.

We also added authorization_response_iss_parameter_supported: true to our metadata. We already sent iss in authorization responses, but RFC 9207 says that if you include it, you must also advertise it. The 2026-07-28 spec expects a future revision to make iss a MUST.

One decision we didn't make

Leaving tools/list open without sign-in would let scanners and directories see our tools, and some clients document that pattern as "lazy authentication": you allow discovery, then return a 401 on the first protected tool call. We didn't do it. Not every client we support documents how it handles a 401 on tools/call, and we haven't measured it yet. Until we have, an honest "not assessable" from a scanner is better than a broken login for users.

What I'd tell someone shipping their first MCP server

  • Run a public scanner on day one, and read the "not assessable" list as carefully as the findings.
  • Measure the network path a new auth feature depends on from production, before writing the feature.
  • Put anything that changes how clients sign in behind a switch you can turn off without a code change.
  • Treat tool descriptions and output schemas as part of the interface. A model reads them on every call.

CIMD is merged and switched off. The next step is turning it on with end-to-end tests in Claude, Claude Code and ChatGPT, then re-scanning. I'll post what breaks.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.