Back to skill

Security audit

Chatbot Engine

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent chatbot engine skill with expected local state, retrieval, and optional LLM-provider behavior, but users should review privacy and dependency hygiene before use.

Install in an isolated environment, pin and review dependencies before production use, and only enable OpenAI or Anthropic providers if users understand that prompts and conversation context may be sent to those services. Keep custom regex intent definitions and plugin objects limited to trusted administrators.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/intent_classifier.py:33
Finding

Unrestricted Regular Expressions Can Cause Denial of Service

Content
View full analysis

Vulnerability Details

File Location: scripts/intent_classifier.py, lines 33-67
Vulnerability Type: Regular Expression Denial of Service (ReDoS)
Risk Level: Medium

Vulnerable Code

python
def add_intent(self, name: str, patterns: List[str],
               keywords: Optional[List[str]] = None):
    """
    添加意图

    Args:
        name: 意图名称
        patterns: 匹配模式 (支持正则)
        keywords: 关键词列表
    """
    self.intents[name] = {
        'patterns': patterns,
        'keywords': keywords or []
    }
    self.patterns[name] = patterns
    self.keywords[name] = keywords or []

def classify(self, text: str) -> Dict:
    """
    分类文本意图

    Returns:
        {'intent': str, 'confidence': float, 'entities': dict}
    """
    text = text.lower()
    scores = {}

    for intent_name, config in self.intents.items():
        score = 0.0
        entities = {}

        # 模式匹配
        for pattern in config['patterns']:
            if re.search(pattern, text, re.IGNORECASE):
                score += 0.5
                # 提取实体 (简化版)
                matches = re.findall(pattern, text, re.IGNORECASE)
                if matches:
                    entities['match'] = matches[0]

Technical Analysis

The classifier accepts unrestricted regular-expression patterns through add_intent() and also supports loading these patterns from JSON configuration. It evaluates each configured expression against message text using Python's backtracking re engine.

A malicious or accidentally pathological expression, such as one containing nested ambiguous quantifiers, can require exponential processing time for a carefully constructed nonmatching input. The implementation compounds this risk by evaluating a successful pattern twice, first with re.search() and then with re.findall().

The exploitability depends on whether an attacker can create or influence intent configurations. Even when configuration access is restricted to administrators, a malform ...[truncated 1173 chars]

Remediation
View remediation

Remediation Suggestions

  • Restrict intent-pattern creation and configuration loading to trusted administrators.
  • Validate expressions before accepting them and reject nested, ambiguous quantifiers and other known catastrophic-backtracking constructs.
  • Enforce conservative maximum lengths for both patterns and classified messages.
  • Use a regular-expression implementation that supports strict execution timeouts, or run matching in a separately constrained process.
  • Prefer literal, token-based, or finite-state matching when full regular-expression capabilities are unnecessary.
  • Avoid evaluating the same expression twice. Retain the match object returned by a single operation and extract the required match from it.
  • Add automated tests containing pathological expressions and long adversarial inputs.
  • Apply request timeouts, CPU limits, concurrency limits, and rate limiting as defense-in-depth controls.

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Unbounded Dependencies Make Installations Non-Reproducible

Content
View full analysis

Vulnerability Details

File Location: requirements.txt, lines 1-5
Vulnerability Type: Unpinned Third-Party Dependencies and Incomplete Dependency Declaration
Risk Level: Low

Vulnerable Code

text
openai>=1.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0
regex>=2023.0.0

The documented installation command in README.md and SKILL.md is:

bash
pip install -r requirements.txt

The implementation also imports a package that is absent from the dependency manifest:

python
from fuzzywuzzy import fuzz
from fuzzywuzzy import process as fuzzy_process

Technical Analysis

Every declared dependency has only a lower bound and no upper bound, exact version, lock file, or integrity hash. Consequently, installations performed at different times can resolve to different package versions. A future compromised, vulnerable, or incompatible release satisfying the lower bound could be installed automatically.

