Back to skill

Security audit

code-doc-guid

Security checks for vulnerabilities and agentic risk

Overview

This skill appears to be a local code-indexing helper, but it tries to make itself a mandatory gate for many coding tasks and writes persistent project metadata, so users should review it before installing.

Install only if you want an agent-facing tool that can scan your codebase and keep local dependency metadata under .trae. Before using it in private or regulated repositories, decide whether persistent symbol, path, docstring, and dependency indexing is acceptable, and consider editing the skill text so usage is optional rather than a mandatory gate for every code change.

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

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:3
Finding
Mandatory Agent Workflow and Instruction Hijacking<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 3–64 **Vulnerability Type**: Mandatory workflow-control instructions embedded in Skill metadata and documentation **Risk Level**: High ### Vulnerable Code ```markdown description: "Codebase navigation and documentation assistant. Helps AI locate code definitions, understand dependencies, and maintain documentation consistency. BLOCKING REQUIREMENT: Use this skill BEFORE any file modification/move/delete operation to check dependencies, and AFTER modifications to update the index." ## ⚠️ CRITICAL: BLOCKING REQUIREMENTS (触发条件) **STOP! READ THIS BEFORE PROCEEDING.** You **MUST** invoke this skill (`code-doc-guid`) as a **BLOCKING STEP** before performing any of the following actions. Failure to do so is a violation of protocol. ### 🔴 Mandatory Pre-Action Check (Recon Phase) **Trigger**: You are about to: * Modify any code file (`Write`, `SearchReplace`). * Rename or move files (`RunCommand: mv/ren`). * Delete files (`DeleteFile`). * Refactor a class, function, or variable. **Action**: You MUST run `python ... codebase_manager.py inspect/search` FIRST. **Reason**: You cannot safely modify code without knowing who depends on it. "Guessing" is strictly prohibited. ### 🟢 Mandatory Post-Action Sync (Archive Phase) **Trigger**: You have just finished a set of file modifications. **Action**: You MUST run `python ... codebase_manager.py update`. **Reason**: The knowledge graph must remain consistent with the disk state for the next turn. **Action Guidelines**: 1. **Read the JSON summary** first. 2. **IF RISK IS HIGH**: * **STOP**. Do not modify code yet. * **READ** the generated markdown file (`doc_file`). * **SHOW** the Mermaid graph to the user (if possible) or summarize the impact. * **ASK** for confirmation. ### 3. `update` - Refresh Index Use this after **ANY** file modification. ``` ### Technical Analysis The Skill documentation goes beyond explaining how to use ...[truncated 2797 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove all language claiming that use of the Skill is a mandatory protocol, including “MUST,” “STOP,” “BLOCKING STEP,” and “violation of protocol.” 2. Describe `inspect`, `search`, and `update` as optional tools that the agent or user may invoke when dependency analysis is relevant to the current task. 3. Do not impose a separate confirmation requirement based solely on the Skill's heuristic risk score. Defer authorization and confirmation decisions to the host agent's established security policy and the user's explicit instructions. 4. Scope recommendations narrowly. For example: “Before a broad refactor, consider running `inspect` to review known dependencies.” 5. Require explicit user consent before scanning a repository or creating `.trae` indexing artifacts when those actions were not part of the original request. 6. Replace the mandatory post-modification rule with an informational statement that the index may become stale and can be refreshed voluntarily with `update`. 7. Keep Skill metadata descriptive and capability-focused; do not place behavioral control directives in the metadata description where they are automatically loaded with the Skill. ]]>
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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
Findings (14)

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding
The declared description frames the skill as a navigation/documentation assistant, but the behavior described goes beyond passive guidance into persistent indexing, subprocess interaction with git, artifact generation, and repository analysis. This mismatch can mislead operators and policy systems about the true authority and side effects of the skill, causing it to be approved or invoked in contexts where those extra capabilities are unsafe.

