Back to skill

Security audit

git-commit-ai

Security checks for vulnerabilities and agentic risk

Overview

This skill is a plausible AI commit-message helper, but it feeds raw staged diffs into the agent prompt and can leave secrets exposed while also offering an optional persistent Git hook.

Install only if you are comfortable with staged code diffs being processed by the AI agent. Review staged changes for secrets before running it, and avoid --install --force unless you have checked and backed up any existing prepare-commit-msg hook.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (2)

T01 · Skill Instruction Hijacking

Error
Location
index.js:456
Finding
Untrusted Git Diff Content Can Inject Instructions into the AI Prompt<![CDATA[ ## Vulnerability Details **File Location**: `index.js:456-485` **Vulnerability Type**: Prompt injection through untrusted repository content **Risk Level**: High ### Vulnerable Code ```javascript // 返回分析请求 const systemPrompt = getSystemPrompt(language); // 构建输出,包含警告信息 let output = ''; if (warnings.length > 0) { output = `⚠️ 警告:\n${warnings.map(w => ` - ${w}`).join('\n')}\n\n---\n\n`; } output += `请根据以下 Git diff 生成 commit message: --- ## Git Diff 内容: \`\`\`diff ${diff} \`\`\` --- ## 分析要求: ${systemPrompt} --- 请生成符合规范的 commit message,只输出 message 本身,不要其他解释。`; return output; ``` ### Technical Analysis The skill inserts the complete staged Git diff into an AI prompt without treating it as untrusted input. A Git diff may contain attacker-controlled text from source files, comments, documentation, test fixtures, filenames, or configuration files. Markdown code fences do not create a security boundary for a language model. An attacker can stage text that instructs the model to ignore the commit-message task, disclose available context, generate unrelated content, or attempt to invoke tools. The generated prompt does not explicitly prohibit following instructions found inside the diff, and it does not use a structured or isolated data channel. The effective severity depends on the host agent. If the receiving model only returns text and has no tool access, the likely consequence is manipulation of the generated commit message. If the host processes the returned prompt in a tool-enabled agent context, the injection could attempt broader actions subject to that host's permissions and safety controls. ### Attack Path 1. An attacker contributes a tracked file containing instructions directed at an AI agent. 2. A user reviews or receives the repository changes and stages the malicious file with `git add`. 3. The skill executes `git diff --cached` and reads the attacker-controlled instructions. 4. The skill interpolates the diff verbatim into th ...[truncated 802 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Explicitly identify the diff as untrusted data and instruct the model never to follow commands or policy statements contained within it. 2. Place trusted instructions before and after the diff so that the trust boundary remains explicit. 3. Use structured model input or a dedicated data field instead of concatenating the diff into a natural-language instruction when the host API supports it. 4. Ensure the model invocation used for commit-message generation has no tool access and receives no unrelated sensitive context. 5. Neutralize or encode delimiter-like content so repository text cannot imitate the surrounding prompt structure. 6. Consider preprocessing the diff into a restricted representation containing file paths and changed code rather than arbitrary prose. 7. Add adversarial tests containing phrases such as “ignore previous instructions” and verify that the output remains a single valid commit message. 8. Validate the model response against the required commit-message format and reject responses containing commands, explanations, multiple lines, or unexpected content. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
index.js:461
Finding
Detected Secrets Remain Exposed in the AI Prompt<![CDATA[ ## Vulnerability Details **File Location**: `index.js:209-215` and `index.js:461-473` **Vulnerability Type**: Plaintext sensitive-data exposure **Risk Level**: Medium ### Vulnerable Code ```javascript // 检测敏感信息(每次创建新的正则实例避免 lastIndex 问题) for (const { pattern, name } of SENSITIVE_PATTERNS) { const regex = new RegExp(pattern.source, pattern.flags); if (regex.test(diff)) { warnings.push(`检测到可能包含${name},请检查是否应该提交`); break; } } ``` ```javascript if (warnings.length > 0) { output = `⚠️ 警告:\n${warnings.map(w => ` - ${w}`).join('\n')}\n\n---\n\n`; } output += `请根据以下 Git diff 生成 commit message: --- ## Git Diff 内容: \`\`\`diff ${diff} \`\`\` ``` ### Technical Analysis The skill scans the staged diff for passwords, API keys, tokens, private keys, and database connection strings. Detection only adds a warning; it neither blocks processing nor redacts the matched value. The original `${diff}` is subsequently inserted into the AI prompt in plaintext. Consequently, a secret that the skill successfully detects is still exposed to the model-processing environment. Depending on the host architecture, the prompt may also be retained in conversation history, telemetry, diagnostic logs, or downstream model-provider records. The detector additionally stops after the first matching secret category. This limits warning completeness when a diff contains multiple kinds of credentials, although the principal vulnerability is that none of the detected values are removed. No direct network request or hard-coded exfiltration endpoint was found in the package. The finding concerns unsafe handling and disclosure of staged sensitive data to the host AI processing path. ### Attack Path 1. A user accidentally stages a file or code change containing a credential. 2. `getStagedDiff()` reads the credential through `git diff --cached`. 3. A sensitive-data regular expression matches the credential. 4. The skill adds a warning but retains the original diff unchan ...[truncated 1022 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Fail closed when a likely secret is detected: do not construct or return an AI prompt until the user removes the secret or gives explicit, informed confirmation. 2. Redact every detected value before prompt construction. Preserve only a typed placeholder such as `[REDACTED_API_KEY]`. 3. Scan all patterns instead of stopping after the first match so that every detected value can be reported and redacted. 4. Apply redaction to a separate copy of the diff and ensure only that sanitized copy is interpolated into the prompt. 5. Avoid printing secret values in warnings, exceptions, debug output, or telemetry. 6. Expand detection to commonly used credential formats and consider entropy-based detection, while accounting for false positives. 7. Configure the host not to retain prompts containing repository data wherever supported. 8. Add automated tests verifying that representative passwords, tokens, private keys, cloud credentials, and database URLs never appear in the returned prompt. ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (8)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 卸载 Hook
```bash
rm .git/hooks/prepare-commit-msg
```

---
Confidence
85% confidence
Finding
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).

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The README explicitly promotes installing a Git hook and mentions a force-overwrite option, but it does not clearly warn that this modifies executable repository hook files and may replace an existing local workflow or security control. In an agent skill context, instructions that alter `.git/hooks` are more sensitive because users may run them with limited review, increasing the chance of unintended persistence or workflow tampering.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The natural-language instruction says that in auto mode, if no comments are present, the commit message should default to Chinese. This imposes a specific language choice without explicit user opt-in, which matches the language/locale policy violation criteria.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The documented purpose is to automatically generate规范化 commit messages based on git diff, which is a content-generation function. The code additionally creates, overwrites, backs up, and chmods a prepare-commit-msg hook inside .git/hooks, which is a separate repository-modification capability not implied by simple commit message generation.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The skill states it uses AI to analyze staged git diff content, but it does not clearly warn users that potentially sensitive code, comments, file paths, or secrets in the staged diff may be transmitted to an external AI service. This creates a real privacy and data-handling risk because users may invoke the skill assuming analysis is local and unintentionally disclose proprietary or confidential material.

Intent-Code Divergence

Low
Confidence
75% confidence
Finding
The inline comments describe the hook as a simple reminder mechanism, but the implementation installs a prepare-commit-msg hook, which actively modifies commit workflow by executing during commit message preparation. While the script currently only prints reminders, the documentation understates that it injects an always-running Git hook into repository operations.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The package description states in Chinese that it automatically generates commit messages conforming to a standard, which implies a language-specific behavior without any indication that users can choose their preferred language or locale. Under the policy, forcing a specific language without opt-in is a natural-language policy concern.

Natural-Language Policy Violations

Low
Confidence
87% confidence
Finding
Defaulting to automatic language detection based on code comments means the tool analyzes comment text without explicit user opt-in, which can include sensitive natural-language notes, internal context, or developer annotations. While this is lower severity than undisclosed external transmission, it still expands processing of potentially sensitive content beyond what some users may reasonably expect.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
index.js:53