Back to skill

Security audit

c刊期刊分析

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly coherent for CNKI journal analysis, but its report script can write generated files outside the intended output folder if a crafted journal title is supplied.

Install only if you are comfortable with the agent browsing CNKI, using browser tooling, creating local JSON/chart/DOCX files, and installing Python dependencies. Run it in a dedicated project folder or virtual environment, and avoid processing JSON from untrusted sources until the journal-title output path is sanitized.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/analyze_journal.py:463
Finding
Untrusted Journal Title Enables Output Path Traversal<![CDATA[ ## Vulnerability Details **File Location**: `scripts/analyze_journal.py`, lines 463–474 **Vulnerability Type**: Path traversal and unintended file overwrite **Risk Level**: Medium ### Vulnerable Code ```python journal_name = data.get('journal_info', {}).get('title', '未知期刊') articles = data.get('articles', []) print(f"期刊: {journal_name}") print(f"文章总数: {len(articles)}") chart_dir = os.path.join(output_dir, f'{journal_name}_charts') charts = create_charts(articles, chart_dir, journal_name) print(f"图表已生成: {chart_dir}/") report_path = os.path.join(output_dir, f'{journal_name}_近五年发文分析报告.docx') generate_report(data, charts, report_path) print(f"报告已生成: {report_path}") ``` The resulting paths are used by the following file-writing operations: ```python os.makedirs(output_dir, exist_ok=True) ``` ```python doc.save(output_path) ``` ### Technical Analysis The journal title is read directly from the user-supplied JSON document and incorporated into filesystem paths without validation or normalization. Python's `os.path.join()` does not guarantee that the result remains beneath the intended output directory. A title containing path separators, traversal components such as `../`, or an absolute path can cause `chart_dir` and `report_path` to resolve outside `output_dir`. The program subsequently creates the chart directory, writes fixed-name PNG files into it, and saves the generated Word document at the derived report path. The report filename has a fixed suffix, so an attacker cannot select every possible destination filename. However, the attacker can still control the parent path and filename prefix. The chart directory similarly receives a fixed suffix, but generated files within that directory can overwrite existing files with names such as `01_yearly_trend.png`. ### Attack Path 1. An attacker prepares an otherwise valid input JSON file. 2. The attacker assigns a traversal or absolute-path value to `journal_info.title`, for example a value begin ...[truncated 978 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Treat `journal_info.title` as display-only data and never use it directly as a filesystem component. 2. Generate a safe filename using a strict allowlist. Remove path separators, control characters, traversal sequences, and platform-specific reserved characters. 3. Reject absolute paths and titles whose sanitized form is empty. 4. Resolve and verify every destination before writing: ```python import re from pathlib import Path def safe_filename_component(value): value = re.sub(r'[^\w.-]+', '_', str(value), flags=re.UNICODE) value = value.strip(' ._') if not value or value in {'.', '..'}: raise ValueError("Invalid journal title") return value base_dir = Path(output_dir).expanduser().resolve() base_dir.mkdir(parents=True, exist_ok=True) safe_name = safe_filename_component(journal_name) chart_dir = (base_dir / f"{safe_name}_charts").resolve() report_path = (base_dir / f"{safe_name}_five_year_analysis.docx").resolve() if base_dir not in chart_dir.parents: raise ValueError("Chart path escapes the output directory") if base_dir not in report_path.parents: raise ValueError("Report path escapes the output directory") ``` 5. Refuse to overwrite existing output files by default, or require an explicit overwrite option. 6. Where output directories may be attacker-controlled, guard against symbolic-link redirection and use safe file-creation semantics. ]]>

T08 · Insecure Dependencies

Note
Location
SKILL.md:135
Finding
Third-Party Dependencies Are Installed Without Version or Integrity Pinning<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 135 and 172 **Vulnerability Type**: Unpinned third-party dependency installation **Risk Level**: Low ### Vulnerable Instructions ```text pip3 install jieba wordcloud python-docx matplotlib numpy ``` The same unpinned installation command is also recommended by the import-error handler in `scripts/analyze_journal.py`, line 38. ### Technical Analysis The Skill instructs users to install five third-party packages without fixed versions, cryptographic hashes, or a reviewed lockfile. Pip will therefore resolve whatever compatible package and transitive dependency versions are available from its configured package index at installation time. This makes installation non-reproducible and prevents integrity verification against a known reviewed dependency set. A compromised future release, compromised package-index account, unsafe user-configured package source, or unexpected transitive dependency update could introduce malicious or incompatible code. Python packages can execute code during installation or when imported. Consequently, dependency installation and subsequent script execution occur with the permissions of the user running pip or the analysis script. ### Attack Path 1. A user follows the installation command documented by the Skill. 2. Pip resolves current versions and transitive dependencies from the configured package index. 3. No project-provided version constraints or hashes are available to verify that the resolved artifacts match reviewed releases. 4. If a resolved release or configured source is compromised, malicious package code may run during installation or later import. 5. That code executes with the privileges of the user performing the installation or running the script. ### Impact Assessment The precise impact depends on the behavior of a compromised dependency. At worst, malicious package code could read or modify files, access environment data, or execute com ...[truncated 268 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Define reviewed, exact dependency versions in a requirements file. 2. Record cryptographic hashes for all direct and transitive packages. 3. Install with hash enforcement: ```text python3 -m pip install --require-hashes -r requirements.txt ``` 4. Use a dedicated virtual environment rather than installing into the system Python environment. 5. Generate and review a lockfile with a dependency-management tool that supports transitive pinning and hashes. 6. Regularly scan pinned dependencies for known vulnerabilities and update them through a controlled review process. 7. Document the expected package index and avoid untrusted extra indexes or dependency sources. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (5)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description emphasizes an end-to-end CNKI-powered journal analysis skill: user provides a journal name, the skill automatically retrieves the last five years of article metadata from CNKI, then produces a comprehensive report. The supplied code does only the downstream analysis and report generation portion. It expects a local JSON file already populated with journal_info and articles, and contains no network access, no CNKI scraping/API usage, no journal-name lookup, and no logic ensuring the data covers the most recent five years. While many report elements align partially with the description (keyword trends, methods, authors, sections, Word report generation), the primary advertised capability—automatic CNKI retrieval based on a journal name—is missing. In addition, the 'research gaps/submission advice' output is merely a generic placeholder rather than the full-dimensional expert analysis described. Therefore this is a material description-behavior mismatch.

Lp3

Medium
Category
MCP Least Privilege
Confidence
84% confidence
Finding
The skill instructs reading a local reference file (`references/journal_codes.md`) but declares no explicit tool scope or permissions boundary. In an agent environment, undeclared file-read capability weakens least-privilege controls and can enable broader-than-expected local file access if the runtime infers or grants filesystem tools implicitly.

Vague Triggers

Medium
Confidence
93% confidence
Finding
Overly broad trigger conditions can cause the skill to activate on ambiguous user requests, leading to unintended browsing, data collection, file generation, or dependency-related actions. In an agentic environment, accidental invocation increases the chance of unnecessary external access and execution of higher-risk workflow steps.

Context-Inappropriate Capability

Medium
Confidence
89% confidence
Finding
The skill tells the agent/user to run `pip3 install` for multiple packages, which modifies the execution environment beyond the core analysis task. Environment-changing instructions can introduce supply-chain risk, break reproducibility, or be abused to install unexpected packages if the instruction path is generalized or tampered with.

Context-Inappropriate Capability

Low
Confidence
71% confidence
Finding
The manifest frames the skill as analyzing a specified C journal by querying CNKI for recent issues and article metadata. This line expands capability to search the broader web for individual article abstracts, which is a separate retrieval mode not clearly justified by the stated journal-level macro-analysis purpose.

Static analysis

No suspicious patterns detected.