Back to skill

Security audit

release-gate-audit

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a legitimate release-audit skill, but confirmed flaws could let it read outside the target repository or miss real secrets while presenting release-gate results.

Review this skill before installing it as a release gate. Use it only as advisory until symlink boundary checks, content-bound baseline fingerprints, and long-line scanning are fixed. Run it under a low-privilege account, keep organization term files out of published repos, and do not rely on a passing result as proof that a repository is safe to publish.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (3)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/release_gate.py:329
Finding

Repository Symlinks Can Read Sensitive Files Outside the Audit Target

Content
View full analysis

Vulnerability Details

File Location: scripts/release_gate.py:329-333
Vulnerability Type: Path-boundary violation through symbolic-link traversal
Risk Level: Medium

Vulnerable Code

python
fp = Path(base) / rel
if not fp.is_file():
    continue
try:
    text = fp.read_text(encoding="utf-8", errors="replace")
except Exception:
    continue

Technical Analysis

Paths obtained from the repository are appended to the target directory without resolving the resulting path and verifying that it remains inside the target directory.

Both Path.is_file() and Path.read_text() follow symbolic links. Consequently, a Git-tracked symbolic link can reference a file outside the repository. When the scanner processes that path, it reads the external file using the privileges of the user or CI worker running the audit.

This behavior exceeds the minimum privileges required for repository auditing. The declared functionality only requires reading files within the selected repository and its Git history.

The external file's contents are passed to scan_text(). If they match a configured pattern, the matching line can be copied into the generated text or JSON report. Reports written to CI logs or retained as artifacts may therefore disclose local secrets.

Attack Path

  1. An attacker prepares a repository containing a tracked symbolic link pointing outside the repository, such as to a user configuration, credential, or private-key file.
  2. A victim or CI service checks out the repository on a platform that preserves symbolic links.
  3. The victim runs release_gate.py in public, worktree, or all mode.
  4. scan_paths() constructs the path and follows the symbolic link through is_file() and read_text().
  5. The scanner reads the external file with the caller's existing filesystem permissions.
  6. Matching content is included in terminal output, JSON output, CI logs, or retained report a ...[truncated 586 chars]
Remediation
View remediation

Remediation Suggestions

  • Reject symbolic links before reading files. Use lstat() or Path.is_symlink() rather than relying on is_file().

  • Resolve each candidate path and verify that it remains below the canonical repository root:

    python
    root = Path(base).resolve()
    candidate = root / rel
    
    if candidate.is_symlink():
        continue
    
    resolved = candidate.resolve(strict=True)
    try:
        resolved.relative_to(root)
    except ValueError:
        continue
    
    if not resolved.is_file():
        continue
    
  • Consider rejecting paths when any component between the repository root and file is a symbolic link, not only when the final component is one.

  • Record rejected out-of-root paths as warnings without reading their targets.

  • Add regression tests for absolute symlinks, relative symlinks containing .., chained symlinks, broken symlinks, and symlinked directories.

  • Run repository audits under a dedicated low-privilege account that cannot read unrelated user or service credentials.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/release_gate.py:84
Finding

Content-Independent Baseline Keys Can Suppress Newly Introduced Real Secrets

Content
View full analysis

Vulnerability Details

File Location: scripts/release_gate.py:84-85 and scripts/release_gate.py:570-572
Vulnerability Type: Security-gate bypass through insufficient baseline identity
Risk Level: High

Vulnerable Code

python
def key(self):
    return (self.category, self.location, self.line, self.desc)
python
# Baseline filtering: only exclude explicitly confirmed false positives
baseline = load_baseline(args.baseline)
if baseline:
    findings = [f for f in findings if f.key() not in baseline]

Technical Analysis

A finding's baseline identity consists only of its category, location, line number, and pattern description. It does not include the matched value, the finding snippet, a hash of the match, or a reviewed source revision.

