Back to skill

Security audit

Local LLM Knowledge Base(本地大模型知识库·免 API Key)

Security checks for vulnerabilities and agentic risk

Overview

This knowledge-base skill needs review because its privacy promises are not enforced and its sensitive-data scan prints private information openly.

Before using confidential files, require a local-only endpoint, reject file symlinks outside the library, and mask scan output. Use a dedicated library folder and remember that summarization replaces its index. Prefer the official Ollama installer and verify optional packages separately. The bundled audit is not reliable evidence of network isolation. External installers and host permissions remain unverified; the local review and mocked checks found concrete privacy gaps, not evidence of intentional malware.

Vulnerability Patterns
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Vulnerability Patterns
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (11)

Tainted flow: 'OLLAMA_BASE' from os.environ.get (line 34, credential/environment) → requests.get (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · quickstart.py (reported line 83)May include surrounding context.

python
def check_ollama():
    """检查 Ollama 是否在线(带超时与异常分类)"""
    try:
        resp = requests.get(f"{OLLAMA_BASE}/api/tags", timeout=OLLAMA_TIMEOUT)
        if resp.status_code != 200:
            print(f"[!] Ollama 返回异常状态码: {resp.status_code}")
            return False

Tainted flow: 'OLLAMA_BASE' from os.environ.get (line 34, credential/environment) → requests.get (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · quickstart.py (reported line 124)May include surrounding context.

python
print(f"[2/5] requests 库: ✓ 已安装 (v{requests.__version__})")

    try:
        resp = requests.get(f"{OLLAMA_BASE}/api/tags", timeout=OLLAMA_TIMEOUT)
        if resp.status_code == 200:
            models = [m["name"] for m in resp.json().get("models", [])]
            print(f"[3/5] Ollama 服务: ✓ 在线(已装 {len(models)} 个模型)")

Code capability 'env' detected in quickstart.py but not covered by declared permissions.

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'env' capability that is not covered by the declared 'allowed-tools' preapproval. Review the host runtime's actual enforcement policy; runtime permissions are unknown unless separately verified, and this declaration alone does not establish a permission ceiling.

Content

No source excerpt is available for this finding.

Code capability 'shell' detected in quickstart.py but not covered by declared permissions.

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'shell' capability that is not covered by the declared 'allowed-tools' preapproval. Review the host runtime's actual enforcement policy; runtime permissions are unknown unless separately verified, and this declaration alone does not establish a permission ceiling.

Content

No source excerpt is available for this finding.

The configurable Ollama endpoint can send document contents off-machine despite the manifest's local-only privacy guarantee.

High
Category
Excessive Agency
Confidence
98% confidence
Finding

OLLAMA_BASE accepts an arbitrary remote URL, and generation requests send document chunks or knowledge-base context to that endpoint without a local-only check or explicit remote-use confirmation. This contradicts the advertised guarantee that documents never leave the machine and could expose confidential material through misconfiguration or environment manipulation; the default localhost endpoint is not itself malicious.

Content

No source excerpt is available for this finding.

Tainted flow: 'index_path' from os.environ.get (line 188, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · quickstart.py (reported line 190)May include surrounding context.

python
index_path = os.path.join(LIBRARY_DIR, "00-index.md")
    if not os.path.exists(index_path):
        with open(index_path, "w", encoding="utf-8") as f:
            f.write("# 知识库索引\n\n")
            f.write(f"> 最后更新: {datetime.now().strftime('%Y-%m-%d %H:%M')}\n\n")
            f.write("| 文件 | 分类 | 摘要 | 更新日期 |\n")

Tainted flow: 'changelog' from os.environ.get (line 197, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · quickstart.py (reported line 199)May include surrounding context.

python
changelog = os.path.join(LIBRARY_DIR, "changelog.md")
    if not os.path.exists(changelog):
        with open(changelog, "w", encoding="utf-8") as f:
            f.write("# 变更日志\n\n")
            f.write(f"- {datetime.now().strftime('%Y-%m-%d')}: 图书馆初始化\n")
        print(f"  [创建] {changelog}")

The summarization prompt requires Chinese output without user opt-in.

Medium
Category
Output Handling
Confidence
99% confidence
Finding

The prompt explicitly instructs the model to summarize in Chinese ("请用中文"), regardless of the source document or user's preferred language. No language choice, opt-in, or documented locale-specific justification is provided.

Content

No source excerpt is available for this finding.

Tainted flow: 'index_path' from os.environ.get (line 281, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · quickstart.py (reported line 282)May include surrounding context.

python
return

    index_path = os.path.join(LIBRARY_DIR, "00-index.md")
    with open(index_path, "w", encoding="utf-8") as f:
        f.write("\n".join(index_lines) + "\n")

    print(f"\n[完成] 已处理 {count} 个文件,索引已更新: {index_path}")

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 · quickstart.py (reported line 458)May include surrounding context.

python
if not os.path.isdir(os.path.join(LIBRARY_DIR, ".git")):
                try:
                    import subprocess
                    subprocess.run(["git", "init", LIBRARY_DIR], check=True)
                    print("[OK] Git 已初始化(版本管理就绪)")
                except Exception as e:
                    print(f"[!] Git 初始化失败(可手动: cd {LIBRARY_DIR} && git init): {e}")

Tainted flow: 'LIBRARY_DIR' from os.environ.get (line 37, credential/environment) → subprocess.run (code execution)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · quickstart.py (reported line 458)May include surrounding context.

python
if not os.path.isdir(os.path.join(LIBRARY_DIR, ".git")):
                try:
                    import subprocess
                    subprocess.run(["git", "init", LIBRARY_DIR], check=True)
                    print("[OK] Git 已初始化(版本管理就绪)")
                except Exception as e:
                    print(f"[!] Git 初始化失败(可手动: cd {LIBRARY_DIR} && git init): {e}")