In addition, scripts/knowledge_base.py imports fuzzywuzzy, but that package is not declared in requirements.txt. This creates an incomplete software bill of materials and may encourage operators to install an unreviewed package manually. The audit found no evidence that the currently named packages are malicious; the finding concerns avoidable supply-chain exposure and lack of reproducibility.

Attack Path

  1. A user follows the documented installation procedure.
  2. pip resolves each dependency from the configured package index at installation time.
  3. Because no exact versions or hashes are specified, a newer release satisfying the lower bound can be selected without repository changes or renewed review.
  4. If such a selected release or one of its transitive dependencies is compromised, its installation or runtime code executes with the privileges of the installing or running user.
  5. Separately, startup of knowledge_base.py can fail because fuzzywuzzy is undeclared, prompting an o ...[truncated 597 chars]
Remediation
View remediation

Remediation Suggestions

  • Generate and commit a reviewed lock file containing exact direct and transitive dependency versions.
  • Require package hashes during installation, such as through a hash-locked requirements file and pip --require-hashes.
  • Declare fuzzywuzzy explicitly or replace it with a maintained, reviewed alternative.
  • Remove dependencies that are not actually used by the project to reduce the supply-chain attack surface.
  • Configure installation to use approved package indexes and disable unexpected fallback indexes.
  • Use automated dependency vulnerability and provenance scanning in continuous integration.
  • Establish a controlled update process that reviews release notes, security advisories, licenses, and test results before changing locked versions.
  • Install dependencies in an isolated virtual environment or container under a nonprivileged account.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The declared purpose is a multi-turn chatbot with intent recognition, but the detected behavior includes knowledge/document management, semantic retrieval, and local JSON persistence while apparently lacking the claimed intent-classification capability. This mismatch is dangerous because reviewers and users may grant trust or permissions based on the stated purpose, while the actual implementation handles broader data access and persistence than expected, which can conceal risky functionality.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language description uses Chinese exclusively ("智能对话引擎。") while the file does not indicate that the skill is region-specific or that users can opt into this language. This can violate language/locale policy because it implicitly forces a specific language without user choice or justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
82% confidence
Finding

The skill advertises executable capabilities consistent with environment access and local file read/write, but the manifest shown in SKILL.md does not declare any explicit tool scope or permissions boundary. That creates an authorization and transparency gap: a host or reviewer cannot easily determine what the skill is allowed to access, increasing the risk of unintended data exposure or filesystem modification if the implementation is invoked.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This Python file is a code file, so only SQP-2 and SQP-3 apply. The user-facing strings, sample prompts, and docstrings are consistently in Chinese throughout the file, which implies a fixed language/locale experience without any opt-in or alternative language path.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This file contains natural-language descriptions, docstrings, and default responses in Chinese only, including the module title and chatbot reply text. Because the skill does not provide user opt-in or explain that it is intentionally region- or language-specific, it may violate a language/locale policy requiring user choice.

Content

No source excerpt is available for this finding.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/chatbot.py (reported line 16)May include surrounding context.

python
"""对话消息"""
    role: str  # 'user', 'assistant', 'system'
    content: str
    timestamp: float = field(default_factory=lambda: __import__('time').time())


class ChatBot:

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module title and all user-facing responses are written in Chinese, indicating the skill is designed to interact in a fixed language. The file does not offer a language/locale choice or explain that the skill is intentionally limited to a Chinese-speaking context, which matches the policy's language/locale violation criterion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The file’s docstrings, printed messages, comments, test data, and several default intent patterns are written in Chinese, indicating the skill is designed to operate in a specific language/locale by default. There is no natural-language indication that users may opt into another language or that the locale restriction is documented as a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file uses Chinese exclusively in its title, class/method docstrings, status messages, and example interactions. Because the skill does not offer a language option or explain that it is intentionally region-specific, it appears to impose a specific language/locale without user opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
73% confidence
Finding

The natural-language descriptions and built-in mock responses are written only in Chinese, and there is no indication that users can choose another language or locale. That may violate a language-choice policy if the skill is expected to support user language preference rather than implicitly forcing one locale.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

