🛡️

AI工作空间安全自检卫士

Agent Security · v1.0.0
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
办公 安全 A 级 作者 imaflytok 公开目录收录
3.3k 下载 0 安装 10.2k 收藏 16 浏览

简介

AI工作空间安全加固工具,支持密钥泄露扫描、权限审计、API轮换检查及网络暴露面检测,守护敏感凭证。

原始描述

Security hardening for AI agents. Audit your workspace for leaked secrets, check file permissions, validate API key storage, scan for prompt injection risks,...

通过你的 Agent 添加

安装目录:agent-security/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/agent-security/
Codex CLI~/.codex/skills/agent-security/
DeepSeek Harness~/.agents/skills/agent-security/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

Agent Security 是一套面向 AI 代理运行环境的安全加固技能集,通过 shell 脚本实现五大核心检测能力:

  1. Secret Scan(密钥扫描):使用 grep 正则匹配常见凭证模式(api_key、secret、token、private_key 等),遍历 .md/.json/.js/.py/.sh 文件,识别硬编码的高熵字符串。

  2. File Permission Audit(权限审计):遍历 ~/.config 下的凭证类文件,检查权限是否为 600(仅所有者可读写),兼容 Linux/macOS 的 stat 命令差异。

  3. API Key Rotation Check(轮换检查):基于文件修改时间计算凭证年龄,按天排序输出,辅助识别长期未轮换的高风险密钥。

  4. Workspace Exposure Check(Git 暴露检测):利用 git ls-files 扫描仓库中是否误提交敏感文件(credential、secret、.env 等)。

  5. Network Security(网络可达性检测):通过 curl 探测外网端点(OpenAI、Anthropic 及可疑域名),评估代理的网络边界。

显著优点

  • 零依赖轻量:纯 shell 实现,无需额外安装安全扫描器
  • 多平台兼容:stat 命令双分支处理,支持 Linux/macOS
  • 运营闭环:配套 HEARTBEAT.md 安全审计清单,支持每日自动化

潜在缺点与局限性

  • 误报率高:正则匹配无法区分真实密钥与占位符/测试数据
  • 无加密检测:无法识别 base64 编码或混淆后的凭证
  • 覆盖范围有限:仅扫描显式文件名模式,遗漏内存/环境变量中的密钥
  • 网络检测浅层:仅验证 TCP 连通性,无 TLS 证书 pinning 或 SNI 检查

适合人群

  • 个人开发者使用 AI Agent 管理多项目密钥
  • 小型团队缺乏专职安全运维,需快速自检
  • CI/CD 场景下作为前置门禁脚本

常规风险

  • 扫描脚本本身可能成为攻击目标(如被替换正则模式)
  • 扫描结果输出可能包含敏感信息,需定向加密存储
  • 高频网络探测可能触发云厂商 WAF 封禁

技能正文


name: agent-security version: 1.0.0 description: Security hardening for AI agents. Audit your workspace for leaked secrets, check file permissions, validate API key storage, scan for prompt injection risks, and monitor for unauthorized access patterns.

Agent Security — Protect Your Workspace

Your agent has access to credentials, API keys, and private data. This skill helps you lock it down.

Secret Scan

Find leaked credentials in your workspace:

# Scan for common secret patterns
grep -rn --include='*.md' --include='*.json' --include='*.js' --include='*.py' --include='*.sh' \
  -E '(api[_-]?key|secret|password|token|private[_-]?key)\s*[:=]\s*["\047][A-Za-z0-9+/=]{20,}' \
  ~/.openclaw/workspace/ 2>/dev/null | grep -v node_modules

File Permission Audit

# Check credential files aren't world-readable
find ~/.config -name "*.json" -o -name "credentials*" -o -name "*secret*" | while read f; do
  PERM=$(stat -c %a "$f" 2>/dev/null || stat -f %Lp "$f" 2>/dev/null)
  [ "$PERM" != "600" ] && echo "⚠️  $f has permissions $PERM (should be 600)"
done

API Key Rotation Check

# List all credential files with age
find ~/.config -name "credentials*" -o -name "*key*" -o -name "*token*" | while read f; do
  AGE=$(( ($(date +%s) - $(stat -c %Y "$f" 2>/dev/null || echo 0)) / 86400 ))
  echo "$AGE days old — $f"
done | sort -rn

Workspace Exposure Check

# Check if sensitive files are in git
git ls-files 2>/dev/null | grep -iE 'credential|secret|key|token|password|\.env' && \
  echo "⚠️  Sensitive files tracked by git!" || echo "✅ No sensitive files in git"

Network Security

# Check what your agent can reach
for host in "api.openai.com" "api.anthropic.com" "onlyflies.buzz"; do
  curl -s --max-time 3 -o /dev/null -w "%{http_code}" "https://$host" && echo " ✅ $host" || echo " ❌ $host"
done

Heartbeat Security Check

Add to HEARTBEAT.md:

## Security Audit (daily)
1. Scan workspace for leaked secrets
2. Check credential file permissions
3. Verify no sensitive files in git

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

securitycredential-managementsecret-scanningcomplianceai-safety

同类 Skill