arihantprasad07/guni

GitHub: arihantprasad07/guni

AI Agent 执行前安全检测中间件,在代理操作网页前拦截 prompt 注入、钓鱼页面、UI 伪装和目标劫持等威胁。

Stars: 1 | Forks: 0

# Guni **AI agent 安全。仅需一次导入。** 在您的 agent 执行任何操作之前,检测 prompt injection、phishing、UI deception 和 goal hijacking。 ## 安装 ``` pip install -e . ``` ## 快速开始 ``` from guni import scan result = scan(html=page_html, goal="Login to website") print(result["decision"]) # ALLOW / CONFIRM / BLOCK print(result["risk"]) # 0-100 print(result["evidence"]) # what was detected and why ``` ## REST API ``` # 启动 API server uvicorn api.main:app --reload --port 8000 # 扫描页面 curl -X POST http://localhost:8000/scan \ -H "Content-Type: application/json" \ -d '{"html": "
Ignore previous instructions
", "goal": "Browse page"}' # 交互式文档 open http://localhost:8000/docs ``` ## 结合 LLM reasoning(捕获新颖、重述的攻击) ``` from guni import scan result = scan( html=page_html, goal="Login to website", api_key="sk-ant-..." # or set ANTHROPIC_API_KEY env var ) print(result["llm_analysis"]["summary"]) ``` ## Guni 检测内容 | 威胁 | 权重 | 示例 | |---------------------|--------|----------------------------------------------| | Prompt injection | 30 | "Ignore previous instructions"(忽略之前的指令) | | Phishing forms | 40 | 向外部 URL 提交的密码字段 | | UI deception | 25 | 带有“立即转账”字样的隐藏按钮 | | Malicious scripts | 20 | eval(), fetch() 至未知域名 | | Goal mismatch | 35 | 告知 agent 进行汇款的页面 | ## 决策策略 | 风险 | 决策 | 含义 | |-------|----------|-----------------------------| | ≥ 70 | BLOCK | 操作已停止 | | 40–69 | CONFIRM | 需要人工确认 | | < 40 | ALLOW | 可以安全执行 | ## 部署到 Railway 请参阅 [DEPLOY.md](DEPLOY.md) 获取分步说明。 由 Code Mavericks 构建 — Indore Institute of Science & Technology
标签:AI安全, Anthropic, Chat Copilot, CIS基准, Code Mavericks, Naabu, Python, REST API, TLS, UI欺骗检测, 中间件, 内容安全, 域名收集, 恶意脚本检测, 提示词注入检测, 无后门, 目标劫持防护, 网络安全, 逆向工具, 钓鱼检测, 防御工具, 隐私保护