Skip to content

Validate static_map_image_tool style path#150

Closed
mattpodwysocki wants to merge 1 commit intomainfrom
fix/static-map-style-validation
Closed

Validate static_map_image_tool style path#150
mattpodwysocki wants to merge 1 commit intomainfrom
fix/static-map-style-validation

Conversation

@mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Mar 18, 2026

Summary

Fixes a path traversal vulnerability issue in static_map_image_tool.

  • Path traversal fix: The style parameter was an unvalidated z.string(), allowing a crafted value like ../../tokens/v2 to 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 valid username/style-id format. Also apply encodeURIComponent() to each segment before URL interpolation.

  • Credentials leak fix: The full URL including ?access_token=TOKEN was 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

  • Added test: rejects style values with path traversal patterns — verifies traversal payloads (../../tokens/v2, ../styles, etc.) are rejected with isError: true
  • Updated existing URL tests to assert access_token= is not present in text content
  • All 613 tests pass

…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>
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner March 18, 2026 18:44
@mattpodwysocki mattpodwysocki changed the title fix(security): validate style parameter to prevent path traversal in static_map_image_tool Validate static_map_image_tool style path Mar 18, 2026
@mattpodwysocki
Copy link
Contributor Author

Closing in favor of a clean PR without edit history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant