Repository navigation
Reject path-breaking ids in MCP tool inputs - #8843
Merged
Merged
Conversation
Id parameters are interpolated into URL paths passed to app.inject(), which resolves dot segments, so an id such as ../applications/<id> could reach a different route. Declare ids with a shared pattern-bearing schema, validate every id argument and refuse dot-segment paths centrally when a tool is invoked, and encode the remaining free-text path values.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8843 +/- ##
==========================================
+ Coverage 78.49% 78.52% +0.02%
==========================================
Files 475 475
Lines 25721 25760 +39
Branches 6849 6857 +8
==========================================
+ Hits 20189 20227 +38
- Misses 5532 5533 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cstns
approved these changes
Oct 9, 2026
…guard # Conflicts: # forge/ee/lib/mcp/tools/snapshots.js
andypalmi
enabled auto-merge (squash)
October 9, 2026 11:02
This was referenced Oct 9, 2026
Add MCP tools to delete database tables, team databases, shared library entries and git tokens
#8857
Merged
This branch was successfully deployed
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.
Description
MCP tools build the
app.injectURL by interpolatingargs.*ids into the path, and most of those ids were plainz.string().app.injectresolves dot segments, so an id such as../applications/<id>reached a different route than the tool claims to act on.This adds a shared guard rather than per-tool checks.
schemas.jsgainspathId, a string restricted to^[A-Za-z0-9_-]+$(hashids, UUIDs andteam-broker). The raw*Id: z.string()parameters across the tools use it, so the published input schema carries the pattern and the gateway enforces it.invokeToolintoolLoader.jsis now the only way a tool handler is called, andplatformAutomation.jsuses it. It rejects any top level string argument whose key ends inIdunless it matches the pattern, withInput validation error: <field> must contain only letters, digits, hyphen and underscore. This runs even when schema parsing falls back to the raw input.invokeToolalso hands the handler a wrappedinjectthat refuses any URL path segment that is.or..(including once percent-decoded) or contains control characters. File paths keep working because they are percent-encoded into one segment.Behaviour change
*Idarguments are UUIDs.pattern.Reviewer notes
tools/*.jswere checked: ids are covered by the id key check andpathId, and everything else (usernames, slugs, file paths, table names) by the inject wrapper plus encoding.Tests
pathGuard_spec.jswith 21 tests:../applications/abcand../teams/abcstyle ids are rejected for instances, applications, pipelines, remote instances, brokers, snapshots and teams, as are?,#, backslash,%2e%2e, newlines and..file paths. Normal ids, UUIDs,team-brokerandlogs/archiveare accepted, and a sweep checks every*Idparameter across all tools.mainand pass here.platformAutomation_spec.jspass.Related Issue(s)
Closes #8716
Part of #8629