Skip to content

fix(mcp): reject dot segments in path arguments - #25

Open
BryanFRD wants to merge 1 commit into
mainfrom
fix/21-reject-dot-segments
Open

BryanFRD wants to merge 1 commit into
mainfrom
fix/21-reject-dot-segments

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Path ids and slugs went through encodeURIComponent, which leaves . and .. intact, so fetch collapsed them (e.g. restore_release with release_id: ".." hit /sites/acme/restore).

All path interpolation now goes through pathSegment, which throws on . and .. before any request is made. Tests cover the helper and two tools (id and site slug).

Closes #21

@ferrfleet-interne ferrfleet-interne 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.

This is correct. encodeURIComponent leaves . and .. as they are, so the WHATWG URL parser would have collapsed /sites/acme/releases/../restore. Rejecting both before encoding closes that hole. A %2e%2e input can't slip through either, because the % is encoded to %25.

I searched the repo and every encodeURIComponent path builder under mcp/packages is converted, so none were missed. @ferrlabs/mcp-core has no equivalent helper, so putting it in api-base.ts makes sense. Nothing blocking.

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.

fix(mcp): validate id and slug arguments so dot segments cannot retarget the request path

1 participant