Back to skill

Security audit

knowledge-graph

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a coherent local knowledge-graph toolkit, but it exposes persistent memory storage and query/import paths with weak containment and input-safety controls that warrant review before installation.

Install only if you want a local, persistent knowledge graph that may record personal, project, message, document, account, and credential-reference metadata. Do not put raw secrets in it; use secret references only. Avoid exposing its SPARQL, natural-language query, RDF import, or export APIs to untrusted users unless you add escaping, path and URL allowlists, query limits, and dependency pinning.

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 (3)

T09 · Insecure Skill Coding Practices

Warning
Location
phase4/query_engine.py:42
Finding
SPARQL Injection Through Unsafe Template Substitution<![CDATA[ ## Vulnerability Details **File Location**: `phase4/query_engine.py:42-48`, `phase4/query_engine.py:253-287`, `phase4/query_engine.py:299-323`; related interpolation in `phase5/hybrid_query.py:197-214` and analogous query templates **Vulnerability Type**: SPARQL injection **Risk Level**: Medium ### Vulnerable Code ```python @dataclass class QueryTemplate: """A pre-built SPARQL query template with parameter substitution.""" name: str description: str sparql_template: str parameters: List[str] = field(default_factory=list) category: str = "general" def render(self, **kwargs) -> str: """Render the template with parameter values.""" result = self.sparql_template for param in self.parameters: if param in kwargs: result = result.replace(f"${{{param}}}", str(kwargs[param])) return result ``` Example vulnerable template: ```python QueryTemplate( name="find_entity_by_name", description="Find entities by name (partial match)", sparql_template=""" PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX dk-class: <https://domain-kit.midea.com/ontology/class/> SELECT ?entity ?type ?name ?description WHERE { ?entity rdf:type ?type . ?entity rdfs:label ?name . OPTIONAL { ?entity rdfs:comment ?description } FILTER(CONTAINS(LCASE(?name), LCASE("${name}"))) } LIMIT ${limit} """, parameters=["name", "limit"], category="entity", ) ``` Execution sink: ```python def execute(self, sparql: str) -> QueryResult: start = time.time() self._query_count += 1 try: results = self.graph.query(sparql) elapsed = (time.time() - start) * 1000 self._total_time_ms += elapsed bindings = [] if results.vars: var_names = [str(v) for v in results.vars] ...[truncated 3024 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Replace textual substitution with RDFLib prepared queries and `initBindings` for all data values. 2. Convert search text into `rdflib.Literal` values rather than embedding it in query source. 3. Allowlist entity types and validate identifiers against a restrictive syntax before using them in prefixed names. 4. Parse `limit` as an integer and enforce a safe range, such as `1` through `100`. 5. Reject `SERVICE`, graph update operations, and unexpected query forms when executing generated or predefined queries. 6. If arbitrary direct SPARQL is required, expose it only to trusted callers and enforce query timeouts and result limits. 7. Add regression tests containing quotes, braces, comments, prefixed-name delimiters, malformed limits, and `SERVICE` clauses. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
phase2/reasoner.py:76
Finding
Unrestricted RDF Source Loading Permits Local File Access and Remote Retrieval<![CDATA[ ## Vulnerability Details **File Location**: `phase2/reasoner.py:76-79`; equivalent behavior in `phase1/rdf_to_jsonl.py:47-61` **Vulnerability Type**: Unrestricted external resource loading **Risk Level**: Low ### Vulnerable Code Reasoner source loading: ```python def load_ontology(self, ontology_path: str, format: str = "turtle") -> None: """Load ontology definition (TBox).""" self.ontology_graph.parse(ontology_path, format=format) self.ns.bind_to_graph(self.ontology_graph) logger.info(f"Loaded ontology from {ontology_path} ({len(self.ontology_graph)} triples)") ``` RDF-to-JSONL conversion: ```python def convert(self, rdf_path: str, format: str = "turtle") -> Tuple[List[Dict], List[Dict]]: """ Convert an RDF file to JSONL records. Args: rdf_path: Path to RDF file (Turtle, RDF/XML, etc.) format: RDF serialization format Returns: Tuple of (entity_records, relation_records) """ graph = Graph() graph.parse(rdf_path, format=format) return self.convert_graph(graph) ``` ### Technical Analysis The public APIs pass caller-controlled source strings directly to `rdflib.Graph.parse()`. RDFLib source arguments are not necessarily limited to workspace-local files and may accept URL-like locations. No scheme allowlist, workspace containment check, file-size restriction, or explicit prohibition of network sources is applied. This differs from `scripts/ontology.py`, whose command-line file arguments are resolved beneath the current workspace. If these library methods are exposed through an application or Agent interface that accepts untrusted locations, an attacker can direct the process to parse a local file available to its operating-system account or request a remote resource accessible from the host. ### Attack Path 1. An application exposes `load_ontology()` or `convert()` using a caller-provided source location. 2. An attacker supplies an absolute local path, a path outside the ...[truncated 1034 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Accept file objects or validated local paths instead of arbitrary RDFLib source strings. 2. Resolve each input path and require it to remain beneath an explicitly configured data directory. 3. Reject values containing URL schemes unless remote loading is an intentional, separately authorized feature. 4. If remote loading is required, allowlist schemes, hosts, ports, and destinations; block loopback, link-local, private, and metadata-service addresses. 5. Enforce input size, parsing-time, and graph-triple limits. 6. Restrict accepted RDF formats to those required by the application. 7. Run parsing in a network-restricted and least-privileged environment. 8. Apply the same source validation consistently in both `DomainKitReasoner.load_ontology()` and `RdfToJsonlConverter.convert()`. ]]>

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding
Unpinned Runtime Dependencies Produce Non-Reproducible and Mutable Installations<![CDATA[ ## Vulnerability Details **File Location**: `requirements.txt:1-3` **Vulnerability Type**: Insecure dependency version constraints **Risk Level**: Low ### Vulnerable Code ```text rdflib>=7.0.0 owlrl>=6.2.0 pytest>=7.0.0 ``` ### Technical Analysis All dependencies use open-ended lower bounds. An installation performed at a later date may therefore resolve to package and transitive dependency versions that were not present during review or testing. The dependency file also includes `pytest`, a development and test dependency, in the same set as runtime packages. This increases the installed package surface in production environments. No evidence of dependency confusion, typosquatting, or a currently malicious package was identified. The risk arises from mutable resolution, absent integrity hashes, and unnecessary production dependencies. ### Attack Path 1. A user or automated deployment installs packages from `requirements.txt`. 2. The package resolver selects the newest versions satisfying the open-ended constraints. 3. Future or otherwise unreviewed package releases and transitive dependencies are downloaded. 4. Package installation or runtime behavior executes in the deployment environment. 5. A compromised, incompatible, or unexpectedly changed dependency affects the Skill despite the Skill source remaining unchanged. ### Impact Assessment Potential consequences include: - Non-reproducible builds and inconsistent behavior across installations. - Introduction of unreviewed dependency changes. - Increased exposure to future supply-chain compromise. - Unexpected parser, query, or network behavior caused by dependency changes. - A larger production attack surface due to installation of test tooling. Actual privileges depend on the account performing package installation and running the Skill. This finding does not establish that any listed dependency is currently malicious. ]]>
Remediation
<![CDATA[ ## Remediation Suggestions 1. Pin direct dependencies to versions that have been reviewed and tested. 2. Generate a lock file containing transitive dependency versions and cryptographic hashes. 3. Separate runtime and development dependencies, moving `pytest` into a development or test requirements file. 4. Use automated dependency vulnerability scanning and controlled update reviews. 5. Prefer a trusted package index or internal mirror in sensitive deployment environments. 6. Rebuild and retest the lock file deliberately when dependencies are upgraded. ]]>
Vulnerability Patterns
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (46)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding
Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The supplied code chunk only implements an entity/relation type registry and validation layer for a domain schema. It statically defines entity and relation types and provides methods to register, retrieve, list, and validate them. While this is loosely related to ontology/schema management, it does not implement the declared major capabilities: OWL/RDFS inference, SPARQL querying, natural-language query handling, agent memory graph CRUD over graph data, planning, or cross-skill communication. Therefore the description substantially overstates the behavior shown in this code chunk.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
The declared description promises a broad knowledge-graph platform with reasoning and agent-oriented capabilities. However, the supplied code chunk is narrowly focused on data interop: importing converters for JSONL-to-RDF, RDF-to-JSONL, and schema mapping. There is no evidence here of CRUD over a memory graph, planning, cross-skill messaging, ontology reasoning, SPARQL execution, or natural-language querying. While JSONL/RDF conversion is related to knowledge graph data handling, the primary purpose of this code chunk is materially narrower than the declared description, so this is a mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared description promises a broad knowledge-graph platform: agent memory graph CRUD, planning, cross-skill communication, and OWL semantic reasoning/querying. The supplied code chunk is much narrower: it reads JSONL entity/relation files, maps them into RDF triples using rdflib, adds ontology header triples, converts fields into literals, and reifies relation confidence with blank nodes. There is no inference engine, no OWL RL/RDFS reasoning, no SPARQL execution, no NL query interface, no CRUD service layer, no planning logic, and no inter-skill messaging. The code is related to knowledge graphs, ontology, and RDF/OWL representation, so the general domain fits the triggers, but the implemented behavior materially underdelivers relative to the declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The declared description promises a broad knowledge-graph platform centered on agent memory graphs, CRUD, planning, inter-skill communication, and OWL/SPARQL/NL reasoning. The supplied code chunk does not implement those capabilities. It only reads RDF, reconstructs entity/relation records from triples, and writes JSONL. Although the domain is knowledge graphs/ontology-adjacent, the actual behavior is materially narrower and different in primary purpose: data conversion rather than semantic reasoning or full-stack graph operations. No suspicious extra permissions or external resource access are present, but the declared functionality significantly overstates what this code chunk does.

Tp4

High
Category
MCP Tool Poisoning
Confidence
89% confidence
Finding
The supplied code chunk is narrowly focused on semantic reasoning over RDF graphs and SPARQL querying. It does align with part of the description: ontology handling, OWL/RDFS reasoning, and SPARQL support are present. However, the declared purpose claims a broader 'full-stack' agent memory graph with CRUD, planning, and cross-skill communication, none of which appear in this module. It also mentions NL mixed querying, but the code only exposes raw SPARQL query execution and no natural-language query interface. Because the actual code covers only a subset of the declared capabilities and omits several central claimed functions, the description does not accurately represent this code chunk as a whole.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
There is a clear mismatch between the declared description and the supplied code. The description promises knowledge graph and ontology tooling with semantic reasoning and query features, but the code shown is a simple package initializer for a custom business rules engine. Nothing in this chunk indicates graph storage, ontology handling, semantic web reasoning, SPARQL support, or cross-skill communication. The exported symbols suggest a different primary purpose: business rule execution and conflict detection. The listed triggers are also unrelated to the observed code behavior.

Tp4

High
Category
MCP Tool Poisoning
Confidence
87% confidence
Finding
The declared description is broad and describes a comprehensive knowledge-graph and ontology system with multiple capabilities. The actual code shown is limited to an __init__.py for a SPARQL query engine and only re-exports query-related classes. Based on this chunk alone, it supports the SPARQL/query portion of the description but does not evidence the broader claimed functionality such as CRUD, planning, cross-skill communication, memory graph management, or OWL reasoning. Therefore the code chunk materially under-implements the declared primary purpose, making the description inaccurate for the supplied code.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding
该代码块的主功能与文件名、文档字符串一致,都是 SPARQL 查询执行与模板封装。虽然声明中的“SPARQL”与“知识图谱/本体”关键词部分吻合,但声明显著扩大了能力范围,尤其是 CRUD、通用 Agent 记忆图谱、规划、跨 skill 通信、OWL 语义推理和自然语言混合查询等关键特性,在此代码片段中都没有实现迹象。仅导入 OWL/RDFS 命名空间不等于进行了语义推理;仅支持 SPARQL 查询也不等于全栈知识图谱系统。因此描述与实际代码行为存在明显能力夸大和主用途范围不一致,应判定为 mismatch。

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding
声明描述的是一个覆盖面很广的知识图谱全栈技能,而实际代码片段只显示 phase5 模块导出 `HybridQueryEngine`,且文档字符串明确限定在“自然语言转 SPARQL 并带回退”的混合查询功能。该代码与声明中的一小部分(SPARQL/NL 混合查询)一致,但没有证据表明其实现了记忆图谱、CRUD、规划、跨 skill 通信或 OWL 推理等核心能力。因此,代码实际行为与声明的主要用途相比明显更窄,构成描述与行为不一致。

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding
声明描述的是一个范围很广的知识图谱全栈能力集合,包括记忆图谱 CRUD、规划、跨技能通信以及 OWL 语义推理。给出的代码片段则聚焦于查询侧功能:通过正则模式匹配识别中文查询意图,生成少量固定模板的 SPARQL,或回退到 RDF 图中的 RDFS.label / SKOS.altLabel 关键词匹配,并返回查询结果与日志统计。虽然这与声明中的“SPARQL/NL混合查询”部分相关,也导入了 reasoner,但代码中并未实际调用推理流程,也没有 CRUD、跨 skill 通信、Agent 记忆管理或规划相关实现。因此该片段的实际行为只覆盖了声明中的一小部分,且主功能明显比声明窄,构成描述与行为不匹配。

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description promises a broad, feature-rich knowledge graph and ontology system with reasoning and query capabilities. However, the provided code chunk only contains an __init__.py that imports and exports a ProtegeExporter class for a visualization/export phase. This is a much narrower purpose focused on Protégé export, with no evidence in the chunk of CRUD operations, planning, inter-skill communication, OWL/RDFS reasoning, or SPARQL/NL query handling. Therefore the code chunk does not accurately represent the declared primary purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared description promises a broad knowledge-graph platform with agent memory, CRUD, planning, cross-skill communication, and semantic reasoning/query features. The supplied code chunk does not implement those capabilities. It only serializes an existing RDF graph to Protégé-compatible formats and provides a basic triple/class-count summary. While export is related to knowledge graphs and ontology tooling, the primary purpose of this code is much narrower and materially different from the declared full-stack reasoning/query/agent-memory functionality.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The code does implement part of the declared knowledge-graph CRUD functionality: entity and relation storage, querying by exact property match, schema storage, and validation. However, the description prominently claims advanced ontology and semantic-reasoning capabilities—OWL inference, RDFS/OWL Lite/OWL RL, SPARQL, and NL mixed queries—which are not present in the code. Instead, validation is limited to handcrafted schema checks (required/forbidden properties, enums, relation type/cardinality, acyclic graphs, and one special Event date rule). There is also no evidence of planning or cross-skill communication despite those being listed in the declared purpose. Therefore the description materially overstates the actual behavior.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding
There is a clear mismatch between the declared description and the provided code. The description claims substantial knowledge-graph and semantic-reasoning functionality, but the actual code chunk is only a placeholder test package file with no observable behavior beyond marking a directory as a Python package. This is not merely incomplete supporting code; the provided chunk does not implement or evidence any of the declared capabilities.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description promises a broad knowledge-graph and ontology system with agent memory, CRUD, planning, cross-skill communication, and semantic reasoning/query capabilities. The actual code shown only contains unit tests for foundational models and namespace management: property type handling, entity/relation serialization to JSONL, entity type validation, default registries, and RDF URI construction/binding. These are related to knowledge graph infrastructure, so the domain is adjacent, but the chunk does not implement or demonstrate the major advertised capabilities such as OWL reasoning, SPARQL querying, natural-language queries, planning, or inter-skill communication. Therefore the description materially overstates what this code chunk actually does.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding
The code chunk does not implement or exercise a general-purpose knowledge graph agent memory platform. Instead, it focuses narrowly on JSONL↔RDF conversion and schema mapping tests. While this is adjacent to knowledge graph data representation, the declared description emphasizes much broader capabilities: CRUD operations over an agent memory graph, planning, cross-skill communication, and semantic reasoning/query features (OWL/RDFS/SPARQL/NL). None of those capabilities are evident in this code chunk. The only overlap is basic RDF/ontology-oriented data handling, which is insufficient to substantiate the full declared purpose.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared description centers on a comprehensive knowledge-graph and ontology reasoning skill, including CRUD operations, agent memory/planning, cross-skill communication, OWL-family reasoning, and SPARQL/NL query support. However, the actual code shown is specifically a test suite for a business rules engine. While it does operate on RDF graphs and includes a simple transitive inference example, that is much narrower than the declared ontology reasoning and query capabilities. The primary purpose in this chunk is validating rule-engine behavior, not implementing the broad knowledge-graph platform described. Therefore the description does not accurately represent this code chunk.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The declared description presents a broad knowledge-graph agent memory platform with CRUD, planning, inter-skill communication, and OWL-based reasoning plus NL/SPARQL hybrid querying. However, the provided code is only a test file for Phase 4 SPARQL query functionality. It exercises SELECT queries, predefined/custom query templates, entity filtering, statistics, and performance metrics on an RDFLib graph. While this aligns partially with the SPARQL/knowledge-graph trigger area, the actual code shown does not evidence most of the major declared capabilities, especially reasoning, CRUD, planning, or cross-skill communication. Therefore the description materially overstates and misrepresents what this code chunk actually does.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description emphasizes a broad knowledge-graph agent platform with memory, CRUD operations, planning, inter-skill communication, and OWL/RDFS/SPARQL/NL reasoning/query features. In contrast, this code chunk only tests RDF graph export and Protégé compatibility. It does not implement or exercise reasoning, querying, CRUD workflows, planning, or cross-skill communication. While Protégé export is adjacent to ontology tooling, the primary behavior shown here is much narrower than the declared purpose, so the description does not accurately represent this specific code chunk.

Ae1

High
Category
analysis-evasion
Content
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
python3 scripts/ontology.py create --type Person --props '{"name":"Alice","email":"alice@example.com"}'
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Static analysis

No suspicious patterns detected.