You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: detect Unicode homoglyphs and bidirectional chars in tool names
Closes a spoofing attack vector where tool names containing visually
identical but distinct Unicode characters (Cyrillic А vs Latin A,
fullwidth a vs ASCII a, Greek Α vs Latin A) or invisible bidirectional
formatting characters (U+202E RTL override, U+200F RTL mark, etc.) could
bypass the existing ASCII-only regex check undetected.
Changes to src/mcp/shared/tool_name_validation.py:
- Add BIDIRECTIONAL_FORMATTING_CHARS set (12 Unicode control chars)
- Reject names containing any bidi formatting char with a descriptive warning
- Reject names whose NFKC-normalized form differs from the original,
catching fullwidth look-alikes (a→a) before the regex runs
Changes to tests/shared/test_tool_name_validation.py:
- Add TestUnicodeHomoglyphDetection (9 tests): Cyrillic А/О/Е/Р, fullwidth,
Greek Α, RTL/LTR override characters
- Add TestUnicodeNormalizationBypass (2 tests): NFD decomposed forms,
NFKC fullwidth normalization
- Add TestUnicodeBoundaryConditions (1 test): zero-width space
- Add TestValidAsciiStillWorks (5 tests): confirm existing valid names
still pass after new checks
0 commit comments