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.
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.
- Guide, pattern list and limits
- How streaming redaction works (decision 0007)
- Changelog · Security policy
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mobiusguard_redact-0.3.1.tar.gz | 51.3 kB | With provenance | Details for mobiusguard_redact-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mobiusguard_redact-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for mobiusguard_redact-0.3.1-py3-none-any.whl |
Total release size: 96.1 kB
Release files / mobiusguard_redact-0.3.1.tar.gz
| Download URL | mobiusguard_redact-0.3.1.tar.gz |
|---|---|
| Size | 51.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7b98365b6ea458a7388604435c06cc1aa52714cae1b2aa72d51637cdbc6659c
|
|
BLAKE2b-256 checksum How to use checksums |
583f480255b20693c5fa6669a68b56debb5d04b2edcfe877f06a402985790c5f
|
| 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 30, 2026.
Transparency logRelease files / mobiusguard_redact-0.3.1-py3-none-any.whl
| Download URL | mobiusguard_redact-0.3.1-py3-none-any.whl |
|---|---|
| Size | 44.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67efcc270538e66b701f5f9cce09234561040c4a2e91f6ec4b1cea3273aa8418
|
|
BLAKE2b-256 checksum How to use checksums |
e02c37b2f24b6d0aac6150f5148e22cafe2fd444f61772eca85873de8b4a8f5f
|
| 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 30, 2026.
Transparency logSecurity for mobiusguard-redact 0.3.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mobiusguard_redact-0.3.1.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 30, 2026.
Transparency logA 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.