has_hidden_char (prompt/_injection_markers.py)

guardana · packages/guardana-rules/src/guardana/rules/prompt/_injection_markers.py · python · Apache-2.0
ai

Pure Python detectors for invisible Unicode characters used to smuggle hidden instructions into LLM context.

# Source: https://github.com/guardana/guardana | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""Shared detectors for smuggled instructions — the core of indirect prompt injection.

Any file whose text is later fed to a model as trusted context (an MCP tool
manifest, an agent rules file, a model card, a README) can carry instructions a
human reviewer never sees: invisible Unicode, or an override phrase buried in
prose. These detectors are shared so every rule that scans such text agrees on
what "hidden instruction" means, instead of each re-inventing the vocabulary.
"""

import re
import unicodedata

# An instruction that tries to override the surrounding context. Greppable phrase

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key