Skip to main content

Mobius Guard

mobiusguard-redact

Streaming redaction for LLM output. It replaces secrets and personal data in a reply while it streams, including a key split across two chunks, without stopping the stream and without buffering the whole reply. One dependency (regex), pure Python 3.11+, typed.

pip install mobiusguard-redact
from mobiusguard_redact import StreamRedactor

r = StreamRedactor()  # 24 curated patterns + all gitleaks rules
for chunk in llm_stream:  # e.g. "my key is AKIA", "QWERTYUIOPASDFGH ok"
    send(r.feed(chunk))  # emits text as soon as it is safe to
send(r.flush())  # -> "my key is [REDACTED:aws_access_key_id] ok"
r.findings  # pattern IDs and positions, never the secrets

Also: redact(text) for a whole string, and redact_stream(iterable) and aredact_stream(async_iterable) to wrap a stream.

Why use it

Most guardrails either block a whole reply or don't look inside streams at all. This one rewrites in place:

  • The same output however the text is split. For every shipped pattern, property tests split each test input at every point and check that the output matches redacting it in one go. A fuzz target (Atheris) checks the same property in CI.
  • About one word of delay. Text is held back only where a secret might be starting: 3 characters at the median, 36 at P99 and about 170 at most, on real prose and code.
  • It tolerates how models echo secrets: a few characters added or dropped, keys in backticks or quotes, connection strings with an empty user.
  • Fast: about 0.15 ms per streamed chunk (P50) and 0.4 ms (P99) on one CPU core, with all 245 patterns. A keyword prefilter skips rules whose keyword hasn't appeared.
  • Bounded: at most 8,192 characters are held back. Past that, the held text is redacted rather than leaked.

0 of 15,000 secrets leaked; 0 of 23,221 benign texts blocked by the request rules; 0.15 ms per streamed token; about one word of delay

Measured: 0 of 15,000 secrets leaked, exact or garbled, streamed through real messages in random chunks (results, 2026-11-02).

What it finds

Secrets (curated) AWS, GitHub, GitLab, OpenAI, Anthropic, Google, Hugging Face, Slack, Stripe and npm keys and tokens; Slack webhook URLs; JSON Web Tokens; private keys; passwords in connection strings; bearer tokens
Personal data (curated) emails; payment cards (Luhn); IBAN (mod-97); US SSN; Aadhaar (Verhoeff); PAN; international phone numbers
gitleaks all 221 rules of gitleaks v8.30.1, with their entropy, allowlist and keyword checks

That is 24 curated patterns and 221 gitleaks rules. Turn any of them off by ID, or bring your own:

from mobiusguard_redact import StreamRedactor, default_patterns

r = StreamRedactor(default_patterns(exclude={"generic-api-key"}), label="<{id}>")

Part of Mobius Guard

This package is the redaction layer of Mobius Guard, an open-source firewall proxy for LLM apps (pip install mobiusguard), which also checks prompts with its own CPU classifier, Fortress-XS. This package is published on its own so any gateway can embed it.

Alpha: the API may still change before 1.0. Apache-2.0. Every release is built by CI and published with PyPI trusted publishing; each file carries a build-provenance attestation.

Metadata

Release files for mobiusguard-redact 0.3.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 mobiusguard-redact 0.3.0
File Size Uploaded Provenance Actions
mobiusguard_redact-0.3.0.tar.gz 51.3 kB With provenance Details for mobiusguard_redact-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mobiusguard-redact 0.3.0
File Interpreter ABI Platform Actions
mobiusguard_redact-0.3.0-py3-none-any.whl Python 3 none any Details for mobiusguard_redact-0.3.0-py3-none-any.whl

Total release size: 96.1 kB

Release files / mobiusguard_redact-0.3.0.tar.gz

Download URL mobiusguard_redact-0.3.0.tar.gz
Size 51.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2ad700e8c52f8c9eb0812f6df09fadfae5db3b0b2915eb9f3b1a2cd821ad76d4
BLAKE2b-256 checksum
How to use checksums
846e9468fe241d98635017606d0516b03511cbf28ce1658c7b6de4e054dbe64f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / mobiusguard_redact-0.3.0-py3-none-any.whl

Download URL mobiusguard_redact-0.3.0-py3-none-any.whl
Size 44.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c7ae24fc2be27d0f52cf28149589bf35aa11f370ec2bc062f393c90035b798e5
BLAKE2b-256 checksum
How to use checksums
43a63a649214597887188cda6ee31c01379423b61763002261d20481d01f6935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for mobiusguard-redact 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mobiusguard_redact-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

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.

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