microsoft/mcp/harden-tool-url-inputs
Claude Code and agent skill by microsoft/mcp
- vendor
Checking that the SKILL.md file is still in the repository.
Audit and harden one or more tool directories against URL hijacking and SSRF by tracing MCP inputs to URL construction and using IAzureService or injectable IEndpointValidator with cloud-specific Azure endpoint allow-lists. Use when: validate URL inputs, secure endpoints, prevent URL hijacking, SSRF hardening, audit tool directories, apply EndpointValidator.
Install
npx vskill@latest install microsoft/mcp/harden-tool-url-inputsSKILL.md
The same SKILL.md was published earlier as microsoft/mcp/harden-tool-url-inputs.
Harden Tool URL Inputs
Audit and update every requested directory so MCP-influenced values cannot hijack a URL, URI, host, or client endpoint. Use IAzureService forwarding methods or the host's injectable IEndpointValidator at the final URL boundary, with the configured Azure cloud and the narrowest appropriate allow-list.
This is a scoped implementation skill, not a report-only audit. Make the fixes and add tests unless the user explicitly requests analysis only.
Required Input and Scope
- Accept one or many repository-relative directories under
tools/. - Resolve every path and confirm it is inside the repository's
tools/directory. Reject files or directories outside that boundary. - If no directory is supplied, ask the user for at least one. If a supplied path does not exist or its intended scope is ambiguous, ask before editing.
- Treat each supplied directory as an exhaustive scope. Do not stop after finding the first vulnerable URL flow.
- Do not modify other tool directories. Shared changes to
core/Microsoft.Mcp.Core/src/Helpers/EndpointValidator.AllowLists.csand its tests are allowed when a scoped tool needs a new Azure service allow-list. - Preserve unrelated worktree changes. Read the repository and nearest scoped instructions before editing.
Pattern Sources
Before implementing, inspect the current versions of:
core/Microsoft.Mcp.Core/src/Helpers/IEndpointValidator.cscore/Microsoft.Mcp.Core/src/Helpers/EndpointValidator.cscore/Microsoft.Mcp.Core/src/Helpers/EndpointValidator.AllowLists.cscore/Azure.Mcp.Core/src/Services/Azure/IAzureService.cscore/Microsoft.Mcp.Core/tests/Microsoft.Mcp.Core.Tests/Helpers/EndpointValidatorTests.cscore/Azure.Mcp.Core/tests/Azure.Mcp.Tests/Helpers/AzureServiceTestHelpers.cs
When wiring dependencies or testing namespace overrides, also inspect SsrfProtectionPolicy.cs, EndpointValidationServiceCollectionExtensions.cs, ICommandContextAccessor.cs, and EndpointValidationRegistrationTests.cs in their corresponding core projects. Read the executing-command-context guidance in CONTRIBUTING.md and transport boundaries in docs/design/HttpClientFactory.md.
Use current implementations as the API and pattern source of truth. Do not copy obsolete static policy-dependent calls or explicit namespace arguments from historical examples. Representative current cases include:
- ACR: validate the exact
Uripassed to the data-plane SDK through a small static helper that receivesIAzureServicefor focused tests. - App Configuration and Communication: validate a discovered or user-supplied endpoint immediately before client construction.
- Compute: distinguish URL input from a resource ID and validate only the URL branch with the
storage-bloballow-list. - Cosmos and Foundry Extensions: try a small explicit set of acceptable Azure service types, then fail closed; an early any-cloud option check never replaces the authoritative configured-cloud service check.
- Load Testing: use
ValidatePublicTargetUrlfor a deliberately arbitrary public target. - Service Bus: reject URL-component characters in a bare host and still validate the completed endpoint.
Threat Model
- Treat every MCP option as untrusted, including values named
account,cluster,endpoint,host,namespace,registry,resource,server,url,uri, orworkspace. - Track derived values. Validation is required when an untrusted name is interpolated into a host even if the option itself is not described as a URL.
- Treat endpoint-like Azure resource metadata as a trust boundary before using it in a data-plane client. Resource Graph or ARM returning a string does not make that string safe for network use.
- Validate the completed absolute endpoint, not only the resource name or one string fragment.
- Treat path, query, and "relative" inputs as potential authority changes. APIs such as
new Uri(baseUri, value)accept absolute and network-path references that can replace the base host. - URL parsing, escaping, encoding, or rejecting a few special characters is not a replacement for host allow-list validation.
EndpointValidatorauthorizes the scheme and host; it does not make untrusted path or query syntax safe. Build those components with typed SDK APIs or correctly escaped path/query helpers.- A successful
Uriparse proves syntax, not authorization to contact the host.
Workflow
1. Establish the baseline
- Inspect
git statusand the scoped diff before editing. - Read command registration, options, commands, services, helpers, and tests in every supplied directory.
- Identify the top-level MCP tool namespace from registration code. Do not infer it only from the directory name.
- Check whether each Azure service endpoint already has a key in
EndpointValidator.AllowLists.cs. - Identify the existing
IAzureServicedependency or, where unavailable, theIEndpointValidatordependency and its DI registration. Do not create a separate validator or policy at the tool boundary.
2. Inventory input-to-URL flows
Search the full scope for both sources and sinks. Useful candidates include:
[Option]properties and legacy option definitionshttp://,https://,Endpoint,Host,Url, andUrinew Uri, target-typednew(...),UriBuilder, and connection strings- base-plus-relative combinations such as
new Uri(baseUri, value)andHttpClientmethods called with string request targets - Azure SDK or other client constructors that accept a URI, endpoint, namespace, or host
HttpClient.BaseAddress,HttpRequestMessage,RequestUri,GetAsync,PostAsync,PutAsync, andSendAsync- interpolated REST paths, request URLs, callback URLs, webhook URLs, and upload/download sources
- helpers that append paths, ports, queries, or fragments
Search results are only candidates. Trace each MCP option through command, service, and helper calls to its final network sink. Also inspect URL construction that uses endpoint-like values returned from ARM, Resource Graph, configuration, files, or prior service calls.
For every candidate, determine one disposition:
| URL flow | Required disposition | |
|---|---|---|
| Azure data-plane endpoint | IAzureService.ValidateAzureServiceEndpoint or injected IEndpointValidator.ValidateAzureServiceEndpoint | |
| Known non-Azure service with an exact host set | Static EndpointValidator.ValidateExternalUrl | |
| Deliberately arbitrary public HTTP(S) target | IAzureService.ValidatePublicTargetUrl or injected IEndpointValidator.ValidatePublicTargetUrl | |
| Input-derived path or query on an allowed base | Reject absolute/network-path replacement, construct or escape the component with an appropriate API, then validate the final absolute URL | |
| Typed Azure control-plane operation | Use the typed ARM SDK and ResourceIdentifier through shared ARM client creation; its pipeline validates each final request URI rather than requiring a redundant tool-level check | |
| Compile-time fixed URL with no influenced component | Document as not input-derived; no runtime validation needed |
Do not classify an Azure endpoint as an arbitrary public target merely to avoid defining a service allow-list.
Shared ARM clients created through AzureHelper.CreateArmClientAsync call IAzureService.ConfigureArmClientOptions and retain a configured-cloud arm validation policy before transport. It validates every attempt, including retries, paging, and long-running-operation polling, even without an active command context. Do not assume raw ARM HTTP calls or independently constructed SDK clients have this policy. Trace those paths and validate their final URLs against the configured-cloud arm allow-list before sending, including subsequent request URLs.
3. Implement Azure service validation
For an Azure data-plane endpoint, validate the exact absolute URL before the SDK client, request, or other network-capable object can use it:
Apply these rules:
- Use named arguments to distinguish the endpoint and service allow-list key. Direct
IEndpointValidatorcalls also supply the Azure cloud. serviceTypeis the exact key for the endpoint domain inEndpointValidator.AllowLists.cs.- The executing tool namespace is resolved by the validator through
ICommandContextAccessor.CurrentContext.ToolNamespaceName, not supplied by the caller. It is the original registeredIAreaSetup.Name, even in consolidated or single-tool mode, and is independent ofserviceType; for example,computemay consumestorage-blob, andfoundryextensionsmay consumefoundryorazure-openai. Never infer it from request arguments, an endpoint, a routing name, or telemetry. IAzureService.ValidateAzureServiceEndpointalways uses its ownCloudConfiguration.ArmEnvironment; callers supply only the endpoint and service key. DirectIEndpointValidatorcalls must pass the configured cloud at an authoritative service boundary. Do not hardcode public cloud when configured cloud context is available.- If option validation cannot access the configured cloud, it may accept endpoints valid in any explicitly supported cloud for early feedback, but the service must validate again against the configured cloud before use.
- When several Azure service endpoint families are intentionally accepted, try only a small explicit service-type set in the configured cloud. Catch only the expected validation exceptions and fail closed when none match.
- Validate every endpoint-producing branch. A safe default branch does not protect an alternate branch.
- Additional service-specific checks may restrict paths, ports, resource-name structure, or bare-host syntax, but they do not replace validation of the completed endpoint. Document why each bespoke check is necessary as described below.
- When combining a trusted base URI with user input, do not pass the input directly to base-plus-relative URI resolution. Prove it is relative, reject
//,\\, schemes, rooted paths, fragments, and other authority-changing forms as appropriate, then add escaped path segments or query parameters with a purpose-built API. - Validate the final absolute URL after combining its components so alternate-authority behavior cannot bypass the allow-list.
- Constructing a
Urisolely to canonicalize and then validating itsAbsoluteUriis acceptable. Do not perform credential acquisition, client creation, DNS access, or a network call before validation. - Do not configure or bypass SSRF protections, open command scopes, or assign namespaces from tool code. Command loaders establish the scope around the complete awaited command execution, including option validation. Discovery, learn/sampling callbacks, direct CLI execution, and external proxy forwarding do not populate the accessor; a real command selected through sampling receives its own scope.
Dependency and policy ownership
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 2 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/harden-tool-url-inputs/SKILL.md
Popularity
- Repository stars
- 3,724
- Repository forks
- 630
- 7-day trend score
- 46
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/mcp/harden-tool-url-inputs)