Skip to content

Read the wire _meta member back through JSON in the Skills server test - #642

Merged
koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:read_the_wire_meta_member_back_through_json_in_the_skills_test
Oct 30, 2026
Merged

koic merged 1 commit into
modelcontextprotocol:mainfrom
koic:read_the_wire_meta_member_back_through_json_in_the_skills_test

Conversation

@koic

@koic koic commented Oct 30, 2026

Copy link
Copy Markdown
Member

Motivation and Context

The test that checks skills/list and skills/get emit a skill's _meta under that key sliced the generated JSON with the regexp /"_meta":\{[^}]*\}/. CodeQL flags the pattern as polynomial on a crafted subject (code scanning alert 14): on a subject that repeats "_meta":{ without a closing brace, the unanchored match restarts at every occurrence and [^}]* scans to the end before \} fails, so the work grows with the square of the length. The subject here is the server's own output, so nothing untrusted reaches the regexp, but the test needs no regexp at all: parsing the generated JSON back and reading "_meta" checks the same thing, the key the wire carries, without a pattern a scanner has to reason about.

How Has This Been Tested?

test/mcp/server_skills_test.rb; the test still fails when Skill#to_h emits the member under another key.

Breaking Changes

None.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## Motivation and Context

The test that checks `skills/list` and `skills/get` emit a skill's `_meta` under that key sliced the generated
JSON with the regexp `/"_meta":\{[^}]*\}/`. CodeQL flags the pattern as polynomial on a crafted subject
(code scanning alert 14): on a subject that repeats `"_meta":{` without a closing brace, the unanchored match
restarts at every occurrence and `[^}]*` scans to the end before `\}` fails, so the work grows with the square
of the length. The subject here is the server's own output, so nothing untrusted reaches the regexp, but the test
needs no regexp at all: parsing the generated JSON back and reading `"_meta"` checks the same thing, the key
the wire carries, without a pattern a scanner has to reason about.

## How Has This Been Tested?

test/mcp/server_skills_test.rb; the test still fails when `Skill#to_h` emits the member under another key.

## Breaking Changes

None.
@koic
koic merged commit d664720 into modelcontextprotocol:main Oct 30, 2026
13 checks passed
@koic
koic deleted the read_the_wire_meta_member_back_through_json_in_the_skills_test branch October 30, 2026 16:58
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