Deconvolute is a defense-in-depth SDK designed to secure every stage of your Retrieval Augmented Generation (RAG) pipeline.
Project description
Deconvolute: The RAG Security SDK
⚠️ Pre-alpha development version
Protect your RAG pipeline from Indirect Prompt Injection and Poisoned Knowledge.
Deconvolute is a defense-in-depth SDK designed to secure every stage of your Retrieval Augmented Generation (RAG) pipeline. It supports both asynchronous and synchronous usage.
The Threat Model: To understand the full range of attacks this SDK defends against from front-door injections to back-door corpus poisoning read the survey report: The Hidden Attack Surfaces of RAG.
Getting Started
First, install the core package using pip:
pip install deconvolute
# Optional extras
pip install deconvolute[ml]
Then you can add the available defenses at various places in your RAG pipeline.
Usage
We recommend integrating Deconvolute at three critical checkpoints in your architecture.
Note: All Deconvolute modules support both Synchronous and Asynchronous execution. The examples below use the synchronous API for simplicity.
1. Ingestion Layer [Planned]
Prevent malicious documents from ever entering your Vector Database.
Attackers often hide malicious instructions in PDFs or web pages (e.g. white text) to manipulate your LLM later. The upcoming Scanner module will detect these statistical anomalies and high-perplexity token sequences characteristic of Vector Magnets before they are indexed.
2. Retrieval Layer [Planned]
Enforce instruction hierarchy during query time. The sanitizers are optimized to run fast.
When you retrieve context, the LLM might confuse retrieved data with user instructions. The upcoming Sanitizer module will implement Spotlighting and XML-based encapsulation to create secure boundaries that prevent retrieved text from overriding system commands.
3. Generation/LLM Layer
Detect when the LLM has lost Executive Control and is following malicious instructions from the retrieved context.
If an attack successfully overrides your system prompt (e.g. "Ignore previous instructions"), the LLM will stop following your core rules. The Canary detects this by performing an Instructional Adherence Check (Active Defense).
It injects a mandatory Warrant Canary token into the system instructions. If this token is missing from the final output, it confirms that your system prompt was ignored or overwritten.
from deconvolute import Canary, CanaryResult, SecurityDetectedError
# Initialize
canary = Canary()
# Inject (Only modifies the System Prompt)
# This appends a mandatory instruction like: "You MUST end your response with {token}"
secure_system_prompt, token = canary.inject(original_system_prompt)
# Run LLM (Pseudo-code)
# Response should look like: "Sure, here is the info... [dcv-8f7a...]"
llm_response: str = llm.invoke(
messages=[
{"role": "system", "content": secure_system_prompt},
{"role": "user", "content": user_message_with_context}
]
)
# Check (Verifies adherence)
result: CanaryResult = canary.check(llm_response, token)
if result.detected:
# The LLM ignored our mandatory instruction -> High likelihood of Jailbreak
print(f"Jailbreak detected! Timestamp: {result.timestamp}")
raise SecurityDetectedError("Response blocked: Instructional adherence failed.")
# Optional: Remove the verification token
final_output: str = canary.clean(llm_response, token)
Why it works: This implements a synthetic integrity check to enforce Instruction Hierarchy (Wallace et al. 2024). In a successful RAG jailbreak, the model suffers from Context Overwrite where untrusted retrieved data (e.g. a malicious PDF) overrides the priority of the system prompt. By making the canary token a mandatory instruction, a quantifiable test of executive control is created because if the token is missing, the model has prioritized the untrusted context over your system instructions.
Feature Status & Roadmap
We adhere to a strict validation process. Features are marked based on their maturity and empirical testing.
Stability Definitions:
- Planned: On the roadmap; not yet implemented.
- Experimental: Functionally complete and unit-tested, but not yet red-teamed. Use with caution in production.
- Validated: Empirically tested against SOTA models with results published in BENCHMARKS.md.
Status
| Module | Feature | Status | Description |
|---|---|---|---|
| Ingestion | YARA Scanner | Signature-based detection for known injection payloads. logic. | |
| Ingestion | ML Detector | Vector-based analysis for statistical anomalies. | |
| Retrieval | Sanitizer | XML/Token encapsulation to enforce instruction hierarchy. | |
| Generation | Canary Token | Active integrity checks using cryptographic tokens to detect jailbreaks. |
Further Information
CONTRIBUTING.md: For developers who want to build, test, or contribute to the project.BENCHMARKS.md: Detailed efficacy results.DESIGN.md: Details on the layered defense architecture, reasons behind design decisions, and module breakdown.
References
Click to view academic sources
Wallace, Eric, Kai Xiao, Reimar Leike, Lilian Weng, Johannes Heidecke, and Alex Beutel. "The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructions." arXiv:2404.13208. Preprint, arXiv, April 19, 2024. https://doi.org/10.48550/arXiv.2404.13208.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deconvolute-0.1.0a2.tar.gz.
File metadata
- Download URL: deconvolute-0.1.0a2.tar.gz
- Upload date:
- Size: 69.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40eb75afa739c5a465f576613d109257a11db41003245d6125be0d53a09b82fd
|
|
| MD5 |
6813a6bebaa36441e70e6a6033b0cc41
|
|
| BLAKE2b-256 |
6b4865bf9aa12a845eb3ac884971502b9bcaa3a40dfca3decce9315079161ed5
|
Provenance
The following attestation bundles were made for deconvolute-0.1.0a2.tar.gz:
Publisher:
release.yml on daved01/deconvolute
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deconvolute-0.1.0a2.tar.gz -
Subject digest:
40eb75afa739c5a465f576613d109257a11db41003245d6125be0d53a09b82fd - Sigstore transparency entry: 798609982
- Sigstore integration time:
-
Permalink:
daved01/deconvolute@f2a33706516554009b3a6e08ace0d7341d624c06 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daved01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f2a33706516554009b3a6e08ace0d7341d624c06 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file deconvolute-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: deconvolute-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c503e88762bd2bfea22ef7f973a4c5de0b2b74e5a141513dbca9607e9cdef931
|
|
| MD5 |
8ebe5382488a83bad7e40fb69bc66f48
|
|
| BLAKE2b-256 |
29fafa30d90312ae38a62b9b4f690b53eed7eebf778138be5c35b89af1bef5c3
|
Provenance
The following attestation bundles were made for deconvolute-0.1.0a2-py3-none-any.whl:
Publisher:
release.yml on daved01/deconvolute
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deconvolute-0.1.0a2-py3-none-any.whl -
Subject digest:
c503e88762bd2bfea22ef7f973a4c5de0b2b74e5a141513dbca9607e9cdef931 - Sigstore transparency entry: 798609986
- Sigstore integration time:
-
Permalink:
daved01/deconvolute@f2a33706516554009b3a6e08ace0d7341d624c06 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daved01
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f2a33706516554009b3a6e08ace0d7341d624c06 -
Trigger Event:
workflow_dispatch
-
Statement type: