Skip to main content

llm-shield

Local PII/secret redaction and prompt-injection guard for LLM calls. Hebrew-, Russian- and English-aware. Zero dependencies, zero servers, zero telemetry — it runs inside your own FastAPI process, so personal data never leaves your infrastructure on the way to an LLM provider.

user text ──► redact ──► [NAME_1] [EMAIL_1] [PHONE_1] ──► LLM provider
user sees ◄── restore ◄── "…send it to [EMAIL_1]…"    ◄── LLM provider

Quick start

from llm_shield import Shield

shield = Shield(on_injection="raise")

# One line around your existing async LLM call:
chat = shield.wrap(call_llm)          # async def call_llm(messages) -> str
answer = await chat(messages)

# Or explicit control:
with shield.session() as s:
    safe = s.redact_messages(messages)       # provider only ever sees placeholders
    reply = await call_llm(safe)
    answer = s.restore(reply)

FastAPI

from llm_shield.contrib_fastapi import install, session_dependency

install(app)                                    # InjectionBlocked -> HTTP 400
get_session = session_dependency(shield)

@app.post("/chat")
async def chat(body: In, session = Depends(get_session)):
    safe = session.redact_messages(msgs(body))
    return {"reply": session.restore(await call_llm(safe))}

Streaming works too (placeholders split across chunks are reassembled on the fly): see examples/demo_app.py. Run python examples/run_demo.py for a walkthrough.

What it detects

Kind Notes
EMAIL, IP
PHONE Israeli mobile/landline (050-…, +972…) and generic international
IL_ID Israeli Teudat Zehut, checksum-verified
CARD Luhn-verified
IBAN mod-97-verified
SECRET API keys (OpenAI/Anthropic-style, AWS, GitHub, Slack), JWTs, PEM private keys
NAME heuristic: only after an introduction phrase ("my name is…", "שמי…", "меня зовут…")

Prompt-injection scanner: English, Hebrew, Russian patterns, role spoofing, hidden zero-width/bidi-override characters, exfiltration via URLs/markdown images. Reports contain signal names only — never user text — so they are safe to log.

Honest limitations

  • Names are the weak spot. Regex can't find a name that isn't introduced. For that you need an NER model; plug one in as a custom Detector.
  • The injection scanner is heuristic. It stops lazy attacks, not determined ones. Pair it with least-privilege tool access and output validation.
  • Models can mangle placeholders (rare, but possible). Unknown placeholders are left as-is, never guessed.
  • Text only. Images, PDFs and audio are not inspected.
  • This is a risk-reduction tool, not a compliance certificate. It helps you prepare for GDPR / Israeli Privacy Protection Law obligations; it does not make you compliant by itself.

Develop

pip install -e .[dev]
pytest

License

AGPL-3.0

Metadata

Release files for sharkeyes 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharkeyes 0.1.0
File Size Uploaded
sharkeyes-0.1.0.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharkeyes 0.1.0
File Interpreter ABI Platform
sharkeyes-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / sharkeyes-0.1.0.tar.gz

Download URL sharkeyes-0.1.0.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8097c450b89bd896c4fde27089ff0874d59f60c55c50442a163a0fda05e4b804
BLAKE2b-256 checksum
How to use checksums
7e6ceb12de2cb4ec3da07244071eba9a2cda85665576308550de6453e7715aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release files / sharkeyes-0.1.0-py3-none-any.whl

Download URL sharkeyes-0.1.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8717f8dbf0dcde8c231330d92d0a716f297e6b5af2f91a640fe9e9b1942b550
BLAKE2b-256 checksum
How to use checksums
bbb4aaacb6f44cc3c5156ea3c16b2fe8a7be95c3a8ff4548c29414627d9a101d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page