Back to skill

Security audit

Business Rule Engine

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent business-rule engine, but its dynamic rule evaluation can run unsafe Python expressions if rules are untrusted.

Install only if rule definitions come from trusted administrators or you first replace eval-based condition handling with a strict parser. Do not expose JSON or DSL rule creation to ordinary or external users without validation and authorization.

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

Error
Location
scripts/rule_engine.py:91
Finding

Arbitrary Python Expression Evaluation in Dynamically Loaded Rules

Content
View full analysis
bool: """安全求值 | Safe evaluation""" # 替换变量 | Replace variables expr = self._replace_variables(expression) # 解析逻辑运算符 | Parse logical operators expr = self._parse_logical_operators(expr) # 安全求值 | Safe evaluation try: result = eval(expr, {"__builtins__": {}}, {}) return bool(result) except: return False ``` Attacker-controlled rule conditions can reach this operation through JSON loading and DSL parsing: ```python def load_rules_from_json(self, json_str: str) -> None: rules_data = json.loads(json_str) for rule_data in rules_data: rule = Rule.from_dict(rule_data) self.add_rule(rule) ``` ```python if match: name = match.group(1) condition = match.group(2).strip() action_text = match.group(3).strip() ``` ### Technical Analysis The evaluator passes rule condition text to Python's `eval()` instead of interpreting it through a constrained business-rule grammar. Rule conditions may be loaded dynamically from JSON or parsed from DSL text and are not validated against an allowlist of permitted syntax. Supplying `{"__builtins__": {}}` does not create a reliable Python sandbox. Python expressions can access attributes and traverse the runtime object model. Depending on the objects and classes loaded into the hosting process, a crafted expression may reach powerful classes, callable objects, or globals and obtain capabilities that were intentionally removed from the evaluation namespace. The `_replace_variables()` operation is textual string replacement rather than syntactic parsing. It therefore neither enforces token boundaries nor prevents attribute access, function calls, comprehensions, dunder attributes, or other unsaf ...[truncated 2195 chars]
Remediation
View remediation
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (11)

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code explicitly labels the evaluation path as 'safe' while still executing attacker-controlled rule conditions via eval(), which creates a dangerous false sense of security. This is especially risky because the skill advertises dynamic rule loading, so conditions may come from external JSON or DSL input and be treated as data when they are actually executed as Python code.

Content

No source excerpt is available for this finding.

eval() call detected

High
Category
Dangerous Code Execution
Confidence
99% confidence
Finding

The engine evaluates rule conditions with Python's eval() after only naive string substitution of variables. Even with builtins removed, untrusted expressions can still lead to arbitrary code execution or sandbox escape techniques in some Python environments, and at minimum allow execution of unintended Python expressions, making this unsafe for dynamically loaded rules.

Content

Scanner excerpt · scripts/rule_engine.py (reported line 101)May include surrounding context.

python
# 安全求值 | Safe evaluation
        try:
            result = eval(expr, {"__builtins__": {}}, {})
            return bool(result)
        except:
            return False

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

python
# 解析动作 | Parse action
            action = RuleDSL._parse_action(action_text)
            
            return Rule(name=name, condition=condition, action=action)
        
        raise ValueError(f"Invalid rule syntax: {rule_text}")

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The manifest describes a lightweight business rule engine supporting rule definition, execution, chaining, and dynamic rule loading. register_action allows callers to inject arbitrary executable handlers into the engine, turning it into a general callback execution framework rather than just a constrained business-rule processor.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
20% confidence
Finding

After review, the file offers both Chinese and English throughout the description and headings. Because it provides language choice rather than enforcing one language, this does not meet the threshold for a genuine locale-policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file includes natural-language strings that default to Chinese alongside English labels, and the main user-facing flow appears to assume a Chinese-speaking context. Under the policy, forcing or assuming a specific language without opt-in can be a locale-policy issue unless the constraint is explicitly justified.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
93% confidence
Finding

The dependency is specified with a lower bound only, which allows installation of any newer release and makes builds non-reproducible. While this file only lists test tooling, unpinned versions can still pull in unexpected or vulnerable releases through normal dependency resolution or supply-chain compromise.

Content

Scanner excerpt · requirements.txt (reported line 1)May include surrounding context.

text
pytest>=7.4.0
pytest-cov>=4.1.0

Unverifiable Dependency: pytest has 2 known advisory(ies) (CVE-2025-71176 (pytest has vulnerable tmpdir handling); CVE-2025-71176 (pytest has vulnerable tmpdir handling)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
76% confidence
Finding

The manifest does not pin pytest, and static analysis indicates known advisories may affect some pytest versions. Because the installed version is unconstrained above 7.4.0, environments could resolve to an affected release without the maintainer realizing it.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
92% confidence
Finding

pytest-cov is also unpinned, so dependency resolution may install different versions over time, reducing reproducibility and increasing supply-chain risk. In this context it is a development/test dependency, so the danger is lower than a runtime production package but still real.

Content

Scanner excerpt · requirements.txt (reported line 2)May include surrounding context.

text
pytest>=7.4.0
pytest-cov>=4.1.0

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The module header and many subsequent docstrings/messages are hard-coded as bilingual Chinese/English, with Chinese presented as a required default rather than a user-selected locale. Under the policy for natural-language violations, forcing a specific language or locale without opt-in can be flagged when no choice mechanism is provided.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

This code file contains a natural-language comment in Chinese ('添加scripts目录到路径'), which imposes a specific language for part of the skill's human-readable guidance. Under the policy rule, language-specific text should either offer user opt-in/choice or be clearly justified as locale-specific; neither is present here.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.dynamic_code_execution

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
scripts/rule_engine.py:101