Back to skill

Security audit

Knowledge Graph - Graph Rule Engine Builder

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent local graph rule engine skill with no hidden access or persistence, though the bundled engine should not be treated as production-ready without fixes.

Use this skill as a reference or prototype aid. Before using the bundled engine in production or for fraud, compliance, recommendations, or other consequential decisions, add real cycle detection, deduplication, resource limits, tests, and human review for enforcement actions.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/graph_rule_engine.py:202
Finding

Unbounded Duplicate Inference Materialization Causes Resource Exhaustion

Content
View full analysis
None: """Add edge to graph.""" source = edge.get('source') target = edge.get('target') if source and target: if source not in self.edges: self.edges[source] = {} if target not in self.edges: self.edges[target] = {} if target not in self.edges[source]: self.edges[source][target] = [] self.edges[source][target].append(edge) ``` ### Technical Analysis The engine stores inferred fact identities in the `inferred_facts` set, which deduplicates tuples of `(source, target, relationship type)`. However, the result of the set i ...[truncated 2793 chars]
Remediation
View remediation
bool: source = edge.get("source") target = edge.get("target") rel_type = edge.get("type") if not source or not target: return False fact = (source, target, rel_type) if fact in self.inferred_facts: return False self.inferred_facts.add(fact) self.edges.setdefault(source, {}) self.edges.setdefault(target, {}) self.edges[source].setdefault(target, []).append(edge) return True ``` 2. **Count only genuinely new facts** Increment `iteration_inferences` and `total_inferences` only when `_add_edge()` returns `True`. Do not use the raw length of `result.inferences_generated` for fixpoint detection. 3. **Use iteration-local deduplication** Deduplicate generated facts within each iteration before insertion. This prevents multiple matching rules or duplicate pattern matches from emitting the same fact repeatedly. 4. **Enforce configured safety controls** Implement the declared `cycle_detection` option and enforce each rule's `max_depth`. Reject or constrain self-referential and mutually recursive rule dependencies where appropriate. 5. **Apply explicit resource budgets** Add configurable limits for: - Maximum inferred facts. - Maximum total edges. - Maximum matches per rule. - Maximum execution time. - Maximum memory-oriented work units. - Maximum iterations, using a conservative default. Execution should terminate with a clear failure result when a limit is reached. 6. **Validate untrusted input** Before execution, estimate rule expansion risk and reject malformed, self-reinforcing, or excessively broad rules supplied by untrusted users. 7. **A ...[truncated 257 chars]
Vulnerability Patterns
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • 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
Findings (9)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The skill documentation claims capabilities such as conditional rules, aggregation, anomaly detection, broad pattern matching, and cycle detection that the underlying implementation reportedly does not provide. This is dangerous because downstream agents or users may rely on missing safety and correctness features—especially cycle detection and constraint/anomaly logic—leading to infinite loops, incomplete reasoning, false negatives in fraud/compliance use cases, or incorrect inferred facts.

Content

No source excerpt is available for this finding.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/graph_rule_engine.py (reported line 255)May include surrounding context.

python
if iteration_inferences == 0:
                break

        return RuleExecutionResult(
            rule_name="all_rules",
            matches_found=total_inferences,
            inferences_generated=list(self.inferred_facts),

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/graph_rule_engine.py (reported line 277)May include surrounding context.

python
if iteration_inferences == 0:
                break

        return RuleExecutionResult(
            rule_name="all_rules",
            matches_found=total_inferences,
            inferences_generated=list(self.inferred_facts),

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · scripts/graph_rule_engine.py (reported line 327)May include surrounding context.

python
if iteration_inferences == 0:
                break

        return RuleExecutionResult(
            rule_name="all_rules",
            matches_found=total_inferences,
            inferences_generated=list(self.inferred_facts),

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The collaborative filtering rule explicitly excludes products already purchased by the target user, but the example output includes a recommendation entry for "Monitor" with reason "Already purchased". This inconsistency can mislead implementers into building logic that leaks invalid recommendations into production pipelines, undermining data integrity and trust in downstream automated decisions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The manifest explicitly says the skill supports cycle detection, and the configuration exposes a cycle_detection flag, which suggests this capability is part of the intended behavior. However, no code path in execution, inference, or edge addition checks for cycles or uses this flag, so the delivered behavior does not match the stated capability.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file presents itself as a production-ready graph rule engine and the example usage defines conditions like "(a)-[works_at]->(company)<-[works_at]-(b)" and "(a)-[reports_to]->(b)<-[reports_to]-(c)". But the matcher only handles a single simple pattern of the form "(a)-[REL]->(b)", so the showcased rule syntax contradicts what the engine can actually parse and execute.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

This markdown example recommends "Block transactions and investigate," which is a potentially disruptive action affecting user data or system operations. The document presents the behavior as a best-practice example but does not include any warning or disclosure that such actions may be high-impact and should be reviewed before execution.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The function at L073-L105 infers a relationship between two source entities that share a common connection, specifically adding a COOCCUR_WITH edge between node_a and node_b. However, the example comment says the result is "User1 --RECOMMENDATION--> Product (via User2)", which contradicts the implemented behavior because it describes a recommendation edge to the shared product rather than a co-occurrence edge between the two users.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.