ninadphalak/LLM-Shield-Proxy: v1.3.0: Stateless Cryptography, MCP Governance, Air-Gapped Egress, and System Hardening
Authors/Creators
Description
Security: upgrade if you run SHIELD_FAILURE_MODE=FAIL_OPEN
An upstream could switch off PII redaction for the rest of a stream.
The streaming handler treated every exception as "rehydration failed", and under FAIL_OPEN that means forward every later chunk raw. But several of those limits bound work an upstream controls: the retention-window cap, the Anthropic tool-ordinal cap, the output ceiling and the line-accumulator ceiling. An upstream that deliberately tripped one, by opening 257 distinct choice indices for instance, put the proxy into raw passthrough and had its PII forwarded in clear.
No bug was required, only a cooperating or compromised upstream, and nothing in the output indicated it had happened.
Deliberate safety limits now raise StreamCapacityExceeded and abort the stream in either failure mode, with an error event and a terminator so the client is told. FAIL_OPEN still does what it is for: an unexpected internal error keeps the stream alive.
This predates 1.6.6. If you run fail-open, treat it as the reason to upgrade.
Also fixed
Whole message shapes were never scanned. The SSE dispatcher routed the shapes it recognised into the scanner and forwarded the rest byte for byte: a reasoning model's reasoning_content, content sent as a list of parts, data: written without the space the SSE spec makes optional, the unterminated last line of a truncated stream, Anthropic message_start, and legacy text choices. Scanning is now the default and the exceptions are an explicit list.
Stand-ins could be reversed. Vault stand-ins were an unkeyed sha256 of the plaintext, so anyone holding a stand-in could recover the original offline, and the same value produced the same stand-in in every tenant, which allowed two "anonymised" datasets to be joined on it. The seed is now an HMAC over the value, its entity type and the vault's own tenant, key and session identity.
Six ways to hide a value from the detectors, all closed: base64 that is unpadded, URL-safe or doubly encoded; HTML entities; invisible filler characters; Cyrillic look-alikes in a domain; and values placed at the edges of an oversized attachment, whose boundary guards were never actually decoded. Secrets pressed directly against Japanese, Chinese or Korean text were also invisible to Tier 2.
A regex built from upstream text. A JSON property name chosen by the upstream was compiled into a pattern rather than escaped, which allowed a crash, a wildcard that rehydrated an unrelated field, and exponential backtracking that pinned a worker on a few dozen bytes.
MCP: the address checked was not the address sent. URLs were validated before PII substitution, and substitution can rewrite a URL's host, so a different registrable domain reached the upstream tool than the one the egress policy cleared. resources/read also skipped the SSRF gate and RBAC entirely, and the gate ran before tool authorisation, letting an unauthorised caller trigger DNS resolution.
Two aborts that ended badly. A tripped canary flushed the retention window it was holding, which during a prompt-extraction attack is the text being extracted. And failing closed returned silently, with no terminator, so a client could not distinguish an abort from a stalled network.
A silent hang in the audit path. The audit worker's exception handler dereferenced a queue item that may never have been bound, so the handler died, the failure was swallowed and task_done() never ran. A caller waiting on a synchronous audit write waited forever.
Configuration note
If you deploy with a Redis-backed vault and do not set SHIELD_ENCRYPTION_KEY, a random per-process key is generated and stand-ins will not be stable across restarts. Set it explicitly. Existing mappings are unaffected: rehydration is a stored lookup, not a recomputation, so stand-ins minted before this release still resolve.
Tooling
ruff, bandit and pyright now run in pre-commit at versions pinned to match CI. They had drifted: pre-commit pinned ruff 0.6.1 while CI installed it unpinned at 0.16.x, so a rule added in between passed locally and failed after pushing.
Notes
Files
ninadphalak/LLM-Shield-Proxy-v1.6.6.zip
Additional details
Related works
- Is supplement to
- Software: https://github.com/ninadphalak/LLM-Shield-Proxy/tree/v1.6.6 (URL)
Software
- Repository URL
- https://github.com/ninadphalak/LLM-Shield-Proxy