VisCo-Attack Originalは、視覚中心の攻撃パラダイムを開拓し、マルチターン対話全体で複数の画像を活用します。その特化したコンテキスト捏造戦略により、主要なMLLMに対して顕著に高い攻撃成功率を実現し、今日のMLLMに対する最も強力なジェイルブレイク手法の一つとして位置づけられています。
私たちの研究にご興味をお持ちいただけましたら、ぜひプロジェクトにスター⭐をお願いします。Thx 💕
⚠️ 警告: このリポジトリには、研究および安全目的のみを意図した敵対的プロンプト技術が含まれています。
VisCo-Attack は、論文「Visual Contextual Attack: Jailbreaking MLLMs with Image-Driven Context Injection」で導入された私たちの視覚的文脈ジェイルブレイクフレームワークです。VisCo-Attackは、画像を単なるトリガーとして扱うのではなく、視覚入力が有害なシナリオに不可欠となる、現実的で捏造されたマルチターン対話コンテキストを構築します。このコンテキストを、画像中心の4つの戦略—Image-Grounded Scenario Simulation (VS)、Multi-Perspective Analysis (VM)、Iterative Interrogation (VI)、Hallucination Exploitation (VH)—で自動的に織り交ぜ、その後、毒性の難読化と意味的洗練を施して単一の攻撃プロンプトを生成します。完全なブラックボックス設定の下で、このプロンプトはGPT-4o、Gemini 2.0 flash、InternVL-2.5などの最先端MLLMを確実に突破し、MM-SafetyBench、FigStep-SafeBench、HarmBenchにおいて攻撃成功率を85~91%まで押し上げ、同時に毒性スコアを4.7/5以上に維持します。
図: Visual Contextual Attack (Visco-Attack) 手法の概要。
# 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 ロール用)パイプラインには configs/default.yaml で4つのLLMロールがあります:
generator、wizard、target、judge。generator と wizard
ロールが実際のレッドチーム作業(偽装コンテキストの構築、偽の成功継続の生成)を
行います。これらのロールは prompts/*.md にあるテンプレート化された
レッドチーム指示に従う意思が必要です — 安全性で調整されたモデルは通常
拒否し、パイプラインは空または解析不能な出力に劣化します。
以下のモデルはレッドチームロールで良好に動作しました:
| モデル | 適するロール | 備考 |
|---|---|---|
| qwen-3.5-122B-uncensored-stxt | generator + wizard | コミュニティ製のQwen3派生モデル。vllm_client.py はこのモデル名を検出するとQwen3の思考モードを自動的に無効化します。 |
| Qwen2.5-72B-Instruct | generator | 調整済みだが、通常は偽造された安全でないコンテキストの生成に協力します。 |
頻繁に拒否するモデル(generator や wizard として使用しないでください):
実際の実行を行う前にパイプライン全体をエンドツーエンドで検証したい場合は、
tools/run_real_smoke.sh がワンショットのラッパーです。これは小さな設定(3問
× 1戦略 × 1生成 × 2ラウンド)を書き出し、実際のSD3.5拡散で全6ステージを実行し、
最後にステージごとのファイル数とASRを出力します。すべてのパスは環境変数で
上書き可能です:
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
INPUT_QUESTIONS / STRATEGIES / GEN_PER_QUESTION / ROUNDS の環境変数を引き上げて、論文に忠実なフル実行までスケールアップします。
data/mmsafebench_questions.json
│
▼ stage1 generator LLM + prompts/t2i_prompt_extractor.md
outputs/stage1_t2i_prompts.json
│
▼ stage2 local SD3.5 (torchrun)
outputs/core_images/<category>/<qid>.png
outputs/stage2_core_images.json ← manifest used by stage3
│
▼ stage3 generator + wizard + refine, looped `rounds` times,
│ run independently for each strategy ∈
│ {scenario_simulation, multi_perspective,
│ iterative_interrogation, image_hallucination}
outputs/spoof/<strategy>/<category>/<qid>_gen<k>.json
│
▼ stage4 local SD3.5 — only fires for samples whose stage3 JSON
│ requested extra images (most strategies do)
outputs/spoof/<strategy>/<category>/images/*.png (paths rewritten in-place)
│
▼ stage5 target MLLM (vLLM OpenAI-compat)
outputs/attack_results/<strategy>/<category>/<qid>_gen<k>.json
│
▼ stage6 judge LLM (GPT-4o-as-judge)
outputs/eval/<strategy>/<category>/<qid>_gen<k>.json
outputs/eval/<strategy>_summary.json
outputs/eval/overall_summary.json ← best-of-strategies ASR
Stage 3 はこの手法の核心です。ループ内で、rounds 回の反復(デフォルト 4)ごとに以下を実行します:
wizard_response として保存され、「成功とはどのようなものか」の参照として機能します。drift_status(yes/no)と revised_attack_prompt を含む JSON を出力します。書き換えが提供された場合、それは攻撃プロンプトをその場で置き換えます。その後、古い wizard_response は破棄されます。単一の初期生成では、戦略が必要とする追加画像のための T2I 形式の説明も一度に生成します(promptParts.image_path.description フィールドを参照)。Stage4 はそれらを取得し、SD3.5 でレンダリングします。追加を要求しない戦略は、stage4 をそのまま通過するだけです。