# No zero-width or other invisible characters

**Zero-width spaces and joiners, soft hyphens, word joiners and direction marks are invisible; they often come from copy and paste, but they can also split keywords to slip past filters, so remove them from tool metadata.**

Check `sec-zero-width` · Poisoning and hidden text · default severity: attention · rubric 2.1.0. Last verified against OWASP MCP Security Cheat Sheet on 2026-11-18.

## What fails

Zero-width spaces and joiners, soft hyphens, word joiners and direction marks are invisible. Often they come from copy and paste, but they can also split keywords to slip past filters.

## The rule

> Treat the entire tool schema as a potential injection surface — not just the description field.

Source: [OWASP MCP Security Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/MCP_Security_Cheat_Sheet.html)

## How to fix it

Remove the characters. "Copy fixed tool list" strips them.

1. Strip U+200B to U+200F, U+2060, U+FEFF and U+00AD from every string.
2. Check your editor or generator: copied text from documents is the usual source.
3. Add a CI test.

A CI test that fails when the pattern comes back:

### TypeScript (node:test)

```js
// tools-list.test.mjs: run `node --test` after saving the answer with
// npx @modelcontextprotocol/inspector --cli <server> --method tools/list > tools.json
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';

const answer = JSON.parse(readFileSync('tools.json', 'utf8'));
const tools = answer.tools ?? answer.result?.tools ?? answer;

// Every string and every key in a tool, with its path.
function* strings(value, path) {
  if (typeof value === 'string') yield [path, value];
  else if (value && typeof value === 'object')
    for (const [k, v] of Object.entries(value)) {
      yield [`${path}.${k} (key)`, k];
      yield* strings(v, `${path}.${k}`);
    }
}

const PATTERN = /[\u200B-\u200F\u2060\uFEFF\u00AD]/u;

test('no zero-width or invisible characters', () => {
  const hits = [];
  for (const tool of tools) for (const [path, text] of strings(tool, tool.name)) if (PATTERN.test(text)) hits.push(path);
  assert.deepEqual(hits, [], 'zero-width or invisible characters in tool metadata');
});
```

### Python (pytest)

```python
# test_tools_list.py: run `pytest` after saving the answer with
# npx @modelcontextprotocol/inspector --cli <server> --method tools/list > tools.json
import json
import re

with open("tools.json", encoding="utf-8") as f:
    answer = json.load(f)
tools = answer.get("tools") or answer.get("result", {}).get("tools") if isinstance(answer, dict) else answer


def strings(value, path):
    """Every string and every key in a tool, with its path."""
    if isinstance(value, str):
        yield path, value
    elif isinstance(value, dict):
        for k, v in value.items():
            yield f"{path}.{k} (key)", k
            yield from strings(v, f"{path}.{k}")
    elif isinstance(value, list):
        for i, v in enumerate(value):
            yield from strings(v, f"{path}.{i}")


PATTERN = re.compile(r"[\u200B-\u200F\u2060\uFEFF\u00AD]")


def test_no_zero_width_or_invisible_characters():
    hits = [path for tool in tools for path, text in strings(tool, tool["name"]) if PATTERN.search(text)]
    assert hits == [], "zero-width or invisible characters in tool metadata"
```

## Questions

### Why is this attention and not blocking?

Most zero-width characters in the wild come from copy and paste, not attacks. They are still worth removing: they change tokens and can defeat keyword filters.

### Is U+FEFF at the start of a file a problem?

A byte-order mark at the start of a file is harmless; inside a string value it is an invisible character.

## Related checks

- [No invisible Unicode tag or variation-selector characters](https://isokron.ai/mcp-check/checks/sec-invisible-encoding)
- [No control characters in metadata](https://isokron.ai/mcp-check/checks/sec-control-chars)
- [No bidirectional override characters](https://isokron.ai/mcp-check/checks/sec-bidi-controls)
- [Tool poisoning and hidden text](https://isokron.ai/mcp-check/checks/security)

Counts toward: Poisoning and hidden text, Anthropic connector directory, OpenAI plugin directory.

Rubric: https://isokron.ai/mcp-check/rubric

Check your tool list: https://isokron.ai/mcp-check
