Back to skill

Security audit

Sandbox Selfheal Guard

Security checks for vulnerabilities and agentic risk

Overview

This self-healing local LLM helper is mostly disclosed and purpose-aligned, but review is warranted because repair mode can make privileged system changes and its source validation before rebuilding code is weak.

Install only if you need an agent to repair a local llama.cpp/GGUF sandbox and are comfortable reviewing each use of SELFHEAL_MODE=fix. Treat fix mode as permission to change the machine: it may install packages, rebuild code, download models, write cache/state, and add an npx shim. Avoid using it on untrusted llama.cpp checkouts, and prefer a pinned installer command instead of a mutable latest package.

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

T08 · Insecure Dependencies

Error
Location
scripts/selfheal_runner.sh:91
Finding
Bypassable Git Remote Allowlist Permits Building Attacker-Controlled Source## Vulnerability Details **File Location**: `scripts/selfheal_runner.sh`, lines 91-96 **Vulnerability Type**: Supply-chain source validation bypass **Risk Level**: High ### Vulnerable Code ```sh selfheal_source_trusted() { # rc 0: provenance ok; rc 4: unknown/untrusted origin [ -d "$SELFHEAL_LLAMA_DIR/.git" ] || { selfheal_log "llama.cpp is not a git checkout — provenance unknown"; return 4; } _remote=$(git -C "$SELFHEAL_LLAMA_DIR" config --get remote.origin.url 2>/dev/null || echo "") case "$_remote" in *github.com/ggml-org/llama.cpp*|*github.com/ggerganov/llama.cpp*) return 0 ;; *) selfheal_log "untrusted llama.cpp remote '$_remote' (expecting github.com/ggml-org/llama.cpp)"; return 4 ;; esac } ``` ### Technical Analysis The trusted-source check performs substring matching against the complete Git remote URL. It does not parse and validate the remote hostname and repository path separately. Consequently, an attacker-controlled URL containing an allowed string can pass validation. Examples include: ```text https://evil.example/github.com/ggml-org/llama.cpp ssh://evil.example/path/github.com/ggml-org/llama.cpp ``` After this check succeeds, `selfheal_rebuild_llama` runs CMake against the local checkout. CMake configuration and build files are executable build logic and may invoke arbitrary commands. Therefore, accepting a malicious checkout as trusted can result in local code execution. The explicit `SELFHEAL_MODE=fix` requirement reduces accidental exploitation but does not make the provenance check effective once a user has consented to repair operations. ### Attack Path 1. An attacker places or causes the user to obtain a malicious Git checkout at `$SELFHEAL_LLAMA_DIR`. 2. The attacker sets its `remote.origin.url` to an attacker-controlled URL containing the substring `github.com/ggml-org/llama.cpp`. 3. The expected llama.cpp binary is absent or fails its version probe. 4. The ...[truncated 914 chars]
Remediation
## Remediation Suggestions Replace substring matching with canonical, exact remote validation: 1. Parse supported Git URL forms, including HTTPS, `ssh://`, and SCP-style SSH URLs. 2. Require the normalized hostname to be exactly `github.com`. 3. Require the normalized repository path to be exactly `ggml-org/llama.cpp` or the explicitly supported legacy repository. 4. Reject URLs containing user-info tricks, unexpected ports, additional path components, encoded separators, or unrecognized schemes. 5. Add regression tests for deceptive URLs such as `evil.example/github.com/ggml-org/llama.cpp` and `github.com.attacker.example/ggml-org/llama.cpp`. 6. For stronger supply-chain protection, require a known commit hash or verified signed tag rather than trusting the remote name alone. 7. Consider cloning the trusted repository into a newly created directory instead of building a preexisting checkout whose worktree may have uncommitted malicious modifications.

T08 · Insecure Dependencies

