Back to skill

Security audit

MNN Local Knowledge Base

Security checks for vulnerabilities and agentic risk

Overview

This is a useful local knowledge-base skill, but it has review-worthy privacy and filesystem-scope risks before installation.

Install only if you are comfortable with persistent local indexing of selected files and notes. Use --no-llm or remove llm_api.base_url unless you explicitly want retrieved private KB excerpts sent to a remote LLM provider, restrict KB names to simple safe identifiers, and prefer a pinned, verified local model before using this with confidential data.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (3)

other

Error
Location
scripts/py_mnn_kb.py:2985
Finding

Private knowledge-base content is transmitted to an external LLM by default

Content
View full analysis
str: """Call OpenAI-compatible LLM API for RAG generation.""" try: import openai except ImportError: print("[LLM] openai package not installed. Install: pip install openai", file=sys.stderr) return "" base_url = cfg_llm.get("base_url", "http://localhost:11434/v1") api_key = cfg_llm.get("api_key", "none") model = cfg_llm.get("model", "qwen2.5:7b") max_tokens = cfg_llm.get("max_tokens", 2048) temperature = cfg_llm.get("temperature", 0.7) system_prompt = cfg_llm.get("system_prompt", "You are a helpful assistant. Answer the question based on the provided context.") client = openai.OpenAI(base_url=base_url, api_key=api_key) user_content = f"Context:\n{context}\n\nQuestion: {prompt}" print(f"[LLM] Calling {model} @ {base_url} ...", file=sys.stderr) print(f"[LLM] Context: {len(context)} chars, question: {len(prompt)} chars", file=sys.stderr) try: response = client.chat.completions.create( model=model, messages=[ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_content} ], max_tokens=max_tokens, temperature=temperature, stream=True ) ``` The normal query path invokes this function unless the caller explicitly supplies `--no-llm`: ```python if args.no_llm: if args.output == "text": lines = [f"[Retrieved {doc_count} documents from KB '{kb_name}']"] for part in context.split("\n ...[truncated 4491 chars]
Remediation
View remediation

T08 · Insecure Dependencies

Error
Location
scripts/py_mnn_kb.py:123
Finding

Embedding model artifacts are downloaded from mutable URLs without integrity verification

Content
View full analysis
None: """ Check if the embedding model exists; if not, auto-download from ModelScope. Only downloads missing files. Skips download if all required files are present. """ model_path = Path(model_dir) model_name = model_path.name file_map = _MODEL_FILES.get(model_name) if file_map is None: return missing = [f for f in _REQUIRED_MODEL_FILES if not (model_path / f).exists()] if not missing: return print(f"[ModelDownload] Model not found at: {model_path}", file=sys.stderr) print(f"[ModelDownload] Auto-downloading {model_name} from ModelScope ...", file=sys.s ...[truncated 4327 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/py_mnn_kb.py:2260
Finding

Unvalidated knowledge-base names allow filesystem writes outside the configured storage directory

Content
View full analysis
None: storage = Path(self.cfg["knowledge_base"]["storage_dir"]) kb_dir = storage / kb_name kb_dir.mkdir(parents=True, exist_ok=True) ``` Metadata is later written to the resulting path: ```python metadata_path = kb_dir / "metadata.json" with open(metadata_path, "w", encoding="utf-8") as f: json.dump(metadata_json, f, ensure_ascii=False, separators=(",", ":")) ``` The database path is constructed in the same unsafe manner: ```python def _get_db(self, kb_name: str = None) -> KnowledgeGraphDB: """Open (or create) knowledge base database.""" name = kb_name or self.cfg["knowledge_base"]["default_name"] storage = Path(self.cfg["knowledge_base"]["storage_dir"]) kb_dir = storage / name kb_dir.mkdir(parents=True, exist_ok=True) db_path = str(kb_dir / "knowledge_graph.db") return KnowledgeGraphDB(db_path, name) ``` The CLI accepts the value without validation and passes it into the background process: ```python kb_name = args.kb or cfg["knowledge_base"]["default_name"] config_path = args.config or str(_HERE / "config.json") cmd = [ sys.executable, str(Path(__file__).resolve()), "--config", str(config_path), "_bg_build", "--dir", str(input_path.resolve()), "--kb", kb_name, ] ``` ### Technical Analysis `kb_name` is treated as a directory component but is not constrained to a simple name. Python path joining permits traversal components such as `..`. If the right-hand operand is absolute, it can also replace the configured storage prefix entirely. For example, if the configured storage ...[truncated 2173 chars]
Remediation
View remediation
Path: if not _VALID_KB_NAME.fullmatch(kb_name): raise ValueError("Invalid knowledge-base name") root = Path(storage_dir).resolve() candidate = (root / kb_name).resolve() if candidate.parent != root: raise ValueError("Knowledge-base path escapes storage directory") return candidate ``` ]]>
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
Findings (31)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The skill is presented as a local/offline private knowledge-base, but the documentation explicitly states that first use auto-downloads a model and setup references an OpenAI-compatible API key for query+LLM. This creates a material description/behavior mismatch: users may entrust sensitive data to a skill they believe is fully local, while network access and related side effects may occur.

Content

No source excerpt is available for this finding.

Ssd 1

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documented usage pattern appends retrieved KB content directly into the model prompt. Because stored documents and notes are untrusted content, this enables prompt injection via the knowledge base: malicious or manipulative text can instruct the model to ignore prior directions, leak secrets, or alter behavior when later retrieved.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
97% confidence
Finding

The script spawns background subprocesses but the finding says shell/process capability is not declared. Undeclared execution capability is sensitive because it can be abused for persistence, evasion, or operational actions outside the apparent scope of a knowledge-base skill.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
97% confidence
Finding

The script spawns background subprocesses but the finding says shell/process capability is not declared. Undeclared execution capability is sensitive because it can be abused for persistence, evasion, or operational actions outside the apparent scope of a knowledge-base skill.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
97% confidence
Finding

The script spawns background subprocesses but the finding says shell/process capability is not declared. Undeclared execution capability is sensitive because it can be abused for persistence, evasion, or operational actions outside the apparent scope of a knowledge-base skill.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
97% confidence
Finding

The script spawns background subprocesses but the finding says shell/process capability is not declared. Undeclared execution capability is sensitive because it can be abused for persistence, evasion, or operational actions outside the apparent scope of a knowledge-base skill.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The query path can send retrieved KB context, including potentially private user notes and indexed documents, to an external OpenAI-compatible LLM endpoint. This directly conflicts with the skill's framing as a local private knowledge base, making accidental exfiltration of sensitive data a serious confidentiality risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The README emphasizes local/private knowledge storage but also advertises optional LLM-backed querying without clearly warning that retrieved KB content may be sent to a remote API. In a privacy-oriented skill, this can mislead operators and users into exposing sensitive documents or notes under the assumption everything remains local.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The configuration instructions require an API key for query with LLM but do not explain that enabling this path sends user prompts and likely retrieved knowledge-base context to a third-party service. Because the tool is positioned for private knowledge management, omission of that warning creates a real risk of inadvertent sensitive data disclosure.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill encourages saving arbitrary dictation, chat fragments, webpage summaries, and uploaded files into a retrievable KB with no sensitivity screening, retention limits, or access-control guidance. This increases the chance that secrets, credentials, regulated data, or private conversations are stored and later surfaced or forwarded through downstream query workflows.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The agent prompt guidance directly instructs appending retrieved KB context into an LLM prompt, which operationalizes exfiltration of stored private material to an external model endpoint if one is configured. In an agent setting, this is more dangerous because the transfer can happen automatically, at scale, and without a user-visible consent step per query.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Using an open-ended trigger such as 'or similar intent' broadens activation beyond clearly defined commands, increasing the chance the skill will capture or retrieve private knowledge when the user did not specifically request KB operations. In a persistence-oriented skill, accidental activation is more dangerous because it can store sensitive content or influence later responses.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The skill stores notes and indexed files in a persistent SQLite-backed knowledge base but does not prominently warn users that private information may be retained locally. In a tool specifically designed for memory and document ingestion, lack of disclosure increases the likelihood of users storing sensitive data without understanding retention implications.

Content

No source excerpt is available for this finding.

Ssd 4

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The workflow explicitly supports storing arbitrary user-provided content and later retrieving it into the model prompt, creating a staged prompt-injection path. This delayed-execution pattern is dangerous because harmful instructions can be planted during ingestion and only activate later during unrelated queries, making detection harder.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Broad phrases like 'save this' and 'remember this' are common conversational language and can cause accidental invocation of a persistent storage tool. In this skill's context, mistaken activation can silently place private or transient user content into a long-lived local database.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The kb_query section claims no internal LLM call is made, yet the setup and CLI examples indicate query may use an external OpenAI-compatible API unless --no-llm is specified. This inconsistency can mislead operators about whether query contents may leave the local environment, risking unintended disclosure of sensitive knowledge-base data or user queries.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The phrase '查一下' is highly ambiguous and could refer to general searching or checking rather than querying a persistent private knowledge base. This raises the risk of unnecessary retrieval from stored private content and of introducing retrieved content into downstream prompts without the user's informed intent.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill is described as a local/private knowledge base, but the configuration explicitly supports sending user queries and retrieved context to an external OpenAI-compatible API. In a knowledge-base skill that is meant to store and retrieve potentially private user data, this creates a clear risk of unintended exfiltration of sensitive content and violates user expectations about local-only processing.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
98% confidence
Finding

The configured base URL points to an external API endpoint, so prompts and potentially retrieved knowledge-base context can be transmitted outside the local environment. Because this skill is intended for storing and querying private knowledge, external transmission materially increases confidentiality risk and can expose sensitive notes, records, or embeddings-derived context to third parties.

Content

Scanner excerpt · config.example.json (reported line 54)May include surrounding context.

json
"llm_api": {
        "_comment": "LLM API for RAG generation (query command). Any OpenAI-compatible endpoint works.",
        "base_url": "https://api.deepseek.com/v1",
        "api_key": "YOUR_API_KEY_HERE",
        "model": "deepseek-chat",
        "max_tokens": 16384,

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill automatically downloads model artifacts from ModelScope when files are missing, despite being presented as a local KB tool. This creates an unexpected network dependency and supply-chain exposure, especially if users expect offline behavior and private-document processing without contacting external services.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This Python file contains natural-language and locale assumptions embedded in behavior: entity records are always inserted with language "zh", and some extracted training text is reformatted with Chinese labels such as 指令/输入/输出/系统. That forces a specific language/locale treatment without user opt-in, which matches the policy-violation category for language or locale constraints.

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

python
CREATE_NEW_PROCESS_GROUP = 0x00000200
        creation_flags = DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP
        log_f = open(build_log, "w", encoding="utf-8", errors="replace")
        proc = subprocess.Popen(
            cmd,
            stdout=subprocess.DEVNULL,
            stderr=log_f,

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

python
log_f.close()
    else:
        log_f = open(build_log, "w", encoding="utf-8", errors="replace")
        proc = subprocess.Popen(
            cmd,
            stdout=subprocess.DEVNULL,
            stderr=log_f,

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The natural-language description explicitly fixes the skill content to Chinese and English stopword sets. Because the file does not mention any language selection, opt-in, or region-specific justification, this can be read as a locale/language constraint that may conflict with the policy requirement to avoid forcing a language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
75% confidence
Finding

This JSON manifest-like data sets the domain and description in Chinese and most entries are primarily Chinese terms, which can imply a fixed language/locale assumption. Under the policy rule, forcing a specific language without user choice or documented justification can be a natural-language policy concern.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.