As a result, changing the content at a baselined location does not necessarily invalidate the exception. If a placeholder or documented example is replaced by a real credential that triggers the same detector on the same line, the new finding receives the same key and is silently removed.

This contradicts the documented expectation that changed content should be presented for renewed review. Since this Skill acts as a release gate, the weakness can cause a false approval for an artifact containing an actual credential.

The line number offers little protection. An attacker or accidental edit can preserve the line position, and normal code formatting may also cause unrelated content to occupy a previously exempted location.

Attack Path

  1. A harmless placeholder, fixture, or vendor example triggers the scanner.
  2. A reviewer accepts the finding into the baseline using its category, path, line, and description.
  3. The content at that line is later replaced with a genuine credential matching the same built-in or organization-specific pattern.
  4. The path and line number remain unchanged.
  5. The new finding produces the same Finding.key(). ...[truncated 717 chars]
Remediation
View remediation

Remediation Suggestions

  • Include a cryptographic hash of the exact matched value or a carefully normalized snippet in each baseline fingerprint.
  • Prefer hashing only the matched token rather than the entire line, so unrelated formatting changes do not invalidate the exception while secret replacement does.
  • Store structured baseline entries containing the pattern identifier, relative path, content hash, review reason, review date, and reviewed Git commit.
  • Re-present a finding whenever its content hash differs from the reviewed baseline entry.
  • Bind release baselines to a repository or commit and warn or fail when they are applied to an unrelated target.
  • Treat malformed baseline files as an audit failure in release-gate use rather than silently continuing without reliable exception processing.
  • Add regression tests covering:
    • Placeholder-to-real-secret replacement on the same line.
    • Two different credentials matching the same detector.
    • Line movement and file renaming.
    • Duplicate matches on one line.
    • Reuse of a baseline against another repository.

T09 · Insecure Skill Coding Practices

Error
Location
scripts/release_gate.py:287
Finding

Secrets Can Evade Current-File Scanning by Appearing on Lines Longer Than 4,000 Characters

Content
View full analysis

Vulnerability Details

File Location: scripts/release_gate.py:287-290
Vulnerability Type: Detection bypass caused by unconditional input skipping
Risk Level: High

Vulnerable Code

python
for i, line in enumerate(text.splitlines(), 1):
    if len(line) > 4000:            # compressed artifact/long base64, skip to avoid false-positive storm
        continue
    for p in patterns:

Technical Analysis

The scanner completely skips every line longer than 4,000 characters. No built-in or externally supplied pattern is evaluated against such a line.

Long lines are legitimate in minified source code, compact JSON, generated configuration, lock data, embedded certificates, serialized environment data, and infrastructure manifests. An attacker can also deliberately pad an otherwise detectable secret until the line crosses the limit.

Skipping the entire line is unnecessary for controlling output volume. The implementation could instead scan bounded overlapping chunks, limit the number of findings, or scan only a bounded region around matches.

The issue applies to current-file scanning through scan_text(), including tracked files, worktree content, and non-Git directory targets. Git-history scanning uses separate logic and does not apply this exact length check.

Attack Path

  1. A credential matching an active pattern is placed in a tracked file or other scanned current file.
  2. The same line contains enough padding or minified content to exceed 4,000 characters.
  3. scan_text() reaches the length check and skips the line.
  4. No pattern matching occurs for that content.
  5. The credential is absent from the report.
  6. If no other blocking finding is present, the scanner exits with a successful release verdict.

Impact Assessment

This creates a reliable false-negative condition in a security-sensitive release gate. Credentials, internal identifiers, PII, and organization-specific to ...[truncated 330 chars]

Remediation
View remediation

