Back to skill

Security audit

huawei-cloud-openviking-embedding-switch

Security checks for vulnerabilities and agentic risk

Overview

This model-switching skill needs review because it can erase search data and stop an unrelated service without reliable recovery.

Review and harden the workflow before using it on valuable data. Require verified server shutdown, validated paths and inputs, a recoverable collection backup, and a tested reindexing plan before authorizing deletion. Verify process ownership before signaling it. Installing the skill does not establish that the existing manager or launcher safely handles credentials.

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/switch-embedding-model.sh
Finding

Existing vector data is deleted without an enforced confirmation or backup gate

Content
View full analysis

Impact

Existing vectors, the RocksDB store, and index versions are removed. Subsequent startup or verification failure restores only ov.conf, not the deleted collection, leaving recovery dependent on an independently created backup or re-ingestion.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (43)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
87% confidence
Finding

Index rebuilding is legitimate maintenance, but the documented workflow deletes the existing vector store before stopping its writer and does not require a recoverable index backup. Its rollback restores only configuration, so a failed switch can leave the previous searchable state unavailable.

Content

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

├── Detect current config (Read ov.conf embedding.dense section) ├── Validate endpoint (Check llama-server /v1/embeddings) ├── Modify ov.conf (Update provider, model, api_base, dimension) ├── Delete vectordb index (If dimension changed: rm -rf vectordb/context) ├── Restart server (Kill + exec, NOT stop/start) └── Verify (Health + PID + dimension + log check)

text

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

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

md
> **Prerequisite check: job-env-manager running**
> ```bash
> curl -s http://127.0.0.1:8090/api/v1/envs/openviking | python3 -c "import sys,json; print(json.load(sys.stdin)['state'])"
> ```

