Repository navigation
Conversation
The output-schema validator (Spec 056) and the pre-dispatch input
validator (Spec 085) compile the JSON Schema an upstream server declares
for its tools with jsonschema.NewCompiler(). Its default URL loader
serves file:// URLs, so a schema containing
{"$ref": "file:///some/path.json"} made the proxy open that local
file and compile it into the tool's schema.
Install an empty SchemeURLLoader on both compilers. In-document refs
(#/$defs/...) and the standard $schema metaschemas are unaffected; a
schema with an external ref now fails to compile and takes the existing
fail-open path.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Dumbris
approved these changes
Oct 26, 2026
Dumbris
left a comment
Member
There was a problem hiding this comment.
Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.
Member
|
Merged. Thank you, @rudycelekli! Upstream tool schemas can no longer make mcpproxy load local files through |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Two validators compile the JSON Schema that an upstream server declares for its tools:
internal/outputvalidation/validator.gocompile(): theoutputSchema, used for output-schema validation (Spec 056; on by default inwarnmode).internal/server/mcp_input_validation.gocompileInputSchema(): theinputSchema, used for pre-dispatch argument validation (Spec 085; always on).Both call
jsonschema.NewCompiler()without setting a loader. Insanthosh-tekuri/jsonschema/v6the default loader isFileLoader, which opens anyfile://URL. So when a schema contains{"$ref": "file:///any/path.json"}, mcpproxy opens that path on the user's machine, parses it, and compiles it into the tool's schema. The verdict then depends on a local file the upstream chose.Trigger
Any upstream, including a remote HTTP one, can list a tool whose
inputSchemaoroutputSchemacontains afile://$ref. The file is read on the first call to that tool. No user action is needed beyond calling the tool.Fix
Call
c.UseLoader(jsonschema.SchemeURLLoader{})on both compilers. The empty loader rejects every external URL scheme. Two things keep working:#/$defs/...) resolve against the in-memory resource and never reach the loader.$schemametaschemas are embedded in the library and are served before the loader is consulted.A schema that uses an external ref now fails to compile and takes the existing fail-open path (FR-A9 / FR-013b).
Tests
TestCompile_RefusesFileRef(outputvalidation) andTestCompileInputSchema_RefusesFileRef(server): a temp file holds{"type":"string"}, and the schema is{"$ref":"file://<that file>"}. With the fix it must not compile.TestCompile_LocalRefsAndMetaSchemaStillWorkandTestCompileInputSchema_LocalRefStillWorks: a#/$defsref and the draft 2020-12$schemastill compile and validate.Commands run
CGO_ENABLED=0 go test -count=1 -run 'Test' ./internal/outputvalidation/: okCGO_ENABLED=0 go test -count=1 -run 'TestCompileInputSchema_|TestPreDispatchValidation_' ./internal/server/: okCGO_ENABLED=0 go vet ./internal/outputvalidation/: okmain(and again with both one-line fixes reverted), bothRefusesFileReftests fail, withschema with $ref file:///…/local.json compiled; the local file was loaded.I did not run the full
./internal/serverpackage locally.