Back to skill

Security audit

Langcache Semantic Caching for OpenClaw

Security checks for vulnerabilities and agentic risk

Overview

The skill is a real LangCache integration, but its safety controls and credential handling have enough gaps that users should review it carefully before installing.

Install only if you are comfortable sending selected prompts and model responses to a Redis LangCache service. Use a dedicated low-privilege cache key, keep the host fixed to a trusted LangCache endpoint, avoid shared caches for personalized or policy-sensitive responses, do not use --force for secrets or PII, and replace the secrets.env sourcing pattern with safer secret handling before production use.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/langcache.sh:118
Finding

Configurable LangCache Host Can Receive API Credentials and User Content

Content
View full analysis
&2 echo "Set them in ~/.openclaw/secrets.env or export them directly." >&2 exit 1 fi } base_url() { echo "https://${LANGCACHE_HOST}/v1/caches/${LANGCACHE_CACHE_ID}" } api_request() { local method="$1" local endpoint="$2" local data="${3:-}" local url url="$(base_url)${endpoint}" local args=( -s -X "$method" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ${LANGCACHE_API_KEY}" ) if [[ -n "$data" ]]; then args+=(-d "$data") fi curl "${args[@]}" "$url" } ``` The Python example contains equivalent behavior at `examples/agent-integration.py:134-139`: ```python self.cache = LangCache( server_url=f"https://{os.environ['LANGCACHE_HOST']}", cache_id=os.environ["LANGCACHE_CACHE_ID"], api_key=os.environ["LANGCACHE_API_KEY"], ) ``` ### Technical Analysis The code validates only that `LANGCACHE_HOST` is nonempty. It does not verify that the destination belongs to Redis LangCache or another explicitly trusted service. The API key is subsequently placed in the Authorization header of every request to that configurable host. Remote semantic caching requires network access, so sending prompts and responses to a cache service is consistent with the declared function. However, sending a credential to any environment-selected host ...[truncated 1432 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/langcache.sh:289
Finding

Explicit --force Option Bypasses the Documented Sensitive-Data Hard Block

Content
View full analysis
&2 echo "Usage: langcache.sh store [--attr ]..." >&2 exit 1 fi local block_reason if block_reason=$(check_blocks "$prompt"); then echo "Error: Prompt contains blocked content ($block_reason)" >&2 echo "This content cannot be cached. Blocked categories:" >&2 echo " - temporal_info: time-sensitive data (today, tomorrow, deadlines)" >&2 echo " - credentials: API keys, passwords, tokens" >&2 echo " - identifiers: emails, phone numbers, account IDs" >&2 echo " - personal_context: private conversations, relationships" >&2 if [[ "$force" != "true" ]]; then exit 1 fi echo "Warning: --force flag used, storing anyway (not recommended)" >&2 fi if block_reason=$(check_blocks "$response"); then echo "Error: Response contains blocked content ($block_reason)" >&2 if [[ "$force" != "true" ]]; then exit 1 fi e ...[truncated 2352 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/langcache.sh:21
Finding

Secrets Configuration File Is Executed as Arbitrary Shell Code

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
examples/agent-integration.py:241
Finding

Cache Keys Omit System Prompt, User, Tenant, and Authorization Context

Content
View full analysis
CacheResult: """Search for cached response with category-specific threshold.""" try: threshold = self.config.thresholds.get( category, self.config.thresholds["default"] ) result = await asyncio.to_thread( self.cache.search, prompt=prompt, similarity_threshold=threshold, search_strategies=[SearchStrategy.EXACT, SearchStrategy.SEMANTIC], attributes={"model": self.config.model_id}, ) if result.hit: response_check = self._check_hard_blocks(result.response) if response_check.blocked: logger.warning( f"Cached response contains blocked content, skipping: " f"{response_check.reason.value}" ) return CacheResult(hit=False) return CacheResult( hit=True, response=result.response, similarity=result.similarity, entry_id=result.entry_id, ) except Exception as e: logger.warning(f"Cache search failed: {e}") return CacheResult(hit=False) ``` The context omission is visible in `examples/agent-integration.py:313-349`: ```python async def complete( self, prompt: str, system_prompt: Optional[str] = None, force_refresh: bool = False, ) -> str: """ Complete a prompt with semantic caching. Args: prompt: The user prompt system_prompt: Optional system prompt (not included in cache key) force_refresh: Skip cache and call LLM directly """ normalized_prompt = self._normalize_prompt(prompt) cat ...[truncated 2914 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
examples/agent-integration.py:211
Finding

Sensitive Prompt Content Is Written to Application Logs

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Warning
Location
examples/agent-integration.py:8
Finding

Third-Party Dependencies Are Installed Without Version or Integrity Pinning

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (33)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 31)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 37)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 43)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 51)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 57)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 65)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 71)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 79)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 168)May include surrounding context.

md
./scripts/langcache.sh search "What is semantic caching?"

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The store endpoint persists prompt-response pairs remotely without warning that user inputs and model outputs may be retained outside the primary system. Because prompts and responses can contain secrets, personal data, or sensitive business information, this can create durable data exposure, retention, and cross-tenant leakage risk if not carefully scoped.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
86% confidence
Finding

