Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Tools/GitHubGitHub/moshe-ship/bidi-guard
Static AnalysisVulnerability AnalysisCode AnalysisDevSecOpsSupply Chain SecurityLearning & Education
GitHubmoshe-ship/bidi-guard

bidi-guard

Scan code for invisible bidirectional Unicode characters (Trojan Source attack prevention, CVE-2021-42574)

View Repository
54 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share
Website

bidi-guard

Scan code for invisible bidirectional Unicode characters

MIT License Python 3.9+


Why This Exists

Invisible Unicode bidirectional characters can make source code display differently than it executes. This is CVE-2021-42574 — the Trojan Source attack.

An attacker embeds characters that reverse text direction. In a code review, you see:

root@kitploit:~
access_level = "admin"

But the compiler sees:

root@kitploit:~
access_level = "user"

The characters are invisible. Your editor won't show them. Your reviewer won't catch them. bidi-guard will.

Install

root@kitploit:~
pip install bidi-guard

Quick Start

root@kitploit:~
# Scan current directory recursively
bidi-guard scan .

# Scan a specific file
bidi-guard scan src/auth.py

Finds all bidirectional Unicode characters, shows their exact position, context, and severity.

Commands

CI Integration

GitHub Action

root@kitploit:~
name: BiDi Guard
on: [push, pull_request]
jobs:
  bidi-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - run: pip install bidi-guard
      - run: bidi-guard ci .

Pre-commit

Add to your .pre-commit-config.yaml:

root@kitploit:~
repos:
  - repo: https://github.com/Moshe-ship/bidi-guard
    rev: v0.1.0
    hooks:
      - id: bidi-guard

Detected Characters

All 16 Unicode bidirectional control characters:

Characters marked High or Critical can actively reorder displayed text — these are the ones used in Trojan Source attacks.

As a Library

root@kitploit:~
from bidi_guard import scan_file, Finding

findings = scan_file("src/auth.py")
for f in findings:
    print(f"{f.char_name} at line {f.line}:{f.col} — severity: {f.severity}")

Why Not Just grep?

These characters are invisible. Literally invisible:

root@kitploit:~
grep "RLO" file.py    # finds nothing
cat file.py            # looks completely normal

bidi-guard shows you what grep cannot: the exact character, its position, surrounding context, severity level, and what it does. It can also auto-fix by stripping them out.

License

MIT — Musa the Carpenter


Brought to you by the Saudi AI Community — for Arabs first, and the world at large.

Download Tool
CommandWhat it does
scanScan files for bidi characters, show findings with context
ciCI mode — exits non-zero if any dangerous characters found
fixRemove all bidi characters from files (interactive by default)
explainShow what each bidi character does with visual examples
initGenerate a .bidi-guard.yml config file for your project
Code PointNameAbbreviationSeverity
U+200ELeft-to-Right MarkLRMLow
U+200FRight-to-Left MarkRLMLow
U+061CArabic Letter MarkALMLow
U+200DZero Width JoinerZWJLow
U+200CZero Width Non-JoinerZWNJLow
U+2066Left-to-Right IsolateLRIMedium
U+2067Right-to-Left IsolateRLIHigh
U+2068First Strong IsolateFSIHigh
U+2069Pop Directional IsolatePDIMedium
U+202ALeft-to-Right EmbeddingLREMedium
U+202BRight-to-Left EmbeddingRLEHigh
U+202CPop Directional FormattingPDFMedium
U+202DLeft-to-Right OverrideLROHigh
U+202ERight-to-Left OverrideRLOCritical
U+2028Line SeparatorLSMedium
U+2029Paragraph SeparatorPSMedium