Skip to content

Avoid prompt injection false positives for emoji ZWJ sequences#264

Open
koriyoshi2041 wants to merge 1 commit into
NVIDIA:mainfrom
koriyoshi2041:fix-emoji-zwj-prompt-injection
Open

Avoid prompt injection false positives for emoji ZWJ sequences#264
koriyoshi2041 wants to merge 1 commit into
NVIDIA:mainfrom
koriyoshi2041:fix-emoji-zwj-prompt-injection

Conversation

@koriyoshi2041

Copy link
Copy Markdown
Contributor

Problem

Fixes #259. The static P2 hidden-instruction rule currently flags every U+200D zero-width joiner, including normal visible emoji ZWJ sequences such as 🧑‍⚖️. That makes benign skill text look like prompt injection.

Fix

Allow U+200D only when it joins two emoji bases in an emoji sequence. Other zero-width characters, and bare ZWJ usage such as text\u200dSYSTEM, still produce P2 findings.

Tests

  • .venv/bin/python -m pytest tests/nodes/analyzers/test_static_patterns.py tests/unit/test_patterns.py
  • .venv/bin/ruff check src/skillspector/nodes/analyzers/static_patterns_prompt_injection.py tests/nodes/analyzers/test_static_patterns.py tests/unit/test_patterns.py
  • .venv/bin/ruff format --check src/skillspector/nodes/analyzers/static_patterns_prompt_injection.py tests/nodes/analyzers/test_static_patterns.py tests/unit/test_patterns.py
  • git diff --check

Risk

Low. The carve-out is limited to ZWJ between emoji-like codepoints; bare ZWJ and non-ZWJ hidden characters remain flagged.

Signed-off-by: kigland <shuaizhicheng336@gmail.com>
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.

Static analyzers flag emoji-zwj-sequence as Prompt Injection

1 participant