Back to skill

Security audit

LSP Python

Security checks for vulnerabilities and agentic risk

Overview

This is a Python code-checking helper with expected local analysis and optional formatting behavior, but users should be aware that auto-fix can rewrite files and the install commands use unpinned Python packages.

Install and run this in a virtual environment, review the unpinned pip dependencies before installing, and only use --auto-fix on version-controlled or backed-up files because it can rewrite every Python file under the chosen directory.

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
SKILL.md:39
Finding

Unpinned Third-Party Dependencies Installed Without Integrity Verification

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:39-44, SKILL.md:102-103, SKILL.md:190, references/pylsp-config.md:7-27, and references/pep8-guide.md:129-147
Vulnerability Type: Unpinned and unverifiable third-party dependencies
Risk Level: Medium

Vulnerable Code Snippets

SKILL.md:39-44:

bash
pip install python-lsp-server
pip install python-lsp-server[all]
pip install pylsp-mypy
pip install pylsp-black

SKILL.md:102-103:

bash
pip install autoflake
autoflake --remove-all-unused-imports --in-place --recursive .

SKILL.md:190:

bash
pip install --upgrade python-lsp-server

references/pylsp-config.md:7-27:

bash
pip install python-lsp-server
pip install python-lsp-server[all]

# Code analysis
pip install pylsp-mypy
pip install pylsp-flake8
pip install pylsp-pylint

# Formatting
pip install pylsp-black
pip install pylsp-autopep8

# Refactoring
pip install pylsp-rope

# Other
pip install pylsp-isort

references/pep8-guide.md:129-147:

bash
pip install black
black file.py

pip install autopep8
autopep8 --in-place --aggressive file.py

pip install autoflake
autoflake --remove-all-unused-imports --in-place file.py

pip install isort
isort file.py

Technical Analysis

The installation instructions identify packages only by name and do not constrain them to reviewed versions or verify package hashes. They also do not provide a lockfile, require a trusted package index, or mandate an isolated environment.

Consequently, the effective code installed by these commands can change after the Skill has been reviewed. Python packages and their transitive dependencies may execute code during installation or when their console entry points are subsequently invoked. The unconditional --upgrade instruction further increases exposure by replacing an installed, potentially reviewed version with the latest ve ...[truncated 1584 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin every direct dependency to a reviewed version rather than installing an unconstrained latest release.
  2. Maintain a lockfile that captures transitive dependency versions.
  3. Generate and verify cryptographic hashes, and install with a command such as pip install --require-hashes -r requirements.txt.
  4. Install dependencies in a dedicated virtual environment or similarly isolated execution environment.
  5. Specify and validate the intended trusted package index; do not silently rely on arbitrary user-configured mirrors.
  6. Replace unconditional pip install --upgrade guidance with an explicit, reviewed upgrade procedure.
  7. Periodically scan locked dependencies for known vulnerabilities and update pins through a controlled review process.
  8. Separate optional dependencies into documented, pinned requirement groups so users install only the components they need.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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 (23)

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The documented purpose emphasizes safe code-quality/LSP assistance, but the content also includes batch traversal and in-place modification commands like autoflake and black across whole projects. That mismatch is dangerous because users or orchestrators may trust the skill as informational while it can trigger broad write-side effects and shell-driven project-wide changes.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 19)May include surrounding context.

md
python3 scripts/check_python.py <文件或目录>

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 22)May include surrounding context.

md
python3 scripts/check_python.py <文件或目录>

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 28)May include surrounding context.

md
python3 scripts/check_python.py <文件或目录>

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 29)May include surrounding context.

md
python3 scripts/check_python.py <文件或目录>

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill advertises and documents shell execution, file reads, and file-modifying operations but declares no explicit tool scope or permission boundaries. In an agent environment, that omission can let the skill be invoked with broader-than-expected capabilities, increasing the chance of unintended filesystem changes or command execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The title and introductory instructions are written in Chinese, and the rest of the skill documentation continues in that locale without indicating that another language is available. The policy explicitly calls for flagging language or locale constraints when the skill forces a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The document title and all instructional content are written in Chinese, with no indication that language choice is optional or that the skill is intentionally limited to a Chinese-speaking audience. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script presents itself primarily as a code-quality checker, but it also modifies source files when --auto-fix is used and always writes a report to disk. In an agent skill context, this expands side effects beyond passive analysis and can surprise users or higher-level automation that expects read-only diagnostics.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language strings that force a specific language for usage instructions and runtime messages. The policy explicitly flags language or locale constraints when the skill does not offer the user a choice or clearly justify the restriction.

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

python
def check_file(filepath):
    """检查单个文件"""
    script = Path(__file__).parent / 'scripts' / 'lsp-service.py'
    result = subprocess.run(
        [sys.executable, str(script), 'check', filepath],
        capture_output=True, text=True
    )

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The auto-fix behavior broadens the capability from LSP-style diagnostics to direct source rewriting via autoflake and black. In a skill advertised for checking and diagnostics, that broader write capability increases the risk of unintended code changes, especially if invoked by an agent or workflow that assumes analysis-only behavior.

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

python
print(f"🔧 修复 {filepath}...")
    
    # 1. 清理导入
    subprocess.run(
        ['autoflake', '--remove-all-unused-imports', '--in-place', filepath],
        capture_output=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/check_python.py (reported line 47)May include surrounding context.

python
)
    
    # 2. 格式化
    subprocess.run(['black', '-q', filepath], capture_output=True)
    
    # 3. 重新检查
    return check_file(filepath)

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/lsp-python.py (reported line 152)May include surrounding context.

python
command = sys.argv[1]
    
    # Start pylsp process
    pylsp = subprocess.Popen(
        ["pylsp"],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The module docstring and command descriptions are entirely in Chinese, and the script's user-facing messages throughout the file also assume Chinese output. For a general-purpose LSP wrapper, this is a natural-language locale restriction without any opt-in, selection mechanism, or documented reason that the skill is region-specific.

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/lsp-service.py (reported line 26)May include surrounding context.

python
script_path = Path(__file__).parent / "lsp-python.py"
    cmd = [sys.executable, str(script_path), command] + args
    
    result = subprocess.run(
        cmd,
        capture_output=True,
        text=True,

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The file title and all instructional content are presented exclusively in Chinese, with no indication that users may choose another language or that the locale restriction is required for a region-specific purpose. This can conflict with language/locale policy when a skill or reference material implicitly forces one language without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

This markdown file presents all instructions and examples exclusively in Chinese, and it does not mention that the guide is intended only for Chinese-speaking users or provide an opt-in language choice. Under the language/locale policy, forcing a specific language without user opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

For completion requests, the script reads the target file and sends its full contents to the language-server subprocess via textDocument/didOpen. While subprocess use is part of an LSP wrapper's purpose, the code does not explicitly warn users that file contents will be forwarded to another process in this path.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The diagnostics flow reads the entire file and transmits it to pylsp using a didOpen notification. The script documents the command purpose, but it does not clearly disclose that file contents are being shared with a subprocess for analysis.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The hover operation reads the file and forwards its contents to pylsp before requesting hover information. There is no explicit user warning in comments or help text that file contents are transmitted to a subprocess.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

Before requesting a definition lookup, the script opens the document in pylsp by sending the file text over stdin to the subprocess. The current help text does not explicitly tell users that full file contents are passed to the language server process.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.