最近更新时间: 2026-03-23 10:33:20
开源 AI 智能体框架 OpenClaw(又称“龙虾”)因其强大的自动化能力在全球范围内广受关注。但国家工信部网络安全威胁和漏洞信息共享平台(NVDB)及各大高校、安全机构已相继发布预警:OpenClaw 在默认或不当配置下存在较高安全风险,易引发网络攻击、信息泄露等严重后果。 本文整理了 OpenClaw 的部署及应用安全最佳实践,帮助您在使用我司全栈应用服务器部署 OpenClaw 时能够“先守安全、再用AI”。
检查 OpenClaw 配置文件 openclaw.json,确保服务未监听在 0.0.0.0,避免服务默认绑定到所有网络接口,导致公网可直达。建议服务监听 127.0.0.1:18789 ,然后通过 ssh 隧道访问,监听配置如下:
{
"gateway": {
"mode": "local",
"port": 18789,
"bind": "loopback"
}
}在 iptables 中添加 IP 白名单限制访问来源。
# 创建自定义链:
sudo iptables -N ALLOWED_IPS
# 添加允许的IP(IP地址为示例,操作时需替换为实际IP地址):
sudo iptables -A ALLOWED_IPS -s 192.168.1.100 -j ACCEPT
sudo iptables -A ALLOWED_IPS -s 10.0.0.5 -j ACCEPT
sudo iptables -A ALLOWED_IPS -j RETURN
# 应用到SSH端口:
sudo iptables -A INPUT -p tcp --dport 22 -j ALLOWED_IPS在 OpenClaw 配置文件中强制开启认证,防止未授权用户远程连接并操控您的 AI 助手。
{
"gateway": {
"mode": "local",
"port": 18789,
"bind": "loopback",
"auth": {
"token": "使用至少32位随机字符串"
}
}
}生成随机 Token 的命令:
openssl rand -hex 32禁止使用 root 或管理员身份运行 OpenClaw,创建专用的 OpenClaw 账户运行进程,防止攻击者通过 OpenClaw 漏洞获得主机最高权限。
设置配置文件权限,防止其他系统用户读取您的敏感配置 chmod 600 /path/to/openclaw.json。
防止恶意技能自动加载 openclaw config set skills.autoInstall false。
安装并使用安全审计工具,可以有效地从源头阻断恶意代码入侵,如 skill-vetter 或 yidun-skill-sec(虾壳)。
openclaw plugin install skill-vetter
openclaw plugin enable skill-vetter安装 Skill 前务必执行扫描,自动化检测 Skill 中的高危行为(如读取敏感目录、执行 shell、外联未知域名)。
openclaw skill scan <skill-name>
openclaw skill report <skill-name>在安装任何 Skill 时自动执行拦截,避免误操作安装恶意插件。
openclaw config set plugins.skill-vetter.autoScan true
openclaw config set plugins.skill-vetter.blockCritical true# 配置日志级别
openclaw config set logging.level info
# 开启会话日志
openclaw config set logging.session true
# 日志输出位置
tail -f /opt/openclaw/logs/openclaw.log定期审查 OpenClaw 应用日志及 /var/log/auth.log 等系统日志,发现可疑的登录尝试或异常操作行为。
自动检查 OpenClaw 运行环境的安全状态。
# OpenClaw 系统体检
openclaw doctor
# 检查所有已安装插件的安全状态
openclaw plugin list --check-security及时关注 OpenClaw 相关漏洞,定期更新版本,规避 RCE 风险。
# 更新 OpenClaw
openclaw update
# 重新运行部署命令
# 更新插件
clawhub update --all如您发现 OpenClaw 行为异常或疑似被入侵,请立即执行以下操作:
openclaw gateway stop。注意:先不要删除应用,保留现场。参考资料
这篇文档有帮助吗?
正在加载反馈服务…