Warning
Location
README.md:11
Finding
Installation Instructions Execute a Mutable Latest-Version Package## Vulnerability Details **File Location**: `README.md`, lines 11-14 **Vulnerability Type**: Unpinned executable dependency **Risk Level**: Medium ### Vulnerable Code ```bash npx --yes clawhub@latest install @orionshaowswmw/sandbox-selfheal-guard ``` ### Technical Analysis The documented installation command instructs `npx` to retrieve and execute the mutable `latest` release of the `clawhub` package. Because no exact version or integrity digest is specified, the code executed by this command can change after the audited Skill version is published. `npx` executes the downloaded package's command-line entry point. A compromised registry account, package, dependency, or future malicious publication under the `latest` tag could therefore introduce code that was not present during this audit. This issue concerns the installer dependency rather than the four model downloads. The model downloads in `manifest.json` are separately pinned with SHA-256 hashes. ### Attack Path 1. The `clawhub` registry package or one of its executable dependencies is compromised, or an unsafe release is assigned to the `latest` tag. 2. A user follows the installation command from `README.md`. 3. `npx` resolves `clawhub@latest` to the newly published mutable version. 4. `npx` downloads and executes that package without verifying it against a project-specified version or integrity value. 5. Malicious installer code runs under the user's account before or during Skill installation. ### Impact Assessment A malicious package executed through `npx` can run arbitrary commands with the installing user's privileges. It may access user-readable files, modify user-owned configuration or installed packages, tamper with the Skill contents, or install a compromised version. No direct privilege escalation is demonstrated by the audited command. The immediate privilege scope is that of the user invoking `npx`.
Remediation
## Remediation Suggestions 1. Replace `clawhub@latest` with an exact, audited package version. 2. Publish and document the expected package integrity digest. 3. Where supported, install through a lockfile or another mechanism that enforces both the exact version and registry integrity metadata. 4. For high-assurance environments, download the package artifact without executing it, verify its digest or signature, inspect it, and only then invoke the installer. 5. Document the expected package registry and reject alternate or user-configured registries unless explicitly trusted. 6. Update the pinned installer only after reviewing and testing each new release.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (5)

Intent-Code Divergence

Medium
Confidence
95% confidence
Finding
The consent-model comments claim check mode is read-only except for its own log, but helper paths such as failure tracking can still create ~/.selfheal state files outside fix mode. This breaks the documented safety boundary and can cause unauthorized local filesystem mutation in a mode users may trust as non-mutating.

Intent-Code Divergence

Medium
Confidence
94% confidence
Finding
The inline comment says check mode writes nothing, but functions like selfheal_breaker_record call selfheal_ensure_dirs and write state files regardless of fix mode. Misrepresenting mutation behavior is dangerous in an agent skill because callers may source or run it assuming dry-run semantics while it still alters user state.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
|---|---|---|
| writes | none in check mode; `~/.selfheal/` (log, state, cache), `~/.shim/npx`, model dir (`$SELFHEAL_MODELS_DIR`) in fix mode | fix mode only |
| network | `huggingface.co` only, exact URLs + sha256 pins in `manifest.json` | fix mode, circuit-broken, hash-verified after download |
| system packages | `sudo -n apt-get` (never interactive, stamp-throttled) | fix mode, only if binary missing |
| prompt content | processed locally, stored only in local cache (fix mode) | never sent anywhere |

## Operating protocol (run top-to-bottom; stop at first success)
Confidence
74% confidence
Finding
The skill explicitly allows `sudo -n apt-get` in fix mode to install missing binaries. Even though it avoids interactive prompts and is limited to package installation, invoking privileged package management from an agent skill expands the blast radius: a compromised execution path, mis-scoped package target, or socially engineered consent could result in unauthorized system modification.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
}

selfheal_breaker_record() { selfheal_ensure_dirs; _f="$SELFHEAL_STATE/fail_$1"; _n=$(sed -n 1p "$_f" 2>/dev/null); printf '%s\n%s\n' "$(( ${_n:-0} + 1 ))" "$(date +%s)" >"$_f"; }
selfheal_breaker_reset()  { selfheal_fix_mode && rm -f "$SELFHEAL_STATE/fail_$1"; return 0; }  # deletions are fix-mode only, even state-cleanup

selfheal_ensure_model() {  # $1=role -> prints path rc 0, or rc 3
  _file=$(selfheal_model_field "$1" file); _bytes=$(selfheal_model_field "$1" bytes)
Confidence
97% confidence
Finding
selfheal_breaker_reset deletes a path built from unsanitized role input: rm -f "$SELFHEAL_STATE/fail_$1". If an attacker can influence the role argument, they can inject path traversal sequences such as ../../ to delete files outside the intended state directory when fix mode is enabled.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
&& selfheal_gguf_ok "$_path" "$_bytes" && selfheal_sha_ok "$_path" "$_hash"; then
    selfheal_log "downloaded + verified (bytes+magic+sha256) $_file"; selfheal_breaker_reset "$1"; printf '%s' "$_path"; return 0
  fi
  rm -f "$_path.part" "$_path" 2>/dev/null   # NEVER leave a failed-verification artifact in place
  selfheal_breaker_record "$1"
  selfheal_log "ERROR: download/verify failed for $_file (artifact removed; breaker count updated)"
  return 3
Confidence
99% confidence
Finding
The script removes both $_path.part and $_path after failed download verification, but $_path is built from a manifest-controlled file field and SELFHEAL_MODELS_DIR. If a malicious or tampered manifest supplies an absolute path or traversal sequence, the cleanup code can delete arbitrary user-accessible files.

Static analysis

No suspicious patterns detected.