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.1

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.1
File Size Uploaded Provenance Actions
sharkeyes-0.1.1.tar.gz 27.2 kB Without provenance Details for sharkeyes-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 50.7 kB

Release files / sharkeyes-0.1.1.tar.gz

Download URL sharkeyes-0.1.1.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7f8636030c009dbbd434d96acc5ba198ee8a0276c6965f764f7964f6fd8af5a3
BLAKE2b-256 checksum
How to use checksums
6dc32799f69c8e7c1a3f6695c2e169b2202dd5df2950a6fac566713ab3915ee3
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.1-py3-none-any.whl

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

Security for sharkeyes 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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