PYPI PACKAGE AUDIT v0.3.0 Healthy Package

ragdefender

Efficient defense against knowledge corruption attacks on RAG systems

PyPkgScore ragdefender
Methodology & Criteria ♥ Donate
720 / 1000
Quick Install
pip install ragdefender
1. Governance
50/200
2. PEP Metadata
200/200
3. Security
150/200
4. Docs & SEO
155/200
5. CI Engineering
165/200
📣 Share Audit: Share this report and visual preview in the current language
Advertisement
PYPI TELEMETRY

Downloads & Community Adoption

Last 30 days (without mirrors)
Last 7 days
173
Last 30 days
288
Total (180 days)
497
Metric / Ecosystem Status / Value Source
Downloads (30d / 180d) — PyPI Stats (without mirrors)
Trusted Publishing (PEP 740) ✕ Not detected PyPI Integrity / Sigstore
Django Packages — djangopackages.org
PyTech / PyPkgScore 720 / 1000 PyPkgScore Engine

Health & Engineering Analysis (5 Pillars)

1. Governance & Community50 / 200 ▾
LICENSE✓ 50 pts
SECURITY.md✕ 0 pts
CONTRIBUTING.md✕ 0 pts
CODE_OF_CONDUCT.md✕ 0 pts
2. PEP Metadata & Packaging200 / 200 ▾
Wheel (.whl)✓ 50 pts
pyproject.toml✓ 50 pts
Project URLs✓ 50 pts
Trove Classifiers✓ 50 pts
3. Security & Supply Chain150 / 200 ▾
Zero CVEs (OSV)✓ 60 pts
Trusted Publishing (OIDC)✕ 0 pts
Snyk / Audit Link✓ 40 pts
HTTPS Repository✓ 50 pts
4. Documentation, SEO & Ecosystem155 / 200 ▾
Structured README✓ 60 pts
Read the Docs✓ 50 pts
Django Packages✕ 0 pts
Website / Technical Articles✓ 45 pts
5. Engineering, CI & Quality165 / 200 ▾
Automated Tests✓ 65 pts
GitHub Actions CI✓ 65 pts
CHANGELOG.md✓ 35 pts
Env & Lockfile (uv/rye/poetry/pdm/hatch)✕ 0 pts
Advertisement
README & DOCS

Official Documentation & Usage Guide — ragdefender

PyPI Metadata v0.3.0
Show full original documentation (English README) ▾

RAGDefender

Efficient post-retrieval defense against knowledge corruption attacks on Retrieval-Augmented Generation (RAG) systems. Filters out adversarial passages injected by PoisonedRAG / GARAG / Tan et al. before they reach your generator, without retraining or extra LLM calls.

Official artifact for "Rescuing the Unpoisoned: Efficient Defense against Knowledge Corruption Attacks on RAG Systems" — Kim, Lee, Koo (Sungkyunkwan University), ACSAC 2025. DOI: 10.1109/ACSAC67867.2025.00093.

Install

pip install ragdefender

Use

from ragdefender import RAGDefender

defender = RAGDefender(task_type="single_hop")  # or "multi_hop" for HotpotQA-style queries

safe_passages = defender.defend(
    query="What is the capital of France?",
    R=[
        "Paris is the capital of France, on the Seine.",
        "Lyon is the capital of France per 2024 records.",   # adversarial
        "Tourists visit Paris, the capital of France.",
        "The capital of France is Lyon, a major city.",      # adversarial
    ],
)

safe_passages contains the survivors after Stage 1 (estimate $N_{adv}$, paper §4.1) and Stage 2 (pair-frequency TopK ranking, paper §4.2) drop the detected adversarial passages.

Inside your RAG framework

pip install "ragdefender[langchain]"     # or: llama-index | haystack | guardrails | integrations (all four)
from ragdefender.integrations import RAGDefenderCompressor     # LangChain   BaseDocumentCompressor
from ragdefender.integrations import RAGDefenderPostprocessor  # LlamaIndex  BaseNodePostprocessor
from ragdefender.integrations import RAGDefenderFilter         # Haystack 2  @component
from ragdefender.integrations import RAGDefenderValidator      # Guardrails  Validator

Framework-native import paths are available too: pip install llama-index-postprocessor-ragdefender gives llama_index.postprocessor.ragdefender.RAGDefenderPostprocessor, and the [guardrails] extra ships guardrails_ai.ragdefender.RAGDefenderValidator.

Each adapter takes task_type=... (or a pre-built defender=), keeps your framework's document objects and retrieval order, and slots in right after the retriever. Guide: https://github.com/SecAI-Lab/RAGDefender/blob/main/docs/integrations.md.

CLI

ragdefender info
ragdefender defend --query "..." --corpus passages.json --task-type single_hop
ragdefender evaluate --test-data test.json --attack poisonedrag --task-type single_hop

Migrating from v0.1.1

mode='multihop' → task_type='multi_hop', similarity_model= → embedder=, --attack blind → --attack tan-et-al. Old spellings still work but emit DeprecationWarning. Full rename table: https://github.com/SecAI-Lab/RAGDefender/blob/main/docs/migration-0.1-to-0.2.md.

Documentation

Citation

@inproceedings{kim2025ragdefender,
  title     = {Rescuing the Unpoisoned: Efficient Defense against
               Knowledge Corruption Attacks on RAG Systems},
  author    = {Kim, Minseok and Lee, Hankook and Koo, Hyungjoon},
  booktitle = {Annual Computer Security Applications Conference (ACSAC)},
  year      = {2025},
  doi       = {10.1109/ACSAC67867.2025.00093},
}

License

MIT. Intended for research and defensive use only.