Claude Code hook

Deepsafe Scan

Universal preflight security scanner for AI coding agents — Detects hooks injection, credential exfiltration & backdoors in .cursorrules, CLAUDE.md, AGENTS.md and more.

77 stars 11 forksHooks Source

Install

From source
git clone https://github.com/XiaoYiWeio/deepsafe-scan.git

From the README

DeepSafe Scan

  AI Agent 环境通用安全预检扫描器

    📖 完整文档与演示 → xiaoyiweio.github.io/deepsafe-scan

  运行前先扫描。一条命令,保护你的 AI Agent 环境免受密钥泄露、提示词注入、Hooks 后门攻击。

  想了解这些攻击是怎么运作的?→ AI Agent Attack Techniques

  ⚡ 攻击者只需 3 秒,就能从你的 AI Agent 环境中窃走 SSH Key、API Key 和全部敏感凭证。
  ↓ 真实攻击演示(3 倍加速) · 观看完整原速视频 →

  你 clone 的下一个仓库,可能已经在等你打开它了。

  支持平台:   
   OpenClaw     
   Claude Code     
   Cursor     
   Codex     
   OpenCode

它能做什么

DeepSafe Scan 在你执行 AI 生成代码或安装新 Skills 前,对 5 个维度进行安全预检:

4 个静态模块无需任何 API Key即可运行。LLM 功能自动检测已有凭证,无需手动配置。

⚠️ 为什么你需要这个

AI 编程 Agent(Claude Code、Cursor、Windsurf、Codex)的配置文件支持自动执行命令。攻击者可以在开源仓库中植入恶意配置:

快速开始

一行安装,一句话使用,从此 clone 不再裸奔。

方式一:作为 AI Agent Skill 安装(推荐)

安装后,直接用自然语言告诉你的 AI Agent:
"帮我用 deepsafe scan 扫一下这个项目"

Agent 自动扫描并返回报告,无需记任何命令。
Claude Code 用户 — 把 CLAUDE.md 复制到项目根目录即可集成:

方式二:作为独立命令行工具

零依赖

Python 核心仅使用标准库:urllib、json、re、hashlib、subprocess、concurrent.futures、argparse、dataclasses。

无需 pip install。

平台支持

项目结构

各模块详解

Posture 扫描

检查你的 AI Agent 部署配置:
- 不安全的网关认证(明文 HTTP、无鉴权、默认密码)
- 配置文件中暴露的 API Keys
- 权限过宽的安全设置
- 生产环境开启了调试模式

OpenClaw 用户读取 openclaw.json,其他平台检查 .env、config.json 等。

Skill / MCP 扫描

扫描所有已安装的 Skills 和 MCP 服务器目录,检测:
- 硬编码密钥(27 种模式 — API Keys、Token、密码)
- 远程代码执行模式(eval、exec、带用户输入的 subprocess)
- 数据外传(curl/wget/requests 发送到外部主机)
- 系统提示词中的提示词注入尝试
- 危险文件操作、Shell 注入、路径穿越

可选:LLM 语义分析可发现复杂的混淆模式。

Memory 扫描

扫描会话日志和 Agent 记忆文件:
- 27 种密钥模式:OpenAI Key、Anthropic Key、GitHub Token、AWS 凭证、Slack、Stripe、数据库 URL、SSH Key、JWT Secret
- 9 种 PII 类型:邮箱、电话(国际格式)、SSN、护照、信用卡(Luhn 校验)、医疗编码、驾照、银行账户、身份证
- 提示词注入:越狱片段、角色覆盖尝试、指令覆盖

Hooks 扫描

扫描 AI…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Python
Last updated
29 May 2026
Topics
ai-agentsaisecurityclaudeclaude-codecodexcursoropenclawopenclaw-pluginopenclaw-skillopenclaw-skillsprompt-injectionprompt-injection-llm-security

FAQ

What is Deepsafe Scan?

Universal preflight security scanner for AI coding agents — Detects hooks injection, credential exfiltration & backdoors in .cursorrules, CLAUDE.md, AGENTS.md and more. It is a hook for Claude Code, from XiaoYiWeio/deepsafe-scan on GitHub.

How do I install Deepsafe Scan?

Clone XiaoYiWeio/deepsafe-scan from GitHub and follow the setup steps in its README.

Is Deepsafe Scan popular?

XiaoYiWeio/deepsafe-scan has 77 GitHub stars and 11 forks. It was last updated on 29 May 2026.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.