Back to skill

Security audit

chart-py-generator

Security checks for vulnerabilities and agentic risk

Overview

The local chart generator is mostly coherent, but the skill also promotes an under-documented Telegram sending workflow and relies on an unsafe import-path change.

Review before installing. Use the local chart generation path only unless you intentionally want charts sent through Telegram, and avoid sending sensitive business, financial, or personal data until the send command's recipient, credentials, logging, and confirmation behavior are documented. The maintainer should remove the broad sys.path insertion and clearly separate local generation from external sharing.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
chart_gen.py:13
Finding

Unsafe Python Import Path Enables Local Module Hijacking

Content
View full analysis

Vulnerability Details

File Location: chart_gen.py, lines 13–18
Vulnerability Type: Python import path hijacking
Risk Level: Medium

Vulnerable Code

python
import json

# 使用 conda 环境中的 matplotlib
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../..'))

import matplotlib
matplotlib.use('Agg')  # 非交互式后端
import matplotlib.pyplot as plt

Technical Analysis

The script prepends an ancestor directory to sys.path before importing matplotlib. Because index zero has the highest import precedence, Python searches this ancestor directory before trusted environment and site-package locations.

If an attacker can write a counterfeit matplotlib.py file or matplotlib/ package into that ancestor directory, Python may load it instead of the legitimate Matplotlib dependency. Top-level Python statements in the counterfeit module execute immediately during import.

The vulnerable path is derived from the script location rather than from a verified, private package directory. In the audited deployment layout, traversing three parent levels reaches a directory outside the Skill root and may expose import resolution to files controlled by another local process or user. Exploitation therefore depends on the attacker having write access to that ancestor directory.

Attack Path

  1. The attacker obtains write access to the directory resolved by ../../.. relative to chart_gen.py.
  2. The attacker creates a malicious matplotlib.py file or matplotlib/ package in that directory.
  3. A user or automated agent invokes chart_gen.py for legitimate chart generation.
  4. The sys.path.insert(0, ...) call gives the attacker-controlled location precedence over the installed Python packages.
  5. The subsequent import matplotlib loads the counterfeit module.
  6. The attacker's top-level Python payload executes with the identity and permissions of the process running the Skill.

Impact Assessment

Successful exploi ...[truncated 524 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the ancestor-directory insertion and rely on the configured Python environment:
python
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
  1. Install and pin Matplotlib in a controlled virtual environment or Conda environment rather than manipulating sys.path at runtime.

  2. If project-local imports are required, package the project properly and restrict imports to a dedicated directory inside the Skill root. Resolve and validate the path before use, and do not prepend shared temporary directories or broad ancestor directories.

  3. Run the Skill with least privilege and ensure that its installation directory and Python environment are not writable by untrusted users.

  4. Add a regression test that creates a counterfeit module in parent directories and verifies that it cannot override the expected Matplotlib installation.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill metadata and description present this as a chart generator, but the documentation also implies local file creation and additional behaviors that are not clearly disclosed up front. Hidden or under-documented side effects such as writing files can lead users or agents to invoke the skill in contexts where filesystem modification is unexpected, reducing informed consent and increasing misuse risk.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documentation introduces a chart-gen-send workflow that transmits generated charts to Telegram, which is materially different from local-only chart rendering. If users or agents assume the skill is confined to local processing, sensitive business or personal data embedded in charts may be exfiltrated to an external service without meaningful notice.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill documents Telegram transmission without any privacy, confidentiality, or data-sharing warning. Because charts often encode sensitive operational, financial, or personal information, omitting a warning can cause accidental disclosure to third-party infrastructure and chat recipients.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Repeated usage examples for chart-gen-send normalize external transmission while continuing to omit any warning about data leaving the local environment. This increases the chance that users copy-paste examples and unintentionally send confidential report data to Telegram.

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 natural-language descriptions and CLI help text that are Chinese-specific, beginning with the module docstring. Under the policy, forcing a specific language without user opt-in can be a locale/language policy violation when no alternative or justification is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The argparse description and argument help messages are all presented in Chinese, which constrains use to a single language without explicit opt-in. There is no indication that the tool is region-specific or that users can select another locale.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The description field forces a specific language presentation (数据可视化图表生成器(支持 7 种图表类型)) without indicating that users may choose another language. Under the language/locale policy rule, a forced language without user opt-in can be a natural-language policy concern.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest says the skill is a chart generator supporting 7 chart types, and the module docstring lists six types: line, bar, pie, scatter, area, and multi-series comparison. In code, the CLI exposes seven choices, but two of them are both multi-series comparison variants ('multi-line' and 'bar-compare'), so the implementation still amounts to six distinct chart categories rather than seven as claimed.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The top-level docstring explicitly enumerates six supported chart types: line, bar, pie, scatter, area, and multi-series comparison. Later, the argument parser advertises seven selectable types, including both 'multi-line' and 'bar-compare', creating a direct inconsistency between documentation and actual exposed behavior.

Content

No source excerpt is available for this finding.