Back to skill

Security audit

Xie Code Review

Security checks for vulnerabilities and agentic risk

Overview

This code-review skill mostly matches its stated purpose, but it automatically loads optional Python modules from outside the skill package, which creates a Review-level security concern.

Review before installing. The core reviewer is ordinary local code-analysis tooling, but only use it in an environment where you trust the surrounding skills directory and any c-support/lib modules, or remove/sandbox that optional import path. Expect it to read files you ask it to review, run git queries for staged or commit reviews, and write reports when an output path is provided.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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 (1)

T08 · Insecure Dependencies

Warning
Location
scripts/analyzer.py:17
Finding

Untrusted External Python Module Loading Through Parent-Directory Search Path

Content
View full analysis

Vulnerability Details

File Location: scripts/analyzer.py, lines 17-24
Vulnerability Type: Python dependency or module hijacking
Risk Level: Medium

Vulnerable Code:

python
# Import C support library
c_support_path = Path(__file__).parent.parent.parent / 'c-support' / 'lib'
if c_support_path.exists():
    sys.path.insert(0, str(c_support_path))
    try:
        from c_parser import CParser
        from c_security_rules import CSecurityChecker
        C_SUPPORT_AVAILABLE = True
    except ImportError:
        C_SUPPORT_AVAILABLE = False

Technical Analysis

The analyzer constructs a path outside the audited project package, inserts that directory at the beginning of sys.path, and imports c_parser and c_security_rules from it. Neither module is included or integrity-pinned by this project.

Because Python executes module-level code during import, control over the external c-support/lib directory is equivalent to control over code executed when scripts/analyzer.py is loaded. Prepending the directory to sys.path gives files at that location priority over modules available from lower-priority search locations.

The except ImportError block does not provide a security boundary. It only handles import failures and does not prevent arbitrary module-level instructions from running before or during import.

Attack Path

  1. An attacker obtains write access to the calculated external c-support/lib directory or can create that directory in the expected parent location.
  2. The attacker places a malicious c_parser.py or c_security_rules.py file there.
  3. A user invokes scripts/main.py, executes scripts/analyzer.py, or otherwise imports the analyzer module.
  4. The analyzer prepends the attacker-influenced directory to sys.path.
  5. Python imports the malicious module and immediately executes its module-level payload.
  6. The payload runs with the same operating-syst ...[truncated 932 chars]
Remediation
View remediation

Remediation Suggestions

  1. Package the C-support modules within the Skill's own trusted Python package and load them using explicit relative imports.
  2. Remove the mutation of sys.path, especially insertion of a mutable directory outside the project package.
  3. If the components are third-party dependencies, distribute them through a trusted package repository, pin exact versions and hashes, and verify them during installation.
  4. If external plugin loading is an intentional feature, require an explicit administrator-controlled configuration rather than deriving a parent-directory path implicitly.
  5. Before loading an external plugin, validate the canonical path, ownership, permissions, and expected cryptographic digest or signature.
  6. Run the analyzer with least privilege and in a sandbox when reviewing untrusted projects.
  7. Add a regression test confirming that modules placed in adjacent or parent directories cannot be imported automatically.
Vulnerability Patterns
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (4)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises and instructs use of shell commands plus file read/write workflows, but it does not declare any explicit tool scope such as permissions or allowed-tools. That creates an authorization gap where an agent may execute broader filesystem or shell actions than users expect, increasing the risk of unintended repository access, file modification, or command execution in automation contexts like hooks and CI.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown file presents nearly all operational instructions, examples, and configuration guidance in Chinese, which effectively imposes a specific language on users. The policy allows locale constraints only when users are given a choice or when the restriction is clearly documented and justified, neither of which appears here.

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/main.py (reported line 51)May include surrounding context.

python
def run_review_staged(args):
    """Review staged git changes"""
    # Get list of staged files
    result = subprocess.run(
        ['git', 'diff', '--cached', '--name-only', '--diff-filter=ACM'],
        capture_output=True,
        text=True

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/main.py (reported line 98)May include surrounding context.

python
def run_review_commit(args):
    """Review a specific commit"""
    # Get files changed in commit
    result = subprocess.run(
        ['git', 'diff-tree', '--no-commit-id', '--name-only', '-r', args.commit],
        capture_output=True,
        text=True