A direct delete-by-ID operation is a dangerous capability in an agent-accessible tool because an attacker or misaligned workflow could supply arbitrary entry IDs and induce deletion of cached content. Without authorization scoping and confirmation, this creates an integrity risk and enables targeted removal of useful or protective cached entries.

Content

Scanner excerpt · references/api-reference.md (reported line 122)May include surrounding context.

Delete a specific cache entry.

text
DELETE /v1/caches/{cacheId}/entries/{entryId}

Response:

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
92% confidence
Finding

Bulk deletion by attributes is especially susceptible to tool-parameter abuse because small changes to filter parameters can expand scope from one user's records to an entire cache partition. In an agent setting, ambiguous instructions or malicious prompt injection could cause mass deletion of cached data and broad service disruption.

Content

Scanner excerpt · references/api-reference.md (reported line 140)May include surrounding context.

Delete all entries matching the specified attributes.

text
DELETE /v1/caches/{cacheId}/entries

Request Body:

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 · references/best-practices.md (reported line 64)May include surrounding context.

prompt = prompt.strip().lower() prompt = re.sub(r'\s+', ' ', prompt) # Collapse whitespace prompt = re.sub(r'^(please |can you |could you )', '', prompt) return prompt

text

## 4. Don't Cache Everything

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The file header states hard blocks 'NEVER get cached,' but the implementation permits exactly that with --force. This safety-policy mismatch is dangerous because operators and upstream agents may rely on the stronger guarantee and unintentionally cache sensitive content.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · SKILL.md (reported line 22)May include surrounding context.

md
set -euo pipefail

# Load secrets if available
SECRETS_FILE="${HOME}/.openclaw/secrets.env"
if [[ -f "$SECRETS_FILE" ]]; then
    # shellcheck source=/dev/null
    source "$SECRETS_FILE"

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/langcache.sh (reported line 22)May include surrounding context.

sh
set -euo pipefail

# Load secrets if available
SECRETS_FILE="${HOME}/.openclaw/secrets.env"
if [[ -f "$SECRETS_FILE" ]]; then
    # shellcheck source=/dev/null
    source "$SECRETS_FILE"

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/langcache.sh (reported line 124)May include surrounding context.

sh
set -euo pipefail

# Load secrets if available
SECRETS_FILE="${HOME}/.openclaw/secrets.env"
if [[ -f "$SECRETS_FILE" ]]; then
    # shellcheck source=/dev/null
    source "$SECRETS_FILE"

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/langcache.sh (reported line 470)May include surrounding context.

sh
set -euo pipefail

# Load secrets if available
SECRETS_FILE="${HOME}/.openclaw/secrets.env"
if [[ -f "$SECRETS_FILE" ]]; then
    # shellcheck source=/dev/null
    source "$SECRETS_FILE"

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The documented hard-block policy is bypassable with --force, allowing prompts or responses containing credentials, identifiers, personal context, or time-sensitive data to be stored anyway. This undermines the skill's primary safety control and can lead to persistent storage of secrets or private data in the semantic cache.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/langcache.sh (reported line 393)May include surrounding context.

sh
if [[ -n "$entry_id" ]]; then
        # Delete by ID
        api_request DELETE "/entries/${entry_id}"
    elif [[ ${#attrs_args[@]} -gt 0 ]]; then
        # Delete by attributes
        local attrs

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/langcache.sh (reported line 400)May include surrounding context.

sh
attrs=$(parse_attributes "${attrs_args[@]}")
        local json
        json=$(jq -n --argjson a "$attrs" '{attributes: $a}')
        api_request DELETE "/entries" "$json"
    else
        echo "Error: Delete requires --id or --attr" >&2
        echo "Usage: langcache.sh delete --id <entry-id>" >&2

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill exposes shell, network, and environment-variable capabilities via Bash, WebFetch, and documented secret usage, but it does not declare a restrictive tool scope such as permissions or allowed-tools. That increases the blast radius if the skill is invoked unexpectedly or modified later, because an agent may execute broader actions than the minimum required for cache operations.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger description contains broad phrases like 'reduce API costs' and 'speed up AI responses', which are common requests and can cause accidental invocation outside narrowly intended caching scenarios. Unintended activation is risky here because the skill has shell, network, and secret-dependent behavior, so overbroad matching can lead to unnecessary secret use or external cache interaction.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · examples/agent-integration.py (reported line 143)May include surrounding context.

python
# Initialize LLM client (example: OpenAI-compatible API)
        self.llm_client = httpx.AsyncClient(
            base_url="https://api.openai.com/v1",
            headers={"Authorization": f"Bearer {os.environ['OPENAI_API_KEY']}"},
            timeout=60.0,
        )

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The cache lookup and storage key are derived from the normalized user prompt and model attributes, while the system prompt is explicitly excluded. That means a response generated under one system instruction set can be served to a later request with the same user prompt but different hidden policy, role, safety, or tenant-specific instructions, causing cross-context response reuse and potentially bypassing guardrails or leaking behavior conditioned on private instructions.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.