mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
fix(service): reject encoded MCP paths
Reject percent signs in mcp_path so ASGI path decoding cannot turn an accepted configuration into an unreachable route. Cover encoded slash, space, and double-encoded slash inputs.
This commit is contained in:
parent
4b5d34c8bc
commit
470e782f71
2 changed files with 4 additions and 1 deletions
|
|
@ -205,7 +205,7 @@ class HttpService(BaseService):
|
|||
)
|
||||
if "//" in path or any(segment in {".", ".."} for segment in path.split("/")):
|
||||
raise ValueError("mcp_path must use non-empty literal path segments")
|
||||
if any(char in path for char in "{}?#\\") or any(
|
||||
if any(char in path for char in "{}?#%\\") or any(
|
||||
char.isspace() or ord(char) < 32 or ord(char) == 127 for char in path
|
||||
):
|
||||
raise ValueError("mcp_path must be a literal URL path without route, query, or fragment syntax")
|
||||
|
|
|
|||
|
|
@ -194,6 +194,9 @@ def test_http_service_rejects_invalid_or_conflicting_mcp_paths() -> None:
|
|||
"/{rest:path}",
|
||||
"/mcp?mode=test",
|
||||
"/mcp#fragment",
|
||||
"/mcp%2Fv2",
|
||||
"/mcp%20v2",
|
||||
"/mcp%252Fv2",
|
||||
"/mcp path",
|
||||
"/mcp//nested",
|
||||
"/mcp/../nested",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue