Skip to content

fix(skills): validate percent-encoded skill names - #1431

Open
tsarlandie-oai wants to merge 3 commits into
modelcontextprotocol:mainfrom
tsarlandie-oai:fix/percent-encoded-skill-names
Open

tsarlandie-oai wants to merge 3 commits into
modelcontextprotocol:mainfrom
tsarlandie-oai:fix/percent-encoded-skill-names

Conversation

@tsarlandie-oai

@tsarlandie-oai tsarlandie-oai commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Motivation and context

Skill::validate compares a URI segment with the UTF-8 name from SKILL.md frontmatter. A skill named café therefore fails validation with NameMismatch when a server advertises skill://caf%C3%A9/SKILL.md. This came up while reviewing the filesystem catalog in #1409 and also affects servers that construct their own entries.

Percent-decode the name segment once and compare its bytes with the frontmatter. Directory separators and query or fragment delimiters are rejected in the name. When checking a listing for duplicate entries, use the same percent-encoding normalization as the manifest checker. This catches equivalent spellings of a skill URI while preserving the advertised URI for reads.

Tests

  • Reproduced NameMismatch on main with the new Unicode regression test. The fix accepts top-level and nested names with either hex case. Tests also cover invalid UTF-8, double encoding, and an encoded slash.
  • A list containing equivalent URI spellings now returns DuplicateSkill. The regression test covers the hex case, an escaped unreserved character, and a literal Unicode name.
  • cargo test -p rmcp --lib --no-default-features passed all 191 tests.
  • cargo test -p rmcp --features client --test test_skills passed all 14 tests.
  • cargo clippy -p rmcp --lib --no-default-features -- -D warnings and cargo +nightly fmt --all -- --check passed.
  • Tested locally with the filesystem catalog from feat: load skills from a directory tree #1409. All 29 catalog tests passed, and a separate test verified that a real café/SKILL.md appears under the encoded URI and returns the original Markdown through read_resource.

@tsarlandie-oai
tsarlandie-oai requested a review from a team as a code owner November 3, 2026 22:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T22:46:50.290719Z 47e65f6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added T-config Configuration file changes T-core Core library changes T-model Model/data structure changes labels Nov 3, 2026
@github-actions
github-actions Bot requested a review from jamadeo November 3, 2026 22:31
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@jamadeo is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94982693ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rmcp/src/model/skill.rs Outdated
if name != self.frontmatter.name {
let name = self.name();
if name.contains(['/', '\\', '?', '#'])
|| !percent_encoding::percent_decode_str(encoded_name).eq(name.bytes())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize URI aliases before duplicate detection

When one skills/list page contains both skill://team/caf%C3%A9/SKILL.md and skill://team/caf%c3%a9/SKILL.md, this comparison validates both entries against the same café name, but validate_skills records the raw skill.uri strings in its HashSet. The percent-escape hex case does not change the URI, so the server path accepts and returns the same skill twice despite the duplicate check; use a canonicalized URI key (also covering percent-encoded unreserved characters) or reject noncanonical spellings.

Useful? React with 👍 / 👎.

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for chasing this down, @tsarlandie-oai!

Comment on lines +274 to +277
let name = self.name();
if name.contains(['/', '\\', '?', '#'])
|| !percent_decode_str(encoded_name).eq(name.bytes())
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Agent Skills naming rules already forbid those characters and allow only lowercase letters, numbers, and a single hyphen between them. The spec says the name has to follow those rules. Would you rather enforce them here?

Comment on lines 354 to 355
// RFC 3986 §6.2.2 decodes unreserved bytes and uppercases the hex digits in
// other escapes. Reserved delimiters therefore stay encoded in the key.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mention the new encoding pass in the comment?

This branch has not been deployed

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

Labels

T-config Configuration file changes T-core Core library changes T-model Model/data structure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants