T09 · Insecure Skill Coding Practices
- Location
scripts/pre-check.sh:38- Finding
Unresolved and Namespaced Skills Bypass Automatic Security Inspection
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a disclosed security checker, but it persistently changes Claude's global hook configuration and has fail-open gaps that can make its protection weaker than advertised.
Install only if you want a global Claude Code hook that runs this package's shell script before future Skill calls. Review the settings.json change first, keep the installed scripts protected from tampering, and do not rely on this as complete protection because some unresolved, namespaced, or nested-script cases can pass without full inspection.
scripts/pre-check.sh:38Unresolved and Namespaced Skills Bypass Automatic Security Inspection
install.sh:397Installer May Silently Skip Security Hook Registration
scripts/pre-check.sh:58Nested Script Directories Evade Automatic Security Scanning
The skill explicitly states it will modify ~/.claude/settings.json to install a PreToolUse hook. Altering agent configuration is security-sensitive because it changes execution flow for future tool use and could persistently intercept, block, or influence agent behavior if the skill or its scripts are later tampered with.
另外会修改:
~/.claude/settings.json # 添加 PreToolUse Hook 配置
This installation step describes automatically merging a PreToolUse hook into ~/.claude/settings.json. Persistent hook registration materially expands the trust boundary of this skill because every future Skill invocation may execute its shell script, making any compromise in that script high impact.
1. 创建 `~/.claude/skills/skill-security-check/` 目录
2. 写入 `SKILL.md`、`scan.sh`、`pre-check.sh`
3. 设置脚本执行权限
4. 将 PreToolUse Hook 合并到 `~/.claude/settings.json`(已有配置不会覆盖,原文件备份为 `.bak`)
安装完成后**重启 Claude Code 会话**即可生效。
The manual install instructions direct the user to add a command hook in ~/.claude/settings.json that runs a local shell script on every Skill use. Even though the purpose is defensive, this is privileged agent configuration and becomes dangerous if the script is modified, replaced, or abused to interfere with normal operation.
chmod +x ~/.claude/skills/skill-security-check/scripts/*.sh
~/.claude/settings.json,添加 Hook 配置:
{
"hooks": {
Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.
Additionally modifies:
~/.claude/settings.json # Adds PreToolUse Hook configuration
Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.
Additionally modifies:
~/.claude/settings.json # Adds PreToolUse Hook configuration
Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.
Additionally modifies:
~/.claude/settings.json # Adds PreToolUse Hook configuration
The documented installation flow says the script automatically merges a PreToolUse hook into ~/.claude/settings.json, creating a persistent interception point that runs on every skill invocation. Even if intended as a security feature, automatic modification of agent configuration introduces a powerful persistence mechanism and expands the trust boundary to shell scripts installed from a third party.
1. Creates `~/.claude/skills/skill-security-check/` directory
2. Writes `SKILL.md`, `scan.sh`, and `pre-check.sh`
3. Sets executable permissions on scripts
4. Merges PreToolUse Hook into `~/.claude/settings.json` (existing config is preserved, original file backed up as `.bak`)
**Restart Claude Code session** after installation to activate.
The manual installation instructions direct the user to add a command hook to ~/.claude/settings.json that executes a shell script automatically for every matched skill event. Hooking a global config to invoke shell code is inherently sensitive because a compromised or buggy script gains recurring execution in the agent workflow.
chmod +x ~/.claude/skills/skill-security-check/scripts/*.sh
~/.claude/settings.json and add the Hook configuration:
{
"hooks": {
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
|-------|------------------|-------|
| Dangerous dynamic injection | SKILL.md contains curl/wget/ssh in dynamic injection syntax | CRITICAL |
| Data exfiltration | Scripts pipe output to curl/nc | CRITICAL |
| Remote code execution | Scripts contain curl \| bash pattern | CRITICAL |
| Sensitive files + network | Scripts access .ssh/.aws/.env AND have network requests | CRITICAL |
| Invisible characters | SKILL.md contains zero-width characters (possible prompt injection) | CRITICAL |
| Auto-execute hooks | Frontmatter defines lifecycle hooks | WARNING |
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
|-------|------------------|-------|
| Dangerous dynamic injection | SKILL.md contains curl/wget/ssh in dynamic injection syntax | CRITICAL |
| Data exfiltration | Scripts pipe output to curl/nc | CRITICAL |
| Remote code execution | Scripts contain curl \| bash pattern | CRITICAL |
| Sensitive files + network | Scripts access .ssh/.aws/.env AND have network requests | CRITICAL |
| Invisible characters | SKILL.md contains zero-width characters (possible prompt injection) | CRITICAL |
| Auto-execute hooks | Frontmatter defines lifecycle hooks | WARNING |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
| Dangerous dynamic injection | SKILL.md contains curl/wget/ssh in dynamic injection syntax | CRITICAL |
| Data exfiltration | Scripts pipe output to curl/nc | CRITICAL |
| Remote code execution | Scripts contain curl \| bash pattern | CRITICAL |
| Sensitive files + network | Scripts access .ssh/.aws/.env AND have network requests | CRITICAL |
| Invisible characters | SKILL.md contains zero-width characters (possible prompt injection) | CRITICAL |
| Auto-execute hooks | Frontmatter defines lifecycle hooks | WARNING |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
| Dangerous dynamic injection | SKILL.md contains curl/wget/ssh in dynamic injection syntax | CRITICAL |
| Data exfiltration | Scripts pipe output to curl/nc | CRITICAL |
| Remote code execution | Scripts contain curl \| bash pattern | CRITICAL |
| Sensitive files + network | Scripts access .ssh/.aws/.env AND have network requests | CRITICAL |
| Invisible characters | SKILL.md contains zero-width characters (possible prompt injection) | CRITICAL |
| Auto-execute hooks | Frontmatter defines lifecycle hooks | WARNING |
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm -rf ~/.claude/skills/skill-security-check
~/.claude/settings.json and remove the PreToolUse entry with matcher SkillTool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm -rf ~/.claude/skills/skill-security-check
~/.claude/settings.json and remove the PreToolUse entry with matcher SkillTool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm -rf ~/.claude/skills/skill-security-check
~/.claude/settings.json and remove the PreToolUse entry with matcher SkillTool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm -rf ~/.claude/skills/skill-security-check
~/.claude/settings.json and remove the PreToolUse entry with matcher SkillThe skill’s declared purpose is a read-only security audit, but its behavior includes executing a local shell script as part of processing. That creates a material trust-boundary violation: users enabling an auditor reasonably expect passive inspection, not code execution, especially when the target path is attacker-controlled.
The instructions explicitly run bash ${CLAUDE_SKILL_DIR}/scripts/scan.sh "$ARGUMENTS", which means the auditing skill executes code rather than only inspecting files. Because the script is invoked on a user-supplied path, any unsafe handling inside that script could expose the user to command execution, unintended file access, or misleading audit results.
The skill contains contradictory instructions: earlier it requires executing a shell script, while later it says to never execute code from the audited skill. This inconsistency is dangerous because it can mislead operators into thinking the workflow is non-executing when it is not, undermining informed consent and safe use.
The installer writes multiple files under ~/.claude, including SKILL.md, helper scripts, and settings.json, so it clearly has file-write capability. That capability is central to the installer's behavior and becomes security-relevant because it alters persistent agent configuration and runtime behavior, not just local skill assets.
The installer writes multiple files under ~/.claude, including SKILL.md, helper scripts, and settings.json, so it clearly has file-write capability. That capability is central to the installer's behavior and becomes security-relevant because it alters persistent agent configuration and runtime behavior, not just local skill assets.
The installer registers a global PreToolUse hook for all Skill calls, which expands behavior from a manual auditing utility into an always-on interception mechanism. This creates persistent, auto-executing control over future skill use and can affect unrelated workflows, increasing blast radius if the hook is flawed, bypassed, or later modified.
Modifying ~/.claude/settings.json to install an auto-executing hook changes the user's global Claude behavior in a persistent way that is not necessary to perform ad hoc skill scans. This is dangerous because it grants the installer ongoing influence over future tool invocations and normalizes silent configuration changes in a security-sensitive agent environment.
Direct access to ~/.claude/settings.json is sensitive because that file governs agent behavior, hooks, and potentially trust boundaries. Writing to it allows persistent modification of how Claude tools are invoked, which is powerful enough to create security or integrity issues even without OS-level privilege escalation.
python3 << 'PYEOF'
import json, os
settings_file = os.path.expanduser("~/.claude/settings.json")
with open(settings_file, "r") as f:
settings = json.load(f)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# Check 3: Sensitive file access
echo "--- Check 3: Sensitive File Access ---"
if grep -rn -iE '\.ssh/|\.aws/|\.env|credentials|\.gitconfig|\.npmrc|\.pypirc|id_rsa|id_ed25519|\.kube/|\.docker/' "$SKILL_DIR" 2>/dev/null; then
echo "[!] Sensitive file access patterns found above"
else
echo "[OK] No sensitive file access patterns found"
No suspicious patterns detected.