hidden-ink-plugin
- Type
- MCP server
- Scanned
- Nov 21, 2026
- Version
- bb8c333c33a2
- Files read
- 54
Hidden Ink is a local scanner, MCP server, and Claude Code guard hook that checks Word (.docx) and PDF files for hidden text and prompt injection before an AI reads them. Its biggest risks are fail-open edge cases and visibility-check bypasses that can let crafted documents or quoted shell commands pass hidden instructions to the AI unchecked, plus a predictable /tmp script path in the optional hidden-ink-check skill.
What it can reach
- Files
- Reads .docx and .pdf files passed to its tools or named in Read and Bash calls, creates a Python virtual environment inside the plugin folder, stores cached scan summaries in the user cache folder for 30 days, and writes output bundles when requested via the CLI or local web server.
- Network
- Downloads Python and locked PyPI dependencies via uv on first use, and optionally runs a local web server on 127.0.0.1:8765 when started with hiddenink serve; document scans themselves make no outbound network calls.
- Shell commands
- Runs a PreToolUse shell hook on Claude Code Read and Bash calls, spawns uv and isolated Python child processes to scan files, and in the optional hidden-ink-check skill instructs the AI agent to write and execute a Python script.
Findings
-
MediumGuard hook fails open when uv is missing or outside its search PATH
When guard.sh cannot find the uv binary (for example before uv is installed, or on macOS when uv is installed via Homebrew at /opt/homebrew/bin/uv and Claude Code runs with a minimal PATH), it outputs only additionalContext with no permissionDecision field. Unlike every other error branch in the guard, this lets Read and Bash calls open the .docx or .pdf file immediately without scanning it or asking the user for approval, exposing the AI to any hidden instructions inside.
Fix: Include "permissionDecision":"ask" (or "deny") and "permissionDecisionReason" when uv cannot be found, and check common install locations such as /opt/homebrew/bin/uv and /usr/local/bin/uv.
-
MediumBash guard regex misses document paths inside quoted subcommands and escaped quotes
The regular expression used to find .docx and .pdf files in Bash tool calls captures an entire quoted string ending in .docx or .pdf as a single file path. Commands such as sh -c "unzip -p contract.docx" or python3 -c "... \"Client Contract.pdf\" ..." resolve to non-existent file names ("unzip -p contract.docx" or "Contract.pdf"), which _resolve silently ignores as files that do not exist yet, allowing the command to read the document unchecked.
Fix: Scan inside quoted strings when the full quoted token does not match a file on disk, handle escaped quotes around file names with spaces, or mark ambiguous quoted .docx/.pdf references as unresolved so the guard asks the user.
-
MediumPreToolUse guard fails open when Path.is_file raises an OS error
run_hook places _collect(*call) inside the same broad try/except block as json.loads(stdin_text) and returns an empty string on any Exception, which tells Claude Code to allow the call silently. In Python, Path.is_file() raises PermissionError on unsearchable directories and OSError (ENAMETOOLONG) on tokens longer than 255 bytes rather than returning False, so any Bash command containing such a token alongside a malicious .docx or .pdf bypasses the guard completely.
Fix: Restrict the silent exception handler to json.loads, catch OSError inside _resolve, and return a permissionDecision of "ask" if path collection fails unexpectedly.
-
MediumInvisible PDF text using zero opacity, clipping paths, or rotated pages passes as clean text
src/hiddenink/checks/pdf.py:79
read_pdf does not track PDF fill alpha (ca 0) or clipping paths (W n), and PageRenderer.page_image does not call page.set_rotation(0) even though span bounding boxes use unrotated crop-box coordinates. If a crafted PDF places black zero-opacity or clipped-out text over existing visible text or graphics (or on a rotated page), the rendered pixel region still shows high luminance spread and a non-matching background, so render_verdict returns None, the guard reports no findings, and get_clean_text includes the hidden instructions as visible text.
Fix: Reset page rotation to 0 in PageRenderer.page_image to match preview.py, and inspect PDFium text object opacity/clip bounds or compare pixel renders with and without the text object.
-
LowSkill instructs the AI agent to write and execute a fixed /tmp script path
check/skills/hidden-ink-check/SKILL.md:23
The optional hidden-ink-check skill tells the AI agent to save its Python scanner to a predictable path in the world-writable /tmp directory (/tmp/hidden_ink_check.py) and execute it with python3. On shared or multi-user systems, another local user can pre-create or replace /tmp/hidden_ink_check.py so that their code runs under the user's account when Claude checks a document.
Fix: Ship the check script as a read-only file inside the skill directory and invoke it from there, or instruct the agent to create a private directory with mktemp -d (mode 0700) before writing the script.
-
LowOptional local web server lacks Origin and Host validation
When a user runs hiddenink serve, the FastAPI server on 127.0.0.1:8765 requires no authentication and checks neither the Origin header nor the Host header. Any website open in the user's browser can submit cross-origin multipart/form-data uploads up to 2 GB (or use DNS rebinding) to consume several gigabytes of memory, CPU, and disk space, and passing --host 0.0.0.0 exposes the unauthenticated scanner to the network.
Fix: Validate the Host header with TrustedHostMiddleware and check Origin/Sec-Fetch-Site headers or require a random local token on POST and DELETE endpoints when running locally.
-
LowLocal cache retains OCR document text and comments on disk without restrictive file permissions
Although the README states that the local cache never holds a document's text, scan_pdf records every OCR span of a scanned PDF (pdf.ocr_layer) as well as all Word comments and tracked deletions as info findings with 300-character excerpts. cache.py writes all of those excerpts to plaintext JSON files in the cache directory for 30 days using the default process umask instead of 0700/0600 permissions, keeping readable text from sensitive documents on disk after the originals are removed.
Fix: Create the cache folder with mode 0o700 and write cache files with mode 0o600, and strip excerpts from benign info findings such as pdf.ocr_layer before caching.
-
LowSingle-pass marker removal lets crafted text escape the untrusted document fence
src/hiddenink/outputs/clean_text.py:13
make_clean_text strips FENCE_START and FENCE_END from visible document text only once using str.replace. A document containing nested marker halves such as <<<END_HIDDEN_INK_<<<END_HIDDEN_INK_UNTRUSTED_DOCUMENT>>>UNTRUSTED_DOCUMENT>>> reconstructs the closing marker after one pass, allowing attacker-controlled document text to appear outside the untrusted content fence returned to the AI.
Fix: Remove fence substrings in a loop until neither marker remains, or append a random per-call token to FENCE_START and FENCE_END.
-
LowUTF-16 XML entities and spoofed ZIP sizes bypass resource checks in hidden-ink-check
check/skills/hidden-ink-check/SKILL.md:145
The standalone script in hidden-ink-check searches raw XML bytes for ASCII b"<!DOCTYPE" and b"<!ENTITY" to block XML entity expansion, and relies on the ZIP header field file_size before calling z.read(name) without process memory limits. A crafted .docx encoded in UTF-16 or carrying a spoofed uncompressed size in its ZIP header bypasses these checks and can exhaust memory or CPU through Billion Laughs entity expansion or decompression.
Fix: Read ZIP members with a bounded stream limit (MAX_PART_BYTES + 1) rather than trusting file_size, and reject DTDs via an Expat StartDoctypeDeclHandler/EntityDeclHandler so all XML encodings are covered.
