Back to skill

Security audit

Hook Engine - 事件驱动行为守卫

Security checks for vulnerabilities and agentic risk

Overview

This skill is a security hook system, but it keeps detailed command audit logs and its documented protections do not fully match what the included scripts actually enforce.

Install only if you are comfortable with a local hook system observing commands and messages and keeping command audit records in the workspace. Treat it as a review-needed package until audit-log redaction, retention, permissions, JSON escaping, and the documented rule-enforcement gaps are fixed; do not rely on the advertised full security catalog as active protection.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
hooks/post-exec-log.sh:10
Finding

Unredacted command lines are written to a persistent audit log

Content
View full analysis
/dev/null; then COMMAND=$(echo "$EVENT_DATA" | jq -r '.command // "unknown"') EXIT_CODE=$(echo "$EVENT_DATA" | jq -r '.exitCode // -1') DURATION=$(echo "$EVENT_DATA" | jq -r '.duration // 0') STDERR=$(echo "$EVENT_DATA" | jq -r '.stderr // ""' | head -c 200) else COMMAND=$(echo "$EVENT_DATA" | grep -o '"command"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*: *"//;s/"$//') EXIT_CODE=$(echo "$EVENT_DATA" | grep -o '"exitCode"[[:space:]]*:[[:space:]]*[0-9]*' | head -1 | sed 's/.*: *//') DURATION=$(echo "$EVENT_DATA" | grep -o '"duration"[[:space:]]*:[[:space:]]*[0-9]*' | head -1 | sed 's/.*: *//') STDERR="" fi ``` ```bash # 确定日志目录 WORKSPACE="${OPENCLAW_WORKSPACE:-.}" LOG_DIR="$WORKSPACE/memory" LOG_FILE="$LOG_DIR/hook-audit.log" # 确保目录存在 mkdir -p "$LOG_DIR" 2>/dev/null || true ``` ```bash # 写入审计日志 echo "[$TIMESTAMP] [PostExec] [$DECISION] [$STATUS] cmd=$COMMAND exit=$EXIT_CODE duration=${DURATION}ms" >> "$LOG_FILE" 2>/dev/null || true ``` ### Technical Analysis The hook extracts the complete command line from attacker-influenced event data and appends it verbatim to a persistent file. Command lines can contain API keys, passwords, bearer tokens, signed URLs, database connection strings, private filesystem paths, and other credentials. The hook does not: - Redact sensitive arguments or credential patterns. - Remove carriage returns, line feeds, or terminal control characters. - Apply a restrictive `umask` or explicitly set log-file permissions. - Define log rotation or retention limits. - Verify that `OPENCLAW_WORKSPACE` points to a trusted location. Consequently, secrets may remain in `memory/hook-audit.log` after command e ...[truncated 1253 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
hooks/pre-exec-check.sh:28
Finding

The advertised security-pattern catalog is not enforced by the PreExec hook

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
rules/security-rules.md:65
Finding

External downloads proceed without the documented domain approval

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
hooks/post-exec-log.sh:49
Finding

Attacker-influenced values are interpolated into JSON without escaping

Content
View full analysis
> "$LOG_FILE" 2>/dev/null || true # 输出 JSON 结果 cat <
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (16)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · rules/security-patterns.md (reported line 192)May include surrounding context.

severity: high pattern: ((password|passwd|pwd|secret|private_key|access_key)\s*=\s*['"][^'"]{4,}|(username|user|uid)\s*=\s*['"]admin['"]) message: "检测到硬编码凭证:凭证应存储在安全位置" suggestion: "使用环境变量、.env 文件或密钥管理服务" cwe: CWE-798

text

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This markdown file presents all user-facing instructions and operational guidance exclusively in Chinese. The policy for this category requires flagging language or locale constraints when the skill forces a specific language without user opt-in, and no alternative language option or justification is provided here.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This code defines a persistent audit log file under the workspace memory directory and later appends executed command metadata to it. Although logging may be part of the hook's purpose, the script itself provides no confirmation prompt, user-facing notice, or explanatory comment warning that command details will be stored on disk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file’s human-readable description comments are written entirely in Chinese, which imposes a specific language context without any indication of user opt-in or documented locale restriction. Under the policy rule for natural-language locale constraints, this is a language/locale choice that is neither optional nor justified as region-specific.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation explicitly defines hook event payloads and audit logging that include potentially sensitive fields such as command strings, message content, stdout/stderr, session summaries, and environment variables. In a hook system, this can lead implementers to persist secrets, personal data, tokens, or confidential operational details into logs without minimization, redaction, retention limits, or user notice, creating privacy and secondary-compromise risks.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The natural-language descriptions shown to users are entirely in Chinese across multiple rule messages, with no indication that the skill is China-specific or that users can opt into another language. This can violate a language/locale policy when a skill imposes one language by default without user choice or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The entire skill file, including headings, usage instructions, warnings, and user-facing messages, is written only in Chinese. This effectively forces a specific language for users and operators without indicating any language choice, opt-in, or region-specific justification.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

文档声明 high 级别规则会“阻止执行并要求确认”,但示例实现里 high 与 critical 都直接设置 blocked=True,未体现单独的确认流程。这会导致安全控制语义与实际行为不一致,调用方可能基于错误假设设计流程,产生误用或绕过风险。

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

函数文档字符串声称返回值能完整表达检查结果,但示例代码并未真正实现文档中暗示的高危确认分支,仅返回 allowed/warnings/blocked。接口契约不准确会误导集成方,导致安全决策依赖错误字段或遗漏必要的人机确认步骤。

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

严重级别处理表说明 high 级别应“阻止执行 + 请求确认”,但实现仅统一阻止,没有暴露确认机制,形成明确的策略矛盾。安全策略文档与代码冲突会让运维、审计或上层代理错误理解控制边界,降低整体安全可预期性。

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The matcher includes chkdsk /f and chkdsk /r under a rule described as blocking disk formatting or partition operations, but those phrases can arise in routine disk-check or troubleshooting contexts and are not clearly constrained to destructive cases. The rule text does not provide scope limits or negative examples, so the activation boundary is ambiguous for normal maintenance commands.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

All natural-language descriptions and warnings in the rule file are written only in Chinese, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking environment. This can violate language/locale policy when no opt-in or justification is provided.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation states a conditional policy: only deletions affecting more than 50 files must be manually approved. However, the implemented rule is a simple command-pattern matcher with action: block, so any matching recursive/force delete command is blocked regardless of how many files are affected.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

Natural-language comments and emitted message strings are written in Chinese, including the status messages returned in the JSON output. The file does not offer any language selection or document that the skill is intentionally limited to a Chinese-speaking context, which can violate language/locale policy expectations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The natural-language comments and user-facing message text in this hook are written only in Chinese, which can impose a specific language on operators without any documented choice or opt-in. Under the policy, forcing a language/locale without user choice is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

A natural-language policy issue exists because the file forces a specific language presentation for all users and does not mention any opt-in, alternative language, or region-specific justification. Under the policy, language constraints should be optional or explicitly justified.

Content

No source excerpt is available for this finding.