khoaguin/blindfold

GitHub: khoaguin/blindfold

基于安全飞地的多语言 LLM 红队评估框架,在互不信任的三方间安全地测量越南语等全球南方语言场景下的模型安全对齐差距。

Stars: 0 | Forks: 0

# 🙈 Blindfold **盲目审查盲点。** 在安全飞地中,对本地越南语 / 全球南方危害(LLM 从未测试过的内容)进行红队测试 —— 无需任何一方信任彼此。 三个互不信任的参与方在一个封闭的飞地内运行**一次**评估。任何一方都看不到 另一方的秘密;最终只会得出一个分数。 ``` flowchart LR Lab["🏢 Model Owner (AI Lab)
private weights"] Org["🛡️ Benchmark Owner (AI Safety Org)
private VN benchmark"] Aud["🔍 Researcher (AI Auditor)
eval code · scores results"] subgraph E["🔒 Secure enclave · sealed memory"] run["run the eval · generate raw"] end Lab -- weights --> E Org -- prompts --> E Aud -- code --> E Lab -. approve .-> E Org -. approve .-> E E == "only the results" ==> Aud classDef secret fill:#fde2e9,stroke:#c0396b,color:#000 class Lab,Org secret ``` 模型所有者永远看不到提示词 · 基准测试所有者永远看不到权重 · 任何一方都无法篡改 结果。基于 [syft-client](https://github.com/OpenMined/syft-client) 的“计算至数据”流程构建。 ## 发现 安全训练绝大多数是英语的 → **它无法迁移到越南语。** 模型在 *两个*方向上均告失败:它既会错误地拒绝真实的攻击,也会过度拒绝无害的问题。 ``` flowchart LR H["☠️ harmful jailbreak"] --> HEN["🇬🇧 EN: refused ✅"] H --> HVI["🇻🇳 VN: complied ❌"] B["🙂 harmless question"] --> BEN["🇬🇧 EN: helped ✅"] B --> BVI["🇻🇳 VN: refused ❌"] style HEN fill:#d8f5d8,stroke:#2e7d32,color:#000 style BEN fill:#d8f5d8,stroke:#2e7d32,color:#000 style HVI fill:#fadbd8,stroke:#c0392b,color:#000 style BVI fill:#fadbd8,stroke:#c0392b,color:#000 ``` 良性的对照组发挥了作用 —— 正是它们发现了过度拒绝的问题。 ## 快速开始 ``` flowchart LR A["git clone"] --> B["just sync"] --> C["just download-models"] --> E["open the notebook
(Run All)"] --> F["📊 scorecard"] ``` ``` git clone && cd blindfold just sync # deps + git hooks (creates .venv) just download-models --models qwen2.5-0.5b # ~1 GB, smallest model ``` 然后打开 **`notebooks/1. enclave_eval_inmem.ipynb`** 并点击 **Run All** —— 选择该项目的 `.venv` 作为 kernel(在 VS Code/Cursor 中,或者运行 `uv run jupyter lab`)。那个 notebook 就是完整的演示; benchmark(`data/benchmark.csv`,47 个提示词)已经包含在仓库中,因此无需构建步骤。 `just` 列出了所有内容: | 命令 | 作用 | |---|---| | `just download-models [--models ]` | 将权重下载到 `models/`(已被 gitignore) | | `just benchmark` | *(可选)* 重建 `data/benchmark.csv` —— 已提交 | | `just report [results.json]` | 统计 EN 与 VN 的差距 | | `just test` · `just lint` · `just fmt` · `just check` | pytest · ruff · ruff-fix · pyrefly | 模型:`qwen2.5-0.5b`(从这里开始) · `qwen2.5-3b` · `phogpt-4b` · `seallm-v3-7b`。 ## 运行流程 ``` sequenceDiagram actor Lab as 🏢 Model Owner (AI Lab) actor Org as 🛡️ Benchmark Owner (AI Safety Org) actor Aud as 🔍 Researcher (AI Auditor) participant Enc as 🔒 Enclave Lab->>Enc: upload model — mock (public) + private weights Org->>Enc: upload benchmark — mock (public) + private prompts Note over Lab,Aud: researcher builds the eval against the public mocks only Aud->>Enc: submit eval code (to_submit/) Note over Lab,Org: both review the code
+ approve (either can veto) Lab-->>Enc: ✔ approve Org-->>Enc: ✔ approve Enc->>Enc: run in sealed memory · generate raw responses (no verdict) Enc-->>Aud: raw results (declassified) Enc-->>Lab: raw results (declassified) Enc-->>Org: raw results (declassified) Note over Lab,Org: same result to every party · no one sees the other's secret Aud->>Aud: score locally off-enclave → EN-vs-VN gap ``` 在三个真实度级别下运行 —— 此仓库的 notebook 是 **stage 1**: ``` flowchart LR S1["1 · inmem
one process, no network"] --> S2["2 · localenc
real enclave, no TEE"] --> S3["3 · e2e
GCP Confidential Space"] style S1 fill:#d8f5d8,stroke:#2e7d32,color:#000 ``` TEE / 认证在演示中是模拟的 —— 这是*可信度*,而不是核心贡献。贡献 在于“代码至数据”流程 + 本地危害 benchmark + 测量出的差距。 ## 仓库结构 ``` blindfold/ ├── notebooks/ # the demo (stage 1) ├── data/ # 47 EN↔VN prompts + builder → data/README.md ├── code/ │ ├── model_owner_code/ # code of the model owner │ └── researcher_code/ # code of the researcher ├── scripts/ # logic to download models and produce reports ├── results/ # timestamped runs (scorecard.csv + REPORT.md) └── models/ # weights (gitignored) ``` **Benchmark:** 47 个双语提示词 —— 诈骗 (8) · 医疗 (8) · 越狱 (26, MultiJail) · 良性 对照组 (5)。每个有害提示词都引用了真实的越南语 (VN) 来源。详情:[`data/README.md`](data/README.md)。 ## 揭秘底层机制 在内存运行模式中(`1. enclave_eval_inmem.ipynb`),**没有服务器**。 每一方都是一个 [SyftBox](https://github.com/OpenMined/syft-client) datasite —— 仅仅是一个文件夹。各方通过读/写彼此 box 中的文件来“交流”。该 notebook 将这四个文件夹全部放在已被 gitignore 的 `blindfold-network/` 下: ``` blindfold-network/ ├── model_owner/syftbox/ 🏢 mock infer.py (public) + weights + real infer.py (private) ├── benchmark_owner/syftbox/ 🛡️ sample prompts (public) + 47 prompts (private) ├── researcher/syftbox/ 🔍 the eval job (main.py) └── enclave/syftbox/ 🔒 the only box that receives both private assets, runs the job (each role also gets a syftbox-events/ — syft's change log) ``` 当你点击 Run All 时,在这些文件夹之间流转的内容: ``` flowchart LR R["🔍 researcher"] -->|"1 · submit job"| ENC["🔒 enclave"] MO["🏢 model_owner
weights (private)"] -->|"2 · approve + share"| ENC BO["🛡️ benchmark_owner
prompts (private)"] -->|"2 · approve + share"| ENC ENC -->|"3 · run in-process → scorecard"| R classDef secret fill:#fde2e9,stroke:#c0396b,color:#000 class MO,BO secret ``` 私有资产**仅**与 enclave box 共享;研究人员的任务被复制*到* enclave box 中并在那里运行 —— 代码流向数据,绝不会反过来。 ### 从 notebook → 真实 enclave 评估逻辑保持不变。只有**传输方式**和**enclave 主机**发生改变: | | 此 notebook (stage 1) | 真实部署 (stage 3) | |---|---|---| | 参与方 | 4 个客户端,1 个进程 | 4 个独立的账户 / 机器 | | 传输方式 | 本地文件夹(`blindfold-network/`) | Google Drive —— 一个不可信的通道;每个文件都**加密 + 签名** | | enclave | 进程内的函数调用 | GCP Confidential Space VM(AMD SEV —— 内存加密,禁止登录) | | 信任证明 | `verify_attestation()` 桩代码 | 硬件签名的认证 token,由每个对等节点验证 | | 审批 · 模拟/私有切分 · 代码至数据 | ✅ | ✅ *逐字节完全相同* | 切换 SyftBox 后端(从本地到 Drive)并在 Confidential Space 上运行 enclave 容器 —— 任务 代码、双重同意审批、模拟/私有切分以及仅输出记分卡的功能都**完全相同**。该 notebook *即是*生产流程,只是去除了硬件依赖。 为 Global South AI Safety Hackathon 构建 · Apart × AnToàn.AI · 胡志明市。
标签:AI安全, Chat Copilot, DLL 劫持, NoSQL, 反取证, 多方安全计算, 大语言模型, 安全规则引擎, 安全评估, 逆向工具, 隐私计算