This code sends assembled conversation messages, which may include user prompts and prior context, to OpenAI without any visible consent, disclosure, or data-minimization guardrails in this component. In a chatbot engine handling multi-turn dialogue, context can contain sensitive user data, making silent third-party transmission a real privacy and compliance risk.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The Anthropic path transmits the user's prompt to an external service with no visible notice or consent mechanism in this file. Although only the prompt is sent here rather than full context, it still creates a privacy exposure because user input may contain confidential or regulated information.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This test file contains user-facing and descriptive natural-language text entirely in Chinese, including prompts and test descriptions, but does not indicate that the skill is intentionally Chinese-only or provide any user opt-in for language selection. Under the policy, forcing a specific language without opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency is specified with a lower bound only, which allows future unreviewed versions to be installed. This weakens build reproducibility and can expose deployments to breaking or vulnerable upstream releases introduced after the skill was authored.

Content

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

text
openai>=1.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
98% confidence
Finding

Using scikit-learn with only a minimum version means installations may resolve to different releases over time, including versions with known security defects or incompatible behavior. In a conversational engine that may process user-controlled inputs, uncertainty around the installed ML library version increases supply-chain and operational risk.

Content

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

text
openai>=1.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0
regex>=2023.0.0

Unverifiable Dependency: scikit-learn has 6 known advisory(ies) (CVE-2020-13092 (scikit-learn Deserialization of Untrusted Data); CVE-2024-5206 (scikit-learn sensitive data leakage vulnerability); CVE-2020-28975 (scikit-learn Denial of Service) +3 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
93% confidence
Finding

scikit-learn has known advisories, and because the manifest does not pin a specific version, it is impossible to verify whether the deployed package is affected. In this context, the skill is a chatbot engine rather than a high-privilege system component, so the risk remains limited but real due to uncertainty around installed code.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The numpy requirement is not pinned, so dependency resolution can pull in newer or transitive combinations that were never security-reviewed for this skill. This creates non-reproducible builds and may expose the environment to upstream flaws or denial-of-service conditions in affected versions.

Content

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

text
openai>=1.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0
regex>=2023.0.0

Unverifiable Dependency: numpy has 16 known advisory(ies) (CVE-2014-1859 (Numpy arbitrary file write via symlink attack); CVE-2021-41495 (NumPy NULL Pointer Dereference); CVE-2021-33430 (NumPy Buffer Overflow (Disputed)) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
92% confidence
Finding

numpy has multiple historical advisories, but the current requirement leaves the installed version unverifiable. This means a build could resolve to an affected release, creating avoidable exposure to upstream memory-safety, file-write, or denial-of-service issues depending on usage.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

A lower-bound-only pandas dependency allows untested future releases to be installed automatically. That increases the chance of inheriting vulnerable or behavior-changing versions, especially in data-processing paths that may handle attacker-influenced content.

Content

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

text
openai>=1.0.0
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0
regex>=2023.0.0

Unverifiable Dependency: pandas has 1 known advisory(ies) (CVE-2020-13091 (** DISPUTED ** pandas through 1.0.3 can unserialize and execute commands from an)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
90% confidence
Finding

pandas has at least one advisory, and the unpinned requirement prevents verification that only safe versions are installed. Although the skill description does not indicate especially dangerous data-deserialization behavior by itself, leaving the version unresolved preserves unnecessary supply-chain uncertainty.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The regex package is also unpinned, which permits drift to future releases without review. While not evidence of active compromise, this weakens supply-chain control and can introduce vulnerable or unstable versions into production unexpectedly.

Content

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

text
scikit-learn>=1.3.0
numpy>=1.24.0
pandas>=2.0.0
regex>=2023.0.0

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The manifest describes a chatbot engine for multi-turn dialogue and intent recognition, but this file also retrieves credentials directly from process environment variables. While calling an LLM service can be expected for a chatbot, implicit credential harvesting from environment state is a separate capability not stated in the manifest and is not inherent to dialogue logic itself.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.