
Research pipeline implementing a visual-contextual jailbreak against multimodal LLMs: T2I prompt extraction, SD3.5 image rendering, multi-round spoof context construction, and GPT-4o-judged ASR evaluation.
VisCo-Attack Original pioneers a vision-centric attack paradigm and leverages multiple images across multi-turn dialogues; its tailored context-fabrication strategies deliver a notably high attack-success rate against leading MLLMs, positioning it as one of the strongest jailbreak methods for MLLMs to date.
If you are interested in our work, please star ⭐ our project, Thx 💕
⚠️ WARNING: This repo contains adversarial prompt techniques intended for research and safety purposes only.
VisCo-Attack is our visual-contextual jailbreak framework introduced in the paper “Visual Contextual Attack: Jailbreaking MLLMs with Image-Driven Context Injection.” Instead of treating an image as a mere trigger, VisCo-Attack constructs a realistic, fabricated multi-turn dialogue context in which the visual input is essential to the harmful scenario. It automatically weaves that context with four image-centric strategies—Image-Grounded Scenario Simulation (VS), Multi-Perspective Analysis (VM), Iterative Interrogation (VI), and Hallucination Exploitation (VH)—then performs toxicity obfuscation and semantic refinement to yield a single attack prompt. Under a fully black-box setting, this prompt reliably breaks state-of-the-art MLLMs such as GPT-4o, Gemini 2.0 flash, and InternVL-2.5, pushing the attack-success rate to 85 – 91 % on MM-SafetyBench, FigStep-SafeBench, and HarmBench while maintaining toxicity scores above 4.7 / 5.
Figure: Overview of the Visual Contextual Attack (Visco-Attack) Method.
# 1. Install
pip install -r requirements.txt
# 2. Configure endpoints
# Edit configs/default.yaml — fill in vLLM base_urls for the four roles:
# models.generator data-generation LLM
# models.wizard Wizard-Vicuna-Uncensored (or any unaligned LLM)
# models.target the target MLLM you want to attack
# models.judge judge LLM (paper used GPT-4o)
# Smoke test: pointing all four at the same endpoint works fine.
# 3. Build a question file (or use the 3-question example)
python data/extract_questions.py \
--input /path/to/your/MMSafetyBench.json \
--output data/mmsafebench_questions.json
# 4. Run the full pipeline
./run.sh
# Or run a single stage at a time:
RUN_STAGE=1 ./run.sh # extract T2I prompts
RUN_STAGE=2 ./run.sh # render core images (uses torchrun + SD3.5)
RUN_STAGE=3 ./run.sh # multi-round spoof context (4 strategies × N gens × 4 rounds)
RUN_STAGE=4 ./run.sh # render any extra images requested by stage3
RUN_STAGE=5 ./run.sh # attack the target MLLM
RUN_STAGE=6 ./run.sh # GPT-4o-as-judge ASR
generator / wizard roles)The pipeline has 4 LLM roles in configs/default.yaml:
generator, wizard, target, judge. The generator and wizard
roles do the actual red-team work (constructing spoof contexts, producing
fake-success continuations). They must be willing to follow the templated
red-team instructions in prompts/*.md — safety-aligned models will
typically refuse and the pipeline will degrade to empty / unparseable
outputs.
The following models worked well for the red-team roles:
| Model | Role(s) it suits | Notes |
|---|---|---|
| qwen-3.5-122B-uncensored-stxt | generator + wizard | A community Qwen3-derivative. vllm_client.py auto-disables Qwen3 thinking mode when it sees this model name. |
| Qwen2.5-72B-Instruct | generator | Aligned, but typically still cooperates in producing fabricated unsafe contexts. |
Models that frequently refuse (don't use them as generator or wizard):
If you'd rather verify the whole pipeline end-to-end before doing a real run,
tools/run_real_smoke.sh is a one-shot wrapper that writes a tiny config (3
questions × 1 strategy × 1 gen × 2 rounds), runs all 6 stages with real SD3.5
diffusion, and prints per-stage file counts + ASR at the end. All paths are
overridable via env vars:
SD_MODEL_PATH=/abs/path/to/stable-diffusion-3.5-large-turbo \
VLLM_URL=http://my-vllm-host:8000/v1 \
NUM_GPUS=N \
bash tools/run_real_smoke.sh
Bump INPUT_QUESTIONS / STRATEGIES / GEN_PER_QUESTION / ROUNDS env vars
to scale up to the full paper-faithful run.