asmit dash
Open-source library

redoubt

Open source · shipped to PyPI

Corpus prompt-injection scanner.

What it is

A static prompt-injection scanner for RAG corpora. Catches jailbreak signatures, encoded payloads, hidden instructions, and role-play inducements before they land in the vector index - so a malicious chunk never gets retrieved. redoubt addresses OWASP LLM01:2025 (prompt injection) for the indirect, retrieved-content vector specifically; it does not call any LLM, hit any network, or block runtime requests. Sub-second on 100k chunks.

Why it's needed

Every retrieved document becomes a new attack surface. A malicious chunk can override the system prompt, install a developer-mode persona, smuggle a base64-encoded jailbreak, hide zero-width-unicode directives, or spoof system tags. Runtime guard rails fire after the model has read the chunk; redoubt scans the corpus before indexing.

What it does

redoubt detects eight attack patterns: instruction-override directives, role-play / persona escapes, system / authority impersonation, encoded payloads (base64, hex, unicode-escape, rot13) that decode to injection text, exfiltration patterns, hidden / invisible characters, tool-call spoofing, and markdown link cloaking. Critical findings flip report.ok() to False; warnings let ok() stay True but should be reviewed. report.cleaned_chunks(chunks) drops anything flagged critical so you can index the safe remainder.

How to use it

Install it:

pip install redoubt

Then call it:

import redoubt

report = redoubt.check_corpus(chunks)
print(report)

if not report.ok():
    raise SystemExit("Sanitize the flagged chunks before indexing.")

# Or drop them automatically:
clean = report.cleaned_chunks(chunks)

Links