AshwinNHacker/side-channel-honeypot

GitHub: AshwinNHacker/side-channel-honeypot

面向多租户GPU/VRAM环境的多语言欺骗安全框架,通过故意延迟内存清零构建「蜜罐窗口」,用AI生成的虚假数据检测并中和侧信道攻击。

Stars: 1 | Forks: 0

# 🛡️ 侧信道蜜罐与欺骗矩阵 [![Rust](https://img.shields.io/badge/Rust-1.75+-orange?logo=rust)](https://www.rust-lang.org/) [![Python](https://img.shields.io/badge/Python-3.11+-blue?logo=python)](https://www.python.org/) [![Go](https://img.shields.io/badge/Go-1.21+-00ADD8?logo=go)](https://golang.org/) [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-3178C6?logo=typescript)](https://www.typescriptlang.org/) [![License](https://img.shields.io/badge/License-MIT%2FApache--2.0-green.svg)](LICENSE) [![Security](https://img.shields.io/badge/Security-Research-red)](SECURITY.md) ## 📖 目录 - [概述](#overview) - [架构](#architecture) - [欺骗策略](#the-deception-strategy) - [模块](#modules) - [快速开始](#quick-start) - [API 参考](#api-reference) - [研究背景](#research-background) - [贡献](#contributing) - [许可证](#license) ## 🎯 概述 **侧信道蜜罐与欺骗矩阵** 是一个生产级的多语言安全框架,它将被动的内存保护转变为**主动欺骗工程**。专为多租户 GPU/VRAM 环境(云端 AI 推理、模型服务平、机密计算)构建,它通过向攻击者提供看似真实但完全虚假的数据,同时启动应急响应,从而检测并中和侧信道攻击。 ### 关键创新:蜜罐窗口 传统的内存安全方法在内存释放时会立即将其清零。我们**故意延迟清零**以创建一个受控的漏洞利用窗口——即**蜜罐窗口**——在此期间,任何对“已释放”内存的访问都必定是恶意的。我们不会崩溃或返回垃圾数据,而是提供** honey-token **:由 AI 生成的虚假 API key、模型权重和凭据,它们看起来足够真实以欺骗攻击者,但实际上毫无用处。 ### 中和的攻击向量 | 攻击向量 | 检测方法 | 欺骗响应 | |--------------|------------------|-------------------| | **Use-After-Free** | 内存状态 = `Released` | 带有追踪信标的虚假模型权重 | | **Heap Spraying** | 快速连续分配 | 投毒的内存模式 | | **Timing Side-Channel** | 重复访问 + 睡眠模式 | 可变延迟的虚假数据 | | **Rowhammer Variant** | 激进的行访问 | 看似损坏但无害的数据 | | **Container Escape** | 跨租户内存访问 | 反情报 payload | ## 🏗️ 架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ TENANT CONTAINERS │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │Tenant A │ │Tenant B │ │Tenant C │ │ATTACKER │ │ │ │ (Legit) │ │ (Legit) │ │ (Legit) │ │(Malicious)│ │ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ │ │ └────────────┴────────────┴────────────┘ │ │ │ │ │ ┌──────────▼──────────┐ │ │ │ VRAM MANAGER │ │ │ │ (Rust Core — Zero │ │ │ │ Cost Abstractions)│ │ │ └──────────┬──────────┘ │ │ │ │ │ ┌───────────────┼───────────────┐ │ │ │ │ │ │ │ ▼ ▼ ▼ │ │ ┌────────┐ ┌──────────┐ ┌──────────┐ │ │ │NORMAL │ │ RELEASED │ │ ZEROED │ │ │ │READ │ │ BLOCK │ │ BLOCK │ │ │ │(OK) │ │ │ │ │ │ │ └────────┘ │ ┌──────┐ │ └──────────┘ │ │ │ │HONEY │ │ │ │ │ │POT │ │◄── HONEYPOT WINDOW │ │ │ │TRAP │ │ (5-30 seconds) │ │ │ └──────┘ │ │ │ └────┬─────┘ │ │ │ │ │ ┌─────────▼──────────┐ │ │ │ 🍯 HONEYPOT LAYER │ │ │ │ │ │ │ │ • ML-Generated Fake │ │ │ │ API Keys │ │ │ │ • Poisoned Model │ │ │ │ Weights │ │ │ │ • Fake Credentials │ │ │ │ • Tracking Beacons │ │ │ └─────────┬───────────┘ │ │ │ │ │ ┌──────────────┼──────────────┐ │ │ │ │ │ │ │ ▼ ▼ ▼ │ │ ┌────────┐ ┌──────────┐ ┌──────────┐ │ │ │Python │ │ Go │ │TypeScript│ │ │ │ML/ML │ │ Daemon │ │Dashboard │ │ │ │Engine │ │(Zeroing &│ │(Real-time│ │ │ │(PyTorch)│ │ Metrics) │ │ Viz) │ │ │ └────────┘ └──────────┘ └──────────┘ │ └─────────────────────────────────────────────────────────────────┘ ``` ## 🧠 欺骗策略 ### 1. 行为分析 (Python) 系统为每个 PID 维护一个内存访问模式的滑动窗口。通过序列分析,它可以检测到: - **顺序抓取**:以可预测的增量读取地址 - **Heap Spray 检测**:快速分配模式 - **Use-After-Free 探测**:访问最近释放的区域 - **Timing Side-Channel**:带有故意延迟的重复访问 ### 2. 自适应欺骗模式 基于威胁评分 (0.0–1.0),系统会选择一种欺骗策略: | 威胁评分 | 模式 | 描述 | |-------------|------|-------------| | 0.0–0.2 | **PASSIVE** | 带有基本日志记录的标准 honey-token | | 0.2–0.5 | **ACTIVE** | 虚假数据 + 完整日志记录 + 追踪信标 | | 0.5–0.8 | **ADAPTIVE** | 由 ML 生成的逼真数据 (DefenderGAN) | | 0.8–1.0 | **COUNTERINTEL** | 用于破坏攻击者 ML 模型的投毒数据 | ### 3. Honey-Token 类型 - **API Key**:结构有效但无功能的 key (OpenAI, Anthropic, AWS, GCP, Azure, HuggingFace, GitHub) - **模型权重**:高斯分布的张量,看起来像真实的 transformer 权重,但在数学上毫无用处 - **凭据**:带有虚假密码的逼真数据库连接字符串 - **通用数据**:格式化为匹配预期内存模式的随机字节 ### 4. 追踪信标 每个 honey-token 都包含一个**隐写信标**——一种隐藏的标识符,允许我们检测该 token 是否被窃取并在其他地方使用(例如,发布到 Pastebin、用于 API 调用,或在攻击者的基础设施中发现)。 ## 📦 模块 ### 🔧 Rust 核心 (`rust_core/`) **目的**:零开销且内存安全的 VRAM 引擎,带有 FFI 导出 ``` // The critical honeypot method pub fn read_unsafe( &self, caller_pid: u32, caller_tenant_id: &str, addr: usize, size: usize, ) -> Result, String> { // If block.state == Released -> trigger_honeypot() // Return realistic fake data + fire incident } ``` **主要特性**: - 设计上保证内存安全(Rust 所有权系统) - 零开销抽象——正常操作无运行时开销 - 用于 Python/Go 集成的 FFI 导出 - 使用 `RwLock` + `Mutex` 进行并发块管理 - SHA-256 完整性追踪 **构建**: ``` cd rust_core cargo build --release cargo test ``` ### 🐍 Python 蜜罐 (`python_honeypot/`) **目的**:带有对抗性防御的 ML 驱动欺骗引擎 **主要特性**: - **DefenderGAN**:用于生成逼真 honey-token 的对抗性生成器 - **BehavioralAnalyzer**:基于序列的攻击模式检测 - **HoneyTokenFactory**:上下文感知的虚假数据生成 - **DeceptionEngine**:具有自适应策略的主编排器 **构建**: ``` cd python_honeypot pip install -r requirements.txt python -m pytest tests/ ``` ### 🐹 Go Daemon (`go_daemon/`) **目的**:高性能清零引擎、指标和 API **主要特性**: - 具有可配置间隔的并发清零循环 - Prometheus 指标导出(`honeypot_*` 计数器和直方图) - 用于块管理和事件查询的 REST API - 带有隔离触发器的事件响应处理器 - 适用于内核集成的 eBPF 就绪架构 **构建**: ``` cd go_daemon go mod tidy go build -o honeypot-daemon go test ./... ``` ### ⚛️ TypeScript 仪表盘 (`typescript_dashboard/`) **目的**:实时安全可视化 **主要特性**: - 实时内存映射可视化(按状态进行颜色编码) - 带有严重性追踪的事件时间轴 - 威胁分布图表 - 攻击向量分析 - 用于演示的模拟攻击按钮 **构建**: ``` cd typescript_dashboard npm install npm start ``` ## 🚀 快速开始 ### 前置条件 - Docker & Docker Compose - Rust 1.75+(用于核心开发) - Python 3.11+(用于 ML 组件) - Go 1.21+(用于 daemon) - Node.js 18+(用于仪表盘) ### 选项 1:Docker Compose(推荐) ``` # Clone 仓库 git clone https://github.com/your-org/side-channel-honeypot.git cd side-channel-honeypot # 启动所有服务 docker-compose up --build # 访问 dashboard open http://localhost:3000 # 查看 Prometheus metrics open http://localhost:9091 # 查看 Grafana dashboards open http://localhost:3001 (admin/honeypot_admin) ``` ### 选项 2:本地开发 ``` # 1. 构建 Rust core cd rust_core cargo build --release # 2. 安装 Python dependencies cd ../python_honeypot pip install -r requirements.txt # 3. 构建 Go daemon cd ../go_daemon go build -o honeypot-daemon # 4. 启动 dashboard cd ../typescript_dashboard npm install && npm start # 5. 运行 integration tests cd ../tests pytest test_integration.py ``` ## 📡 API 参考 ### REST Endpoint (Go Daemon) | 方法 | Endpoint | 描述 | |--------|----------|-------------| | GET | `/health` | 服务健康检查 | | GET | `/metrics` | Prometheus 指标 | | GET | `/api/v1/blocks` | 列出所有内存块 | | POST | `/api/v1/release` | 释放内存块 | | GET | `/api/v1/incidents` | 列出安全事件 | ### FFI 接口 (Rust 核心) ``` // Initialize the VRAM engine void* vram_init(uint64_t zeroing_interval_ms); // Allocate memory for a tenant uint64_t vram_allocate( void* engine, const char* tenant_id, size_t tenant_id_len, uint32_t pid, size_t size, uint8_t security_class ); // Read memory (triggers honeypot if Released) int32_t vram_read_unsafe( void* engine, uint32_t caller_pid, const char* caller_tenant_id, size_t tenant_id_len, uintptr_t addr, size_t size, uint8_t* out_buf, size_t out_buf_len ); ``` ## 🔬 研究背景 本项目实现了以下前沿研究中的概念: - **防御性 ML** (DefenderGAN):使用对抗性生成器在架构层混淆侧信道 - **移动目标防御**:通过随机化和欺骗实现概率性内存安全 - **主动欺骗工程**:适用于内存安全场景的蜜罐技术 - **迷惑代理人防御**:通过资源访问控制防止提权 ### 学术基础 - Liu & Hsieh (2019): *Rob-GAN: Generator, Discriminator, and Adversarial Attacker* — 用于稳健防御的对抗性训练 - Samangouei et al. (2018): *Defense-GAN* — 使用 GAN 净化对抗性样本 - Paccagnella et al. (2021): 云环境中的内存争用侧信道 - CISA (2023): 软件产品对内存安全的迫切需求 ## 📄 许可证 本项目采用双重许可: - **MIT License** — 见 [LICENSE-MIT](LICENSE-MIT) - **Apache License 2.0** — 见 [LICENSE-APACHE](LICENSE-APACHE) 您可以自行选择其中一种许可证。 ## ⚠️ 安全声明 这是一个**研究与防御工具**。其设计旨在: - 保护您自己的系统免受侧信道攻击 - 在受控环境中检测并欺骗攻击者 - 推动内存安全研究的发展 **请勿**使用此工具攻击您不拥有或未获得明确测试权限的系统。
标签:Apex, BOF, Docker镜像, 侧信道攻击防护, 凭据扫描, 可视化界面, 多语言混合架构, 日志审计, 机器学习, 欺骗防御, 自定义请求头, 蜜罐, 证书利用, 请求拦截, 逆向工具