Back to skill

Security audit

Enhanced Search Service

Security checks for vulnerabilities and agentic risk

Overview

This search skill mostly matches its purpose, but it under-discloses query storage and loads adapter code from a hard-coded local path that can expand its effective behavior.

Review this before installing in environments with sensitive memory contents. The main issues are that parts of search queries may be stored in the co-occurrence system, and adapter code is loaded from a hard-coded local workspace path outside the reviewed package. Install only if you trust and control that adapter directory, and consider requiring query redaction, retention limits, and packaged or integrity-checked dependencies.

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

T08 · Insecure Dependencies

Warning
Location
scripts/enhanced_search_service.py:28
Finding

Unverified Dependency Loading Through Python Import-Path Precedence

Content
View full analysis

Vulnerability Details

File Location: scripts/enhanced_search_service.py, lines 28–37
Vulnerability Type: Insecure dependency loading and local module hijacking
Risk Level: Medium

Vulnerable Code:

python
try:
    # Try to import co-occurrence adapter
    sys.path.insert(0, '/root/.openclaw/workspace/integration/adapter')
    from co_occurrence_adapter import CoOccurrenceAdapter
    self.co_occurrence_adapter = CoOccurrenceAdapter()
    logger.info("Co-occurrence adapter initialized")
except ImportError as e:
    logger.warning(f"Could not import co-occurrence adapter: {e}")

try:
    # Try to import semantic vector adapter
    from semantic_vector_adapter import SemanticVectorAdapter

Technical Analysis

The service inserts the hard-coded external directory /root/.openclaw/workspace/integration/adapter at index zero of sys.path. This gives modules in that directory precedence over modules from standard package locations. It then imports co_occurrence_adapter and semantic_vector_adapter without validating their paths, ownership, permissions, provenance, or integrity.

Python executes module-level code as soon as a module is imported. Consequently, either adapter file becomes an implicit code-execution boundary outside the audited project. The second import is also affected because the modified search path remains active process-wide. Catching ImportError does not mitigate malicious module execution because attacker-controlled code runs before normal adapter initialization completes.

Attack Path

  1. An attacker obtains write access to /root/.openclaw/workspace/integration/adapter, or compromises a process or deployment mechanism that populates that directory.
  2. The attacker creates or replaces co_occurrence_adapter.py or semantic_vector_adapter.py with a module containing malicious top-level Python code.
  3. The application instantiates EnhancedSearchService.

...[truncated 1210 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the runtime sys.path.insert() call and load adapters through normal, fully qualified package imports.
  2. Package the adapters as reviewed dependencies with pinned versions and reproducible integrity hashes.
  3. Install dependencies into a controlled virtual environment rather than importing code from a mutable workspace directory.
  4. Verify that dependency directories and files are owned by a trusted administrative account and are not writable by the service account or untrusted users.
  5. If dynamic local loading is unavoidable, resolve the configured path to a canonical location and enforce an allowlist of approved directories and module filenames.
  6. Authenticate module contents against trusted cryptographic hashes or signatures before loading them.
  7. Validate the imported module's resolved __file__ path before instantiating its classes, while recognizing that post-import validation alone cannot prevent top-level code execution.
  8. Run the service under a dedicated least-privileged account with restricted filesystem and network access to limit the consequences of dependency compromise.
  9. Add deployment checks that fail closed when adapter provenance, ownership, permissions, or integrity cannot be established.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (2)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The service records co-occurrence data using search-derived memory IDs and a string containing the raw query prefix, which can persist potentially sensitive user input without notice or minimization. In a search/memory context, queries may contain secrets, filenames, incident terms, or proprietary data, so storing them in telemetry or graph data increases privacy and data-exposure risk if the adapter storage is later accessed or logged.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The inline comment at L166 describes a step to limit results to max_expansion, but the code immediately returns the full sorted list without applying any truncation. This is an intent/documentation mismatch because callers are led to expect max_expansion to affect output size when it currently does nothing.

Content

No source excerpt is available for this finding.