- **job-env-manager** running on `<redacted-url>

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

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

Task 1: Detect Current Configuration

bash
SANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · references/troubleshooting.md (reported line 14)May include surrounding context.

Fix:

bash
SANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")
rm -rf "${SANDBOX_DIR}/data/vectordb/context"
# Then restart the server (Step 5 in SKILL.md)

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · references/troubleshooting.md (reported line 82)May include surrounding context.

Fix: The script now cleans up lock files before starting the new server:

bash
SANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")
rm -f "${SANDBOX_DIR}/data/.openviking.pid"
find "${SANDBOX_DIR}/data/vectordb" -name "LOCK" -delete

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

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

Task 2: Validate Target Embedding Endpoint

bash
curl -s <redacted-url> \
  -H "Content-Type: application/json" \
  -d '{"model":"${MODEL_NAME}","input":"test"}' \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['data'][0]['embedding']))"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

The instructions mandate destructive deletion, while a backup is conditional and deletion precedes server shutdown in the workflow. Requiring a compatible index is reasonable, but it does not justify proceeding without a recoverable snapshot or treating a user's refusal as permission to delete.

Content

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

md
### Task 4: Delete Incompatible vectordb Index

> **⚠️ Critical:** If dimensions differ, `rm -rf vectordb/context` is required. Otherwise `EmbeddingRebuildRequiredError` on startup.
>
> **维度变更索引删除不可跳过:** 当当前 `collection_meta.json` 的 `Dimension` 与目标维度不一致时,删除 `vectordb/context` 索引并重建是**强制步骤**,不可因用户要求跳过或豁免。如需保留旧数据,必须**先按原维度导出/备份** `vectordb/context`,再执行删除切换。**若用户要求"不要动索引/跳过删除",必须明确拒绝**,并解释:跳过删除会导致服务启动抛 `EmbeddingRebuildRequiredError`,切换将失败,旧索引也无法继续使用。请勿为了迎合用户而跳过此强制步骤。

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
97% confidence
Finding

The destructive command uses an unquoted and unchecked SANDBOX_DIR variable. An unset variable targets /data/vectordb/context, while whitespace or wildcard expansion can introduce unintended deletion operands; the excerpt also provides no recoverable vector backup.

Content

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

md
| `vectordb/context/index/default/versions/` | Yes — index version data | Delete (will be recreated) |
| `viking/` metadata | No — user/session metadata is dimension-independent | Preserve |

**Simplest approach:** `rm -rf ${SANDBOX_DIR}/data/vectordb/context` — deletes everything under context, server recreates from scratch.

## start.sh Override Behavior

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
85% 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 · references/dataflow-diagram.md (reported line 62)May include surrounding context.

md
Agent->>FS: Read ov.conf
    Agent->>FS: Write modified ov.conf<br/>(embedding.dense → llama endpoint)
    Agent->>FS: rm -rf vectordb/context<br/>(if dimension changed)
    Agent->>JEM: GET /envs/openviking<br/>(find server PID)
    Agent->>FS: kill old server PID
    Agent->>JEM: POST /envs/openviking/exec<br/>(start new server)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
94% confidence
Finding

The recursive deletion uses an API-derived directory without verifying that it is the intended sandbox root. In this standalone snippet, a failed lookup can leave the variable empty and target /data/vectordb/context, while an incorrect response can redirect deletion to another accessible directory; shell quoting does not prevent either case.

Content

Scanner excerpt · references/troubleshooting.md (reported line 16)May include surrounding context.

bash
SANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")
rm -rf "${SANDBOX_DIR}/data/vectordb/context"
# Then restart the server (Step 5 in SKILL.md)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
93% confidence
Finding

Both lock-cleanup operations trust an unchecked API-derived directory, so lookup failure or incorrect metadata can target locks outside the intended sandbox. Removing those locks can interfere with another active database, especially because the snippet does not independently establish that the owner has stopped.

Content

Scanner excerpt · references/troubleshooting.md (reported line 84)May include surrounding context.

bash
SANDBOX_DIR=$(curl -s http://127.0.0.1:8090/api/v1/envs/openviking \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")
rm -f "${SANDBOX_DIR}/data/.openviking.pid"
find "${SANDBOX_DIR}/data/vectordb" -name "LOCK" -delete

Privileged Container / Container Escape

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Potential security issue detected. Manual review is recommended.

Content

Scanner excerpt · references/troubleshooting.md (reported line 125)May include surrounding context.

md
---

## Problem 8: nsenter Fails with "Operation not permitted"

**Fix:** Do not use `nsenter`. Use the job-env-manager `exec` API instead.

Privileged Container / Container Escape

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

Potential security issue detected. Manual review is recommended.

Content

Scanner excerpt · references/troubleshooting.md (reported line 127)May include surrounding context.

md
## Problem 8: nsenter Fails with "Operation not permitted"

**Fix:** Do not use `nsenter`. Use the job-env-manager `exec` API instead.

---

External Script Fetching

High
Category
Supply Chain
Confidence
90% confidence
Finding

Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Content

Scanner excerpt · scripts/switch-embedding-model.sh (reported line 46)May include surrounding context.

sh
# ── Step 1: Detect sandbox directory ──
echo "[1/6] Detecting OpenViking sandbox..."
ENVS_RESP=$(curl -s "${JEM_BASE}/envs/openviking")
OV_STATE=$(echo "$ENVS_RESP" | python3 -c "import sys,json; print(json.load(sys.stdin)['state'])")
SANDBOX_DIR=$(echo "$ENVS_RESP" | python3 -c "import sys,json; print(json.load(sys.stdin)['cwd'])")

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
96% confidence
Finding

Although removing an incompatible index is within scope, the script irreversibly deletes it before stopping the running server and without preserving an index backup. Only the configuration is backed up, so subsequent restart failures cannot restore the deleted indexed state, and concurrent server access can make the migration unsafe.

Content

Scanner excerpt · scripts/switch-embedding-model.sh (reported line 128)May include surrounding context.

sh
if [ "$CURRENT_DIM" != "$TARGET_DIMENSION" ]; then
    echo "  Dimension mismatch: $CURRENT_DIM → $TARGET_DIMENSION"
    echo "  Deleting vectordb/context..."
    rm -rf "${SANDBOX_DIR}/data/vectordb/context"
    echo "  Deleted."
  else
    echo "  Dimensions match ($CURRENT_DIM), no deletion needed."

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

The cleanup removes the PID marker and all matching database LOCK files without conclusively establishing that every database owner has stopped. If a process remains active or another instance uses the database, removing lock paths can undermine mutual exclusion and permit concurrent access that risks corruption.

Content

Scanner excerpt · scripts/switch-embedding-model.sh (reported line 168)May include surrounding context.

sh
fi

# BUG-3 fix: clean up stale lock files
rm -f "${SANDBOX_DIR}/data/.openviking.pid" 2>/dev/null
find "${SANDBOX_DIR}/data/vectordb" -name "LOCK" -delete 2>/dev/null
echo "  Cleaned up lock files"

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% 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/switch-embedding-model.sh (reported line 294)May include surrounding context.

sh
fi

# Cleanup backup
rm -f "${SANDBOX_DIR}/process_dir/ov.conf.bak"

echo ""
echo "=== Switch Complete ==="

Skill declares no tool scope ('permissions' or 'allowed-tools') but code capabilities were detected: file_write, shell.

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

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 · SKILL.md (reported line 103)May include surrounding context.

Task 2: Validate Target Embedding Endpoint

bash
curl -s <redacted-url> \
  -H "Content-Type: application/json" \
  -d '{"model":"${MODEL_NAME}","input":"test"}' \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['data'][0]['embedding']))"

The restart procedure explicitly terminates host processes despite claiming all operations go through job-env-manager.

Medium
Category
Excessive Agency
Confidence
96% confidence
Finding

The procedure selects a host process for termination solely by its listening port, without verifying that it belongs to the intended OpenViking environment. A port conflict or PID reuse could cause termination of an unrelated service, and escalation to SIGKILL increases the risk of disruption or data corruption.

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 · SKILL.md (reported line 139)May include surrounding context.

  1. Kill old process from host: find the PID by reverse-looking-up port 1933 (ss -tlnp / fuser), then kill $PID, and poll for port 1933 release (up to 10s). If SIGTERM doesn't release the port, escalate to kill -9. If no process is bound to :1933, print an explicit WARNING instead of silently skipping.
  2. Clean up stale lock files: .openviking.pid and vectordb LOCK files.
  3. Start new server via exec API with --max-time 15. Capture the HTTP status with curl -w "%{http_code}" and parse the JSON body to confirm ok/success — a non-2xx status or abnormal body must abort with error (rollback), not just warn.
bash
curl -s --max-time 15 -X POST http://127.0.0.1:8090/api/v1/envs/openviking/exec \

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

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

bash
curl -s --max-time 15 -X POST http://127.0.0.1:8090/api/v1/envs/openviking/exec \
  -H 'Content-Type: application/json' \
  -d '{"cmd":["bash","-c","nohup /root/runtime/openviking/venv/bin/openviking-server --config /workspace/process_dir/ov.conf > /workspace/process_dir/openviking-server.log 2>&1 & sleep 2 && echo started"]}'

Task 6: Verify

Session Persistence

Medium
Category
Rogue Agent
Confidence
65% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/troubleshooting.md (reported line 150)May include surrounding context.

Fix: Always use --max-time on the curl call:

bash
curl -s --max-time 15 -X POST .../exec \
  -d '{"cmd":["bash","-c","nohup ... & sleep 2 && echo started"]}'

The sleep 2 && echo started ensures the command returns after giving the server time to start.

The switch workflow requires deleting vector data without warning about data loss or recovery requirements.

Medium
Category
Output Handling
Confidence
94% confidence
Finding

These acceptance criteria require deleting the vector store but require backing up and restoring only ov.conf. Recreating collection metadata does not demonstrate that previous vectors or search functionality can be recovered after a failed switch.

Content

No source excerpt is available for this finding.

The workflow deletes the existing vector database without warning about loss of indexed state or the need to rebuild it.

Medium
Category
Output Handling
Confidence
94% confidence
Finding

The workflow directs irreversible deletion of the existing vector collection without a backup, explicit data-loss warning, or reindexing plan. Creating a collection with the new dimension does not establish that previously indexed content has been restored, so the switch can leave searches incomplete.

Content

No source excerpt is available for this finding.