Back to skill

Security audit

Flexible Database Design – SQLite flexible schema & knowledge base skill

Security checks for vulnerabilities and agentic risk

Overview

The skill coherently helps users build a local SQLite-based archive, with no evidence of hidden exfiltration or deceptive behavior.

Install this only if you want an agent to help create and operate a local SQLite archive. Keep the database in a project-specific path, treat archived raw content and exports as potentially sensitive, do not use untrusted FLEXIBLE_DB_SCHEMA or extractor modules, pin optional Python packages in a virtual environment, and be careful opening CSV exports in spreadsheet apps.

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)

T08 · Insecure Dependencies

Note
Location
SKILL.md:99
Finding
Unpinned Third-Party Dependency Installation<![CDATA[ ## Vulnerability Details **File Locations**: - `SKILL.md:99` - `references/fulltext_chinese.md:38` **Vulnerability Type**: Uncontrolled third-party dependency versions **Risk Level**: Low ### Vulnerable Code Snippets `SKILL.md:99`: ```text 4. **For PDF/document content**: Extract the body text before archiving (pypdf is recommended: `pip install pypdf`); skip scanned documents when text cannot be extracted. ``` `references/fulltext_chinese.md:38`: ```text | **jieba tokenization** | `jieba.lcut("煤炭期货价格")` → `["煤炭","期货","价格"]` | Requires `pip install jieba` | ``` ### Technical Analysis The Skill recommends installing `pypdf` and `jieba` directly from the package index without specifying reviewed versions, hashes, a lock file, or an isolated environment. Consequently, the code installed by an agent or user may differ from the code that existed when the Skill was audited. This is a supply-chain hardening weakness rather than evidence that either named package is currently malicious. Exploitation would require compromise of the package distribution channel, a malicious future release, or another package-resolution failure. ### Attack Path 1. An attacker compromises a referenced package or its distribution channel, or publishes a malicious future version. 2. A user or agent follows the Skill instruction and runs `pip install pypdf` or `pip install jieba`. 3. The package manager resolves the unconstrained dependency to the affected release. 4. Package installation or later import executes attacker-controlled code under the privileges of the user or agent running Python. ### Impact Assessment Successful exploitation could execute arbitrary Python code with the permissions of the installing user or agent. Depending on those permissions, the payload could read or modify project files, access user-readable data, alter the Python environment, or invoke available network and operating-system functionality. The Skill does not itself retrieve or execute a ...[truncated 177 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Define reviewed dependency versions in a requirements or lock file, for example: ```text pypdf==REVIEWED_VERSION --hash=sha256:REVIEWED_HASH jieba==REVIEWED_VERSION --hash=sha256:REVIEWED_HASH ``` 2. Generate and verify hashes using a dependency-locking tool such as `pip-tools`. 3. Install dependencies in an isolated virtual environment rather than the agent's global Python environment. 4. Use a trusted package index and configure package-index allowlisting where available. 5. Review dependency release notes and provenance before updating locked versions. 6. Change the documentation to direct users to the reviewed dependency file instead of issuing unconstrained `pip install` commands. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/query_items.py:116
Finding
Spreadsheet Formula Injection in CSV Exports<![CDATA[ ## Vulnerability Details **File Location**: `scripts/query_items.py:116-126` **Vulnerability Type**: CSV/spreadsheet formula injection **Risk Level**: Medium ### Vulnerable Code Snippet ```python else: if not rows: out = "record_id,source,content_type,raw_content,created_at,extracted\n" else: buf = io.StringIO() w = csv.DictWriter(buf, fieldnames=["record_id", "source", "content_type", "raw_content", "created_at", "extracted"], extrasaction="ignore") w.writeheader() w.writerows(rows) out = buf.getvalue() ``` ### Technical Analysis The exporter passes database-controlled values directly to `csv.DictWriter`. CSV quoting correctly preserves the file structure, but it does not prevent spreadsheet applications from interpreting cell contents as formulas. Fields including `source`, `raw_content`, and `extracted` can contain imported or archived content. If a value begins with a formula indicator such as `=`, `+`, `-`, or `@`, spreadsheet software may evaluate it when a user opens the exported CSV. Depending on the spreadsheet product and its security configuration, formulas may initiate external requests, expose data through URLs, or invoke other dangerous spreadsheet features. For example, an attacker-controlled record could contain a value beginning with a hyperlink or web-service formula. The current export path writes that value without neutralization. ### Attack Path 1. An attacker supplies content through `archive_item.py`, a JSON import, or a CSV import. For example, the `raw_content` or `source` value begins with `=`, `+`, `-`, or `@`. 2. The record is stored in the SQLite database without modification. 3. A user runs: ```bash python3 scripts/query_items.py --export csv --output export.csv ``` 4. `csv.DictWriter.writerows()` writes the attacker-controlled value directly into a cell. 5. The user opens `export.csv` in formula-capable spreadsheet software. 6. The spreadsheet interp ...[truncated 752 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Sanitize every string destined for CSV output. Prefix cells that begin with formula indicators with a single quote: ```python def neutralize_csv_formula(value): if isinstance(value, str) and value.startswith(("=", "+", "-", "@")): return "'" + value return value ``` 2. Apply the function to every exported field before calling `writerows()`: ```python safe_rows = [ {key: neutralize_csv_formula(value) for key, value in row.items()} for row in rows ] w.writerows(safe_rows) ``` 3. Consider treating leading tabs, carriage returns, line feeds, and whitespace followed by a formula indicator as dangerous because spreadsheet behavior varies. 4. Document whether CSV exports are intended for spreadsheet use and warn that exports produced by older versions may contain untrusted formulas. 5. Add tests covering values beginning with `=`, `+`, `-`, and `@`, including values preceded by whitespace or control characters. 6. Preserve an explicit raw-export option only if necessary, and clearly mark its output as unsafe to open in spreadsheet software. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (31)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
The declared description promises substantial functionality and guidance related to building a flexible SQLite-backed knowledge/archive system. However, the provided code chunk does not implement any of that behavior; it is only an empty tests package initializer. This is a material mismatch in primary purpose and actual behavior, since the code neither provides the described database-related capabilities nor any meaningful supporting implementation for them.

Ae1

High
Category
analysis-evasion
Content
2. 修改 `flexible_db.py` 中的 `db_path` 指向用户的 db 路径。
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Missing User Warnings

High
Confidence
97% confidence
Finding
This is the same core issue as the environment-controlled schema execution, framed as silent persistence modification: a schema script from an environment-controlled path is executed automatically without any user confirmation or trust check. In a library that may run inside agents or automation, silent execution of arbitrary SQL during initialization materially increases the risk of unauthorized data modification or destructive setup actions.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The README advertises activation phrases like building a personal knowledge base or collecting scattered information, which are common, broad user intents rather than narrowly scoped triggers. In agent ecosystems that auto-load or prioritize skills from conversational similarity, this can cause the skill to activate in many unrelated contexts and steer the agent toward executing local Python/database workflows without the user explicitly asking for this specific capability.

Lp3

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding
Without declared permissions the skill's intent is opaque and cannot be validated.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The description says the skill activates when users say things like "I want to build a knowledge base," "archive PDF reports," or "collect policies or scattered information." These phrases are broad, common task descriptions rather than tightly scoped trigger conditions, and the file does not provide exclusion conditions or a narrower activation context.

Natural-Language Policy Violations

Medium
Confidence
84% confidence
Finding
The title and core description are written in Chinese and label the skill as a general-purpose skill, but there is no indication that the user can opt into another language. For a broadly applicable skill, forcing one language without opt-in can violate language/locale policy expectations.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
This markdown file is natural-language documentation, and all headings and descriptions are presented only in Chinese. The policy requires flagging language/locale constraints when a skill forces a specific language without user opt-in or clear justification.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
This code file contains natural-language strings entirely in Chinese in the module docstring, help text, examples, and status messages. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified, which is not present here.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Content
return None
    mod_path, func_name = spec.rsplit(":", 1)
    try:
        mod = __import__(mod_path, fromlist=[func_name])
        return getattr(mod, func_name)
    except (ImportError, AttributeError) as e:
        logger.warning("抽取器加载失败 %s: %s", spec, e)
Confidence
89% confidence
Finding
The extractor is chosen from an environment variable or caller-provided string and then imported dynamically with no allowlist or trust boundary enforcement. If an attacker can influence FLEXIBLE_EXTRACTOR or the spec argument, they can cause arbitrary module loading and execution of module top-level code, which can lead to code execution in the context of the process.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
The module docstring and many user-facing string literals are written exclusively in Chinese, which imposes a specific language/locale without any opt-in or documented regional constraint. Under the policy, language-specific behavior should offer user choice or be clearly justified as region-specific.

Missing User Warnings

Medium
Confidence
86% confidence
Finding
This code creates directories and opens a SQLite database file, which can create or modify files on disk, but there is no user-facing disclosure such as a prompt, print, or explicit warning near the operation. The surrounding docstrings describe functionality but do not warn that running the skill will write to the local filesystem.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The code reads FLEXIBLE_DB_SCHEMA from the environment and passes the file contents directly into sqlite3.executescript(), which allows execution of arbitrary SQL from any local path the process can access. In this skill’s context, that goes beyond normal schema initialization and can modify or destroy data, attach other databases, create triggers, or otherwise alter application behavior if an attacker can influence environment variables or deployment configuration.

Missing User Warnings

Medium
Confidence
83% confidence
Finding
This method inserts raw content and extracted data into the database and commits it, creating persistent storage of potentially sensitive user data. The code logs only debug/status messages and does not provide a clear user-facing warning that submitted content will be retained locally.

Missing User Warnings

Medium
Confidence
80% confidence
Finding
The update flow first deletes existing dynamic_data rows for the record and then rewrites extracted content, which is a data-modifying operation with potential loss of prior structured state. There is no visible confirmation prompt or explicit warning to the user about this overwrite behavior.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The file's user-facing natural-language content, including the module description, CLI description, examples, and argument help text, is entirely in Chinese. This creates a language/locale constraint in the skill interface without any opt-in, alternative language option, or justification that the tool is region-specific.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
This code file contains user-facing docstrings, argparse descriptions, help text, and status messages exclusively in Chinese. The policy requires flagging language or locale constraints when a skill forces a specific language without user opt-in, and there is no indication here that the locale is optional or region-specific.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The export_data function serializes full rows including raw_content and writes them to an arbitrary output path. Although the code prints a success message after writing, there is no prior warning, confirmation, or explanatory comment/docstring disclosing that potentially sensitive database contents will be persisted to disk.

Natural-Language Policy Violations

Low
Confidence
82% confidence
Finding
The file presents core instructional content in Chinese and continues with Chinese invocation examples and descriptions, but does not state that the skill is intentionally Chinese-language only or offer an English/localized alternative. That can amount to an implicit language policy constraint without user opt-in.

Natural-Language Policy Violations

Low
Confidence
88% confidence
Finding
This markdown file is natural-language documentation, and all user-facing content is presented only in Chinese. The stated policy category requires flagging language or locale constraints when a skill forces a specific language without user opt-in or an explicitly justified regional scope.

Natural-Language Policy Violations

Low
Confidence
84% confidence
Finding
该 markdown 文档中的自然语言说明要求金额类字段“统一存元”,属于对单位/本地化约定的强制性要求。虽然这在财务场景中可能合理,但文档未说明是否仅适用于中国财报场景,也未提供其他币种或单位的选择,存在 locale/region 约束未明确告知的问题。

Natural-Language Policy Violations

Low
Confidence
77% confidence
Finding
该文件全文使用中文描述使用方式与约定,但没有说明这是面向特定中文用户群体的示例,亦未提供语言选择或英文等替代说明。按规则,若技能内容强制特定语言且无用户选择或明确合理范围,可能构成自然语言层面的语言/locale 政策问题。

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The SQL file contains operational comments only in Chinese ('添加复合索引', '执行前请备份'), which imposes a specific language on readers without any opt-in or documented reason for a locale restriction. This matches the language/locale policy category because the file's natural-language guidance is not presented in a user-selectable or justified form.

Natural-Language Policy Violations

Low
Confidence
94% confidence
Finding
The file's instructional comments are written only in Chinese, including the usage guidance telling the reader to adjust the schema based on SKILL.md. This imposes a specific language on users without offering an opt-in or documenting that the schema is intended for a Chinese-only or region-specific audience.

Natural-Language Policy Violations

Low
Confidence
88% confidence
Finding
The file's instructional comments are entirely in Chinese, including usage guidance for copying and executing the SQL examples. Under the policy, forcing a specific language without user opt-in can be a natural-language policy violation, and no alternative language or justification is provided here.

Static analysis

No suspicious patterns detected.