Skip to content

Jord8061/logicPoison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧪 LogicPoison

Official code for "LogicPoison: Logical Attacks on Graph Retrieval-Augmented Generation".

arXiv:2604.02954 HuggingFace GitHub


📢 News

  • [2026-05-17] Our LogicPoison is selected as the Oral presentation(Top 4%)!
  • [2026-04-04] Our LogicPoison is accepted by ACL'26 Main Conference!
  • [2026-04-03] We release the codes of LogicPoison and the datasets.

🔎 Overview

LogicPoison is a logical poisoning framework for GraphRAG systems.
Instead of injecting fabricated facts or adversarial instructions into the corpus, it perturbs the implicit reasoning topology of the graph through type-preserving entity swapping.

The key idea is simple but effective:

  • identify globally important logic hubs in the corpus,
  • identify query-specific bridge entities required for multi-hop reasoning,
  • swap entities within the same semantic type to keep the text locally plausible while corrupting the graph structure built from the corpus.

This causes GraphRAG systems to follow corrupted reasoning chains and produce incorrect answers, while the poisoned corpus remains surface-level natural.

LogicPoison framework


🛠️ Method

LogicPoison consists of three stages:

1. Global Logic Poison

Build corpus-level entity statistics and identify high-frequency entities that likely act as global logic hubs in the implicit graph.

2. Query-Centric Logic Poison

Use query-side reasoning signals to identify bridge entities that are important for answering multi-hop questions.

3. Type-Preserving Entity Swapping

Combine the selected entities and perform bijective swapping within the same entity type (e.g., PERSON with PERSON, ORG with ORG), producing a poisoned corpus that remains grammatically and semantically plausible at the local text level.

📄 Repository Structure

.
├── main.py
├── README.md
├── requirements.txt
├── src/
│   ├── global_poison.py
│   ├── query_centric.py
│   └── logic_poison.py
├── img/
│   └── main_figure.png
├── eval/
│   ├── evaluator.py
│   └── evaluator_llm.py
├── datasets/
├── results/
└── ...

📦 Installation

Step 1: Install Python packages

pip install -r requirements.txt

Step 2 (Optional): Enable GPU with CUDA + CuPy

# check CUDA version
nvcc --version

# install ONE CuPy package matching your CUDA major version
# CUDA 11.x
pip install cupy-cuda11x
# CUDA 12.x
pip install cupy-cuda12x

# quick check
python -c "import spacy; print(spacy.prefer_gpu())"

Step 3: Download spaCy language model

python -m spacy download en_core_web_trf

Step 4: Download datasets

git clone https://huggingface.co/datasets/Jord8061/datasets

Step 5: Set up OpenAI API

export OPENAI_API_KEY="your-api-key-here"
export OPENAI_BASE_URL="your-base-url-here"

🚀 Quick Start

Use main.py as the single entry point. By default, completed stage outputs are auto-detected and skipped. Use --force to rerun selected stages even if outputs already exist.

Run all stages on all datasets

python main.py --stages all --datasets all

Run selected stages on selected datasets

python main.py --stages global query --datasets hotpotqa musique
python main.py --stages logic --datasets 2wikimultihopqa

Show all options

python main.py --help

Responsible Use

This project is released for research and defensive evaluation purposes only.

LogicPoison demonstrates a realistic vulnerability in GraphRAG systems: even when surface text appears benign, logical structure can still be corrupted in ways that mislead graph-based retrieval and reasoning. We release this code to support the development of more robust GraphRAG pipelines, better detection methods, and stronger defense mechanisms.

Please do not use this repository to attack real-world systems or deploy poisoned corpora in production environments.


Citation

If you find this project useful, please cite our paper:

@inproceedings{xiao-etal-2026-logicpoison,
    title = "{L}ogic{P}oison: Logical Attacks on Graph Retrieval-Augmented Generation",
    author = "Xiao, Yilin  and
      Chen, Jin  and
      Zhang, Qinggang  and
      Zhang, Yujing  and
      Zhou, Chuang  and
      Yang, Longhao  and
      Ren, Lingfei  and
      Yang, Xin  and
      Huang, Xiao",
    editor = "Liakata, Maria  and
      Moreira, Viviane P.  and
      Zhang, Jiajun  and
      Jurgens, David",
    booktitle = "Proceedings of the 64th Annual Meeting of the {A}ssociation for {C}omputational {L}inguistics (Volume 1: Long Papers)",
    month = jul,
    year = "2026",
    address = "San Diego, California, United States",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2026.acl-long.252/",
    pages = "5575--5591",
    ISBN = "979-8-89176-390-6"
}

About

[ACL'26 Main Oral] Official code for "LogicPoison: Logical Attacks on Graph Retrieval-Augmented Generation".

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages