Validate static_map_image_tool style path#150
Closed
mattpodwysocki wants to merge 1 commit intomainfrom
Closed
Conversation
…atic map URL - Add regex validation to the style parameter to prevent path traversal attacks; accepts only username/style-id with alphanumeric chars, hyphens, and underscores - Apply encodeURIComponent() to each style segment before URL interpolation - Return public URL (without access_token) in text content to avoid leaking credentials to the model context; token is still used internally for the fetch and the MCP Apps iframe URL Reported via HackerOne (2026-03-18) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Closing in favor of a clean PR without edit history. |
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.
Summary
Fixes a path traversal vulnerability issue in
static_map_image_tool.Path traversal fix: The
styleparameter was an unvalidatedz.string(), allowing a crafted value like../../tokens/v2to escape the/styles/v1/URL path and proxy authenticated requests to arbitrary Mapbox API endpoints using the server operator's access token. Added a regex constraint (/^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]+$/) that accepts only validusername/style-idformat. Also applyencodeURIComponent()to each segment before URL interpolation.Credentials leak fix: The full URL including
?access_token=TOKENwas returned as text content and exposed to the model context. The token is only needed internally for the HTTP fetch and the MCP Apps iframe. Changed to return a public URL (without the token) in the text content block.Test plan
rejects style values with path traversal patterns— verifies traversal payloads (../../tokens/v2,../styles, etc.) are rejected withisError: trueaccess_token=is not present in text content