Remediation Suggestions

  • Never skip a line solely because of its length.

  • Scan long lines in fixed-size chunks with overlap at least as large as the maximum practical token length:

    python
    chunk_size = 4096
    overlap = 512
    step = chunk_size - overlap
    
    chunks = (
        line[start:start + chunk_size]
        for start in range(0, len(line), step)
    )
    
  • Deduplicate findings produced in overlapping regions and preserve the original line and column offsets.

  • Apply a per-file or per-pattern finding cap to prevent report flooding without suppressing detection.

  • Consider streaming file scanning to avoid loading very large files fully into memory.

  • Add tests with secrets before, across, and after chunk boundaries, as well as padded lines, minified JSON, and compact configuration files.

  • Clearly distinguish unsupported binary formats from supported textual files; textual content should not become unsupported merely because a line is long.

Vulnerability Patterns
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (12)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
70% 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).

Content

Scanner excerpt · references/threat-categories.md (reported line 34)May include surrounding context.

bfg --replace-text replacements.txt && git reflog expire --expire=now --all && git gc --prune=now

然后 force push(务必提前通知所有协作者,否则他们的本地分支会分叉)

git push --force --all

text

> 注意:fork、PR、CI 缓存、镜像仓库里可能仍有副本。历史重写不能替代吊销。

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill instructs use of shell commands, file reads, and environment-variable input, but it does not declare any explicit tool scope such as allowed tools or permissions. Even though the documented purpose is a defensive audit, the absence of a least-privilege boundary means an agent may invoke broader-than-expected shell/file/env capabilities on a target repository, increasing the chance of unintended command execution, access to unrelated files, or exposure of sensitive environment data.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This markdown file is written entirely in Chinese and presents the guidance as the default skill content, with no indication that users may choose another language or that the locale restriction is required for a region-specific purpose. Under the policy, forcing a specific language without opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The entire skill document is written in Chinese and does not indicate any language choice, alternative locale, or opt-in behavior. Under the policy rule for natural-language violations, forcing a specific language without user opt-in is in scope.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code file contains user-facing natural-language strings entirely in Chinese, including the module description and operational guidance, but provides no option to select another language or opt in to this locale. Under the policy rule, forcing a specific language without user choice is a natural-language policy violation unless the locale restriction is clearly documented and justified.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The usage text describes worktree mode as '仅扫工作目录(含未追踪文件)', which suggests scanning what is in the working directory. In implementation, worktree mode for git repos uses only tracked + untracked from git ls-files and git ls-files --others --exclude-standard (L561-L565), so gitignored files are excluded even though they exist in the working directory. Given the manifest's emphasis on the distinction from ls-visible content, this wording materially misstates behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Multiple user-facing print statements, argparse descriptions, and report text are hardcoded in Chinese throughout the script, and there is no mechanism for locale choice. This can force a specific language on users at runtime, which violates the policy unless there is explicit opt-in or a justified region-specific constraint.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/release_gate.py (reported line 240)May include surrounding context.

python
# ─── git 交互 ────────────────────────────────────────────────────
def run_git(args, cwd):
    try:
        r = subprocess.run(["git"] + args, cwd=cwd, capture_output=True,
                           text=True, timeout=120)
        return r.returncode, r.stdout, r.stderr
    except FileNotFoundError:

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring at L341 says the function scans '全部提交的diff 内容', which implies full diff scanning for the tool's configured issue classes. However, the code at L355-L356 restricts history scanning to only CREDENTIAL and ORG_INTERNAL patterns, omitting PII and LOCAL_ONLY from commit history. This is an active contradiction between documentation and behavior, not just missing detail.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The module docstring and CLI usage/help text are entirely in Chinese, and the runtime output later in the file is also Chinese-only. For a general-purpose verification script, this is a natural-language locale policy issue because users are not given any language/locale opt-in or alternative.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Error messages, headings, warnings, and remediation guidance printed by the script are all hardcoded in Chinese string literals. This enforces a single language for all users without opt-in, which matches the language/locale policy violation criteria.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

This JSON file contains natural-language policy text entirely in Chinese in the _comment and _review_note fields. Under the policy, forcing a specific language without user opt-in or a documented justification is a locale-policy concern, and no such opt-in or justification appears in this file.

Content

No source excerpt is available for this finding.