ananyaa241/ASTRA-Q
GitHub: ananyaa241/ASTRA-Q
结合 AI 机器学习与后量子密码学的企业级内部威胁检测平台,通过持续行为信任评分和动态风险分级防御数据泄露。
Stars: 0 | Forks: 1
Astra-Q:高级安全威胁响应架构 – Quantum
企业级持续信任情报与内部威胁检测平台
专为现代高安全生态系统设计(例如:下一代银行、航空航天)
Astra-Q 不再依赖静态边界安全,而是持续评估行为遥测数据,动态对用户信任异常进行评分,并结合后量子密码学 (PQC),从原生层面防御内部威胁和数据泄露。
## 技术栈
- **前端框架**:Next.js 14, React 18
- **样式与 UI**:Tailwind CSS, Framer Motion, Recharts
- **后端 API**:FastAPI (Python 3.10+)
- **机器学习引擎**:DGL (GCN), Scikit-Learn (Isolation Forest, Random Forest), PyTorch
- **实时数据接入**:Apache Kafka, Zookeeper, WebSockets
- **目标 LLM 模型**:Groq (Llama-3-8b)
- **加密原语**:`liboqs-python` (ML-KEM / ML-DSA)
- **缓存与会话存储**:Redis
- **基础设施**:Docker / Docker Compose
Astra-Q 采用了一种超可扩展的、面向服务的架构,将实时事件流、人工智能和加密弹性连接在一起。
### 1. 数据接入与流处理
* **Apache Kafka & Zookeeper**:Astra-Q 的神经系统。由企业终端生成的原始行为遥测数据(按键、文件访问、外围设备、登录模式)将直接发布到 Kafka topics(例如 `aegis.telemetry`)。
* **WebSocket 中继**:在 FastAPI 后端之外运行的活动 WebSocket 会消费这些 Kafka 数据流,将零延迟数据直接推送到 React/Next.js 客户端界面。分析师可以观察生态系统的动态反应。
### 2. 核心检测引擎(机器学习 pipeline)
为了在不打扰合法员工工作的情况下准确隔离恶意活动,Astra-Q 部署了一个名为 **Fusion Head** 的集成机器学习模型:
* **异构图卷积神经网络 (HeteroGCN)**:对公司复杂的互连拓扑结构(用户 → PC → 文件)进行建模。如果员工访问了其同级组以前从未触及的文件类型,连接权重会立即激增。
* **心理测量归一化**:处理局部的时间变化。它实现了 **Isolation Forests**(用于原始异常值检测)和 **Random Forests**(用于有监督的历史模式分类),以基于“时段”行为将数据情境化。
* **序列 Transformer**:专门设计用于发现长期的、持久的窃取方法,这些方法通过保持对时间序列的状态感知来逃避传统的 SIEM 日志抓取。
* **风险输出**:这些 pipeline 融合在一起,将用户分为四个动态等级:**Low、Medium、High 或 Critical**。
### 3. 后量子密码学 (PQC) 安全层
Astra-Q 旨在通过实现为 Python 封装的 Open Quantum Safe (`liboqs`) 原生 C 绑定,来抵御即将到来的量子计算时代的威胁:
* **ML-KEM-1024 (Kyber)**:用于密钥封装机制 (KEM),以促成超越传统 TLS 算法的抗量子传输隧道。
* **ML-DSA-87 (Dilithium)**:用作不可变的真相来源。执行的每项缓解措施和隔离的每个威胁都会使用 Dilithium 签名进行数字签名。它们被安全地存储到 `pqc_keys` 模块中,生成牢不可破的加密审计日志。
### 4. 交互式分析师指挥中心(前端)
* **Next.js 14 / React**:在高度优化的 `standalone` Docker 架构中执行。
* **美学设计**:全面转向现代的“浅薄荷糊”企业设计语言,专注于高对比度、可读性和玻璃拟态深度建模。
* **可视化遥测**:UI 将实时数据绑定到 **实体关系图**,通过颜色(用户、PC、文件)在拓扑结构上识别威胁节点。
* **Groq SDK AI 助手**:利用 Llama3-8b,集成的 Chatbot 通过自然语言处理分析日志,随时协助分析师。
## 项目结构
该仓库被模块化地容器化为不同的核心环境:
```
astra-q/
│
├── frontend/ # Interactive Control Center (Next.js 14)
│ ├── Dockerfile # Multi-stage optimized Docker build for Next.js standalone container
│ ├── .eslintrc.json # ESLint configuration for frontend static typings
│ ├── next.config.js # Next configuration including standalone output for Docker
│ ├── package.json / package-lock.json # Frontend dependency manifest (Tailwind, Framer Motion, Recharts)
│ ├── postcss.config.js / tailwind.config.js # Styling processor and Tailwind component class configurations
│ ├── tsconfig.json # TypeScript compiler parameters
│ ├── next-env.d.ts # Next.js typescript declarations
│ ├── public/ # Static assets served to the client
│ │ ├── astra_logo.jpg # Astra-Q main platform application logo
│ │ └── logo.png # Secondary platform badge graphic
│ └── src/
│ ├── app/ # App router & Page architectures
│ │ ├── globals.css # Master stylesheet declaring Enterprise Light Mint system variables
│ │ ├── layout.tsx # Root layout wrapper binding authentication context to all child routes
│ │ ├── page.tsx # High-fidelity public Landing Page detailing enterprise threat defense
│ │ ├── access/
│ │ │ └── page.tsx # Primary Entry Gateway coordinating login and MFA workflows
│ │ └── dashboard/
│ │ ├── page.tsx # Core Command Center layout managing Telemetry, Control, and Ledger tabs
│ │ └── report/
│ │ └── page.tsx # Granular Threat Report dashboard rendering dynamic entity graphs and mitigations
│ ├── components/
│ │ ├── AccessPortal/
│ │ │ ├── CriticalDenial.tsx # Renders 403 ML-DSA lockdown screen during extreme behavioral anomaly
│ │ │ ├── LoginForm.tsx # Orchestrates base user authentication and password extraction
│ │ │ └── MfaChallenge.tsx # Triggers TOTP secondary authentication when adaptive friction is assigned
│ │ ├── AlertPanel/
│ │ │ └── index.tsx # Right-side heads-up display rendering active temporal threats locally
│ │ ├── ArchitecturalGraph/
│ │ │ └── index.tsx # Visualizes systemic infrastructure via D3 algorithms
│ │ ├── AuditLedger/
│ │ │ └── index.tsx # Displays immutable, cryptographically-signed records of past mitigations
│ │ ├── Chatbot/
│ │ │ └── index.tsx # Draggable LLM overlay analyzing cyber-logs via natural language context
│ │ ├── common/
│ │ │ └── NavSidebar.tsx # Application vertical navigation toolbar orchestrating system routes
│ │ ├── MetricsBar/
│ │ │ └── index.tsx # Dashboard header widgets displaying throughput and active risk aggregators
│ │ ├── SessionManager/
│ │ │ └── index.tsx # Active session visual tracker showcasing online user identities
│ │ ├── ThreatGraph/
│ │ │ └── index.tsx # D3.js powered Force-Directed graph bridging behavioral anomaly clusters
│ │ ├── ThreatTable/
│ │ │ └── index.tsx # Central event tracker allowing analysts to initiate manual containment payloads
│ │ └── WorkflowTracker/
│ │ └── index.tsx # Progressive visual stepper tracking the multi-stage event processing pipeline
│ ├── context/
│ │ └── AuthContext.tsx # React Context mapping identity data across protected routes
│ ├── hooks/
│ │ ├── useMounted.ts # Utility hook ensuring client-side hydration safety
│ │ ├── useThreatData.ts # Polls historical threat sets when WebSockets are unresponsive
│ │ └── useWebSocket.ts # Real-time data pipeline consuming Kafka analytics natively to the UI
│ └── lib/
│ ├── api.ts # Axios interceptors mapping frontend requests to backend core endpoints
│ └── types.ts # Universal TypeScript primitives declaring Data, Model, and Risk structures
│
├── backend/ # FastAPI Application Engine & Kafka Consumers
│ ├── Dockerfile # Backend container incorporating gcc/cmake steps required for liboqs C-bindings
│ ├── .env / .env.example # Security variables provisioning Cryptographic KEKs and Groq keys
│ ├── compile_oqs.py # Automated internal build script enforcing quantum-encryption C libraries
│ ├── main.py # Core FastAPI ASGI app aggregating modular routers and enabling CORS
│ ├── openapi.json # Autogenerated OpenAPI specs mapping the REST endpoints
│ ├── pyproject.toml # Universal Poetry replacement declaring all backend python modules
│ ├── requirements.txt # Deprecated standard python dependency graph list
│ ├── test_login.py / test_pqc.py # Pre-deployment validation scripts validating MFA auth logic and OQS binding stability
│ ├── api/
│ │ ├── main.py # Master API aggregator linking web server middleware to sub-routers
│ │ └── routers/
│ │ ├── auth.py # Identity processor governing session risk assessment against Redis caches
│ │ ├── chat.py # Chatbot handler communicating telemetry inquiries to the Groq LLM API
│ │ ├── system.py # Uptime health checks verifying ML model integration status
│ │ ├── threats.py # Containment endpoint executing policy isolation and firing ML-DSA signatures
│ │ └── ws.py # Asynchronous handler mounting persistent broadcast pipes with active dashboards
│ ├── ingestion/
│ │ ├── cert_reader.py # Parse mechanisms pulling structured raw data frames from local CERT datasets
│ │ ├── feature_cache.py # Redis-backed buffer caching historical user variables supporting fast anomaly clustering
│ │ ├── kafka_producer.py # Translates internal raw dataset structures into asynchronous live Kafka streams
│ │ ├── simulator.py # Script generating synthetic malicious traffic for live demonstration testing
│ │ └── syslog_stream.py # Native handler absorbing external system logs directly into the analytic pipeline
│ ├── llm/
│ │ └── groq_client.py # Integration controller bundling local incident data into API requests for Llama3 analysis
│ ├── models/
│ │ ├── evaluate.py # Post-training logic ensuring predictive Isolation Forest outputs meet minimal thresholds
│ │ ├── process_data.py # Script orchestrating dimensional reduction and categorical encodings on raw logs
│ │ ├── test_models.py # Unit test protocol validating predictive outcomes prior to application integration
│ │ └── train.py # Primary orchestration executing ensemble training iterations across core datasets
│ ├── pqc/
│ │ ├── __init__.py # Marks Cryptographic toolkit space
│ │ ├── audit_log.py # Secure JSON ledger handler caching signed Dilithium transaction hashes
│ │ ├── dsa.py # ML-DSA implementation utilized for issuing unforgeable containment commands
│ │ └── kem.py # ML-KEM module designed to provision symmetric session keys securely resistant to quantum-cracking
│ ├── scripts/
│ │ ├── provision_demo_secrets.py # Seeds identical authentication hashes across Redis and Postgres for uniform demo operations
│ │ └── provision_demo_totp_db.py # Automatically populates mock two-factor authorization codes into the simulation graph
│ ├── tests/
│ │ ├── __init__.py # Initializer identifying PyTest directories
│ │ ├── conftest.py # Injects pre-constructed testing fixtures across testing loops
│ │ └── test_pqc.py # Unit verification directly confirming OQS library encapsulation outputs via liboqs
│ ├── training/
│ │ ├── __init__.py # Training module namespace
│ │ └── train.py # Legacy or alternate training compilation node (often overlaps with models directory)
│ └── utils/
│ ├── __init__.py # Shared utilities namespace
│ ├── keywrap.py # Cryptographic controller handling Fernet-based Key Encryption Keys based off `.env`
│ ├── secret_store.py # Runtime configuration manager pulling validated environment mappings automatically
│ ├── totp_db.py # Secondary mock database logic enforcing accurate 2-factor code comparisons
│ └── vault_client.py # Hypothetical wrapper structure mimicking hashicorp vault secret extraction protocols
│
├── models/ # Root Pre-compiled ML models outputs
│ └── training_report.json # Meta statistical output of final isolation forest training cycles displaying accuracy matrices
│
├── infra/ # Deployment Infrastructure configurations
│ ├── .env / .env.example # Environment parameters establishing global container networking specifics
│ ├── docker-compose.yml # Central nervous orchestration file bootstrapping the frontend, backend, Kafka, and Redis images via docker
│ ├── kafka/
│ │ └── topics.sh # Bash script natively bound to Zookeeper launching fundamental `aegis.telemetry` data topics instantly
│ └── postgres/
│ └── init.sql # SQL initialization generating mock identity user tables when relational databases are utilized
│
└── README.md # You are here - Exhaustive project blueprint and deployment instructions
```
## 设置与安装
按照以下步骤通过 Docker Compose 在本地部署 Astra-Q。
### 要求
* Docker Desktop / Docker Compose
* Python 3.10+(如果不使用 Docker 原生运行)
* Node.js & npm(用于前端修改)
* 用于 AI 助手的有效 [Groq API Key](https://console.groq.com/keys)
### 1. 克隆仓库
```
git clone https://github.com/your-org/astra-q.git
cd astra-q
```
### 2. 环境变量
复制环境模板并插入您的 API keys:
```
cp .env.example .env
```
确保在 `.env` 中定义了以下密钥:
```
FERNET_KEY=
GROQ_API_KEY=
```
### 3. 通过 Docker 构建与部署
使用 Docker Compose 配置后端、前端、Zookeeper、Kafka 和 Redis 实例。
```
cd infra
docker-compose up --build -d
```
*注意:后端容器将在构建阶段从源代码编译 `liboqs` C 库。这可能需要几分钟。*
### 4. 访问应用
一旦容器报告健康,打开浏览器并导航至:
* **分析师仪表板**:`http://localhost:3000`
* **后端 API 文档 (Swagger)**:`http://localhost:8000/docs`
## 系统工作流
### 架构流程图
```
graph TD
%% Entities
User((Endpoint User))
Kafka{{Apache Kafka}}
ML[Fusion Head Engine]
Redis[(Redis Sessions)]
Auth{Risk Assessor}
SOC((Analyst Dashboard))
%% Flows
User -->|Behavioral Telemetry| Kafka
User -->|Access Request| Redis
Redis --> Auth
Kafka -->|Stream Consumption| ML
ML -->|Risk Tier Update| Auth
Auth -->|Low Risk| Allow[Seamless Access]
Auth -->|Temporal Anomaly| MFA[TOTP Challenge Required]
Auth -->|Critical Threat| Deny[Post-Quantum 403 Lockdown]
Deny -->|ML-DSA-87 Signed Audit| SOC
MFA -->|Websocket Alert| SOC
Allow -.->|Normal Operations| SOC
SOC -->|One-Click Mitigation| Deny
```
### 管理员登录与身份验证流程
1. **访问发起**:操作员通过 `/api/auth/request-access` 查询 Astra-Q 网关。
2. **风险评估**:身份提供商 (Identity Provider) 将请求通过由 Redis 支持的功能缓存进行路由,以实时分析源环境。
3. **自适应摩擦**:
* 如果指标暗示处于标准操作参数范围内,则无缝授予通行权限。
* 如果检测到时间或位置异常,系统将触发 **MFA Challenge**,在验证次要的加密 TOTP token 之前阻止通行。
* 如果灾难性的参数阻碍了身份保证,系统将抛出 `403 CRITICAL DENIED` 响应,通过自动化的后量子遏制日志来暂停登录。
### 威胁检测与缓解处理
1. **持续遥测**:合法的操作员日志将持续传入 Kafka broker。
2. **行为转变**:员工在凌晨 3:00 使用未经授权的设备开始批量下载高度机密的文件。Fusion Head 通过 Graph 和 Transformer 模块对此进行处理,瞬间将风险等级转变为 `CRITICAL`。
3. **分析师审查**:仪表板会在几毫秒内将 UI 警报面板中的事件隔离出来。实时的节点图会将受影响的用户和端点标记为深琥珀色和红色。
4. **即时缓解**:分析师调用自适应权限滑块或触发直接的“撤销连接” payload。此请求将被传回 FastAPI 的 `/api/threats/contain` endpoint,该端点将被立即评估,由 `ML-DSA-87` 签名,并从原生层面执行以立即锁定网络节点。
## 竞争对比与可行性
Astra-Q 通过在算法预见性的基础上强制执行持续验证,代表了对抗传统企业入侵系统的范式转变。
| 功能领域 | Astra-Q | 传统 SIEM / IAM |
|:---|:---|:---|
| **身份范式** | **持续信任评分** 在活动会话期间持续评估意图。 | **静态边界防御** 一旦用户通过初始密码/MFA 界面,即授予无限访问权限。 |
| **加密标准** | **NIST 后量子密码学** (ML-KEM / ML-DSA) 保护 payload 免受量子解密的影响。 | **传统的 RSA / ECC 协议**,从根本上容易受到分解算法的攻击。 |
| **架构速度** | **实时数据流** 将 Kafka 生产者直接连接到 WebSocket 前端,实现瞬时操作。 | **批量日志抓取与索引**,其中违规与检测之间出现 10-30 分钟的延迟是常态。 |
| **缓解行动** | **一键微隔离** 从 SOC 仪表板动态锁定特定的用户路径。 | **手动脚本**需要处理 IT 工单,导致响应瘫痪和更广泛的违规行为。 |
| **部署可行性** | **高可行性:** 使用 Python/Next.js 微服务的模块化 Docker 部署。轻量级且可通过 Kubernetes 进行水平扩展。 | **低灵活性:** 沉重的单体部署结构需要大量的数据库复制和僵硬的配置。 |标签:AV绕过, FastAPI, 人工智能, 内部威胁检测, 凭据扫描, 后量子密码学, 威胁情报, 开发者工具, 搜索引擎查询, 用户模式Hook绕过, 自动化攻击, 请求拦截, 软件成分分析, 逆向工具