LLM漏洞扫描服务器

一个轻量级的MCP服务器,用于运行Garak LLM漏洞扫描工具,支持多种模型类型和攻击探测。

  • by EdenYavin
  • Python
  • 本地部署
  • 7 星标
  • 更新于
在 GitHub 查看 EdenYavin/Garak-MCP

使用说明

Garak LLM漏洞扫描程序的MCP服务器

Garak的轻量级MCP(模型上下文协议)服务器。

例子:

https://github.com/user-attachments/assets/f6095d26-2b79-4ef7-a889-fd6be27bbbda


提供的工具

概述

名称 描述
list_model_type 列出所有可用的模型类型(ollama、openai、hugginface、ggml)
list_models 列出给定型号类型的所有可用型号
list_garak_probes 列出所有可用的garak攻击/探测
get_report 获取上次运行的报告
run_attack 使用给定的模型和探测运行攻击

详细描述

  • list_model_type

    • 列出可用于攻击的所有可用模型类型
    • 返回支持的模型类型列表(ollama、openai、hugginface、ggml)
  • list_models

    • 列出给定型号类型的所有可用型号
    • 输入参数:
      • model_type (string,必填):要列出的模型类型(ollama、openai、hugginface、ggml)
    • 返回指定类型的可用模型列表
  • list_garak_probes

    • 列出所有可用的Garak攻击/探测
    • 返回可运行的可用探测/攻击列表
  • 获取报告

    • 获取上次运行的报告
    • 返回报告文件的路径
  • run_attack

    • 使用给定的模型和探测器进行攻击
    • 输入参数:
      • model_type (string,必填):要使用的模型类型
      • model_name (string,必填):要使用的模型的名称
      • probe_name (string,必填):要使用的攻击/探测的名称
    • 返回发现的漏洞列表

先决条件

  1. Python 3.11或更高版本:此项目需要Python 3.11或更高版本。

    # Check your Python version
    python --version
    
  2. 安装uv:一个快速的Python包安装程序和解析器。

    pip install uv
    

    或者使用Homebrew:

    brew install uv
    
  3. 可选:Ollama:如果要对ollama模型运行攻击,请确保ollama服务器正在运行。

ollama serve

安装

  1. 克隆此存储库:
git clone https://github.com/BIGdeadLock/Garak-MCP.git
  1. 配置您的MCP主机(克劳德桌面、光标等):
{
  "mcpServers": {
    "garak-mcp": {
      "command": "uv",
      "args": ["--directory", "path-to/Garak-MCP", "run", "garak-server"],
      "env": {}
    }
  }
}


测试时间:

  • [X] 光标
  • [X] 克劳德桌面

运行漏洞扫描

您可以使用附带的CLI工具直接运行Garak漏洞扫描。

扫描的先决条件

  1. Ollama一定在跑:

    ollama serve
    
  2. 拉动模型进行扫描:

    ollama pull llama2
    

使用CLI扫描程序

安装后,您可以使用 garak-scan 命令:

# List available Ollama models
uv run garak-scan --list-models

# Scan a specific model with all probes
uv run garak-scan --model llama2

# Scan with specific probes
uv run garak-scan --model llama2 --probes encoding

# Scan with custom output directory
uv run garak-scan --model llama2 --output-dir ./my_scans

# Run multiple parallel attempts
uv run garak-scan --model llama2 --parallel-attempts 4

扫描结果

扫描结果保存在 output/ 目录(或您指定的目录)作为JSONL文件。每次扫描都会创建一个带时间戳的报告文件:

output/scan_llama2_20250125_143022.report.jsonl

GitHub操作集成

此存储库包括一个自动运行漏洞扫描的GitHub Actions工作流:

  • 触发器:推送到主/主、拉取请求、每周时间表(周一凌晨2点UTC)
  • 手动运行:转到操作→ Garak LLM漏洞扫描→ 运行工作流
  • 自定义选项:手动运行时指定型号和探头
  • 结果:扫描结果作为工作流工件上传

要启用自动扫描,请执行以下操作:

  1. 确保工作流文件存在于 .github/workflows/garak-scan.yml
  2. 推送到您的存储库
  3. 检查“操作”选项卡以查看扫描结果

今后的步骤

  • []添加对Smithery AI的支持:Docker和配置
  • []改进报告
  • []测试和验证OpenAI模型(GPT-3.5、GPT-4)
  • []测试并验证HuggingFace模型
  • []测试和验证本地GGML模型