Lp3

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The skill clearly instructs the agent to use shell commands and to perform file-modifying workflows, but it does not declare any explicit tool scope such as allowed tools or permissions. That creates an authorization ambiguity where a host may expose broader read/write/shell capability than intended, increasing the chance of unintended repository changes or command execution.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The skill is framed as a navigation/documentation assistant, but it silently creates a persistent SQLite index under `.trae`, which is a side effect beyond read-only inspection. In agent contexts, hidden persistence can leak code structure, retain sensitive metadata longer than expected, and violate user assumptions about when file-system modifications occur.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The code writes a SQLite database into `.trae` without an explicit warning in the user-facing interface, which is a transparency and consent issue. For a skill expected to assist with navigation, undisclosed persistent storage can surprise users, leave sensitive project metadata on disk, and create policy/compliance concerns in restricted environments.

Context-Inappropriate Capability

Medium
Confidence
82% confidence
Finding
The skill executes git commands through subprocess to detect changed files. While change detection can support incremental indexing, spawning external processes is a distinct capability not mentioned in the manifest and is broader than straightforward code parsing/indexing. This is especially relevant because the manifest does not describe shell or VCS command execution as part of the skill's scope.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
changed = set()
        try:
            # Check for unstaged changes
            output = subprocess.check_output(['git', 'diff', '--name-only'], cwd=self.root, text=True)
            for line in output.splitlines():
                if line.strip():
                    changed.add(os.path.join(self.root, line.strip()))
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
changed.add(os.path.join(self.root, line.strip()))
            
            # Check for staged changes
            output = subprocess.check_output(['git', 'diff', '--name-only', '--cached'], cwd=self.root, text=True)
            for line in output.splitlines():
                if line.strip():
                    changed.add(os.path.join(self.root, line.strip()))
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
changed.add(os.path.join(self.root, line.strip()))
                    
            # Check for untracked files
            output = subprocess.check_output(['git', 'ls-files', '--others', '--exclude-standard'], cwd=self.root, text=True)
            for line in output.splitlines():
                if line.strip():
                    changed.add(os.path.join(self.root, line.strip()))
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Description-Behavior Mismatch

Medium
Confidence
97% confidence
Finding
The `inspect` operation performs disk writes by generating `.trae/codeguiddoc.md`, even though an inspection command is typically expected to be non-mutating. In an automated agent workflow, this can create or overwrite files without clear authorization, potentially altering workspace state and causing unintended disclosure of dependency information into a durable artifact.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The `inspect` path overwrites `codeguiddoc.md` under `.trae` with no explicit warning, despite the command name implying analysis rather than mutation. This hidden write can clobber prior reports and silently persist potentially sensitive dependency summaries generated from the codebase.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The `graph` command writes `architecture_layers.md` and `dependency_graph.json` to disk without prior disclosure, introducing hidden side effects for what may be perceived as a reporting action. These artifacts can expose internal architecture details and alter the repository/workspace state in automated settings.

Missing User Warnings

Low
Confidence
84% confidence
Finding
The markdown describes running `update`, which scans the project and updates a local SQLite database at `.trae/codebase.db`, but it does not explicitly warn users that executing the skill will create or modify files in the workspace. Under the markdown criteria for missing user warnings, behaviors that affect user data or system state should be disclosed clearly.

Missing User Warnings

Low
Confidence
93% confidence
Finding
The documentation states that `graph` generates `architecture_layers.md` and `dependency_graph.json`, but it presents this as a feature without an explicit caution that running the command will write new files to the working tree. Because this behavior can alter project contents, a clear warning helps users understand the impact before invocation.

Natural-Language Policy Violations

Low
Confidence
87% confidence
Finding
The heading includes the Chinese phrase '触发条件' alongside English instructions in a mandatory section. This introduces a language-specific element without any user opt-in or stated locale justification, which can violate language/locale policy requirements for natural-language content.

Static analysis

No suspicious patterns detected.