Back to skill

Security audit

Gene Engine

Security checks for vulnerabilities and agentic risk

Overview

The skill’s purpose is coherent, but unsafe script handling could let crafted inputs run code while changing persistent agent state.

Review before installing. Run only in a trusted OpenClaw workspace, do not pass untrusted gene keys or outcome text, and do not run it against a gene-state.json that other users or workflows can modify until the Python interpolation bugs are fixed.

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

T09 · Insecure Skill Coding Practices

Error
Location
gene-trigger.sh:30
Finding

Arbitrary Python Code Execution Through Unsafe Argument Interpolation

Content
View full analysis
/dev/null; then echo "❌ Gene '$1' 不存在" exit 1 fi echo "=== Gene Trigger Recorder ===" echo "Gene: $1" echo "结果: $RESULT" echo "描述: $OUTCOME" echo "时间: $NOW_ISO" echo "" # 更新JSON python3 -c " import json, sys with open('$GENE_FILE', 'r') as f: data = json.load(f) gene = data['$GENE_KEY'] now = '$NOW_ISO' # 更新基础字段 gene['lastTriggered'] = now gene['triggeredCount'] = gene.get('triggeredCount', 0) + 1 if gene.get('daysSinceLastTrigger') is None: gene['daysSinceLastTrigger'] = 0 if '$RESULT' == 'success': gene['lastResult'] = {'success': True, 'outcome': '''$OUTCOME'''} gene['consecutiveFailures'] = 0 gene['status'] = 'verified' gene['lastVerified'] = now # wakeUpRate: 每次成功都算改变判断 gene['activationCount'] = gene.get('activationCount', 0) + 1 else: gene['lastResult'] = {'success': False, 'error': 'trigger_failed', 'reason': '''$OUTCOME'''} gene['consecutiveFailures'] = gene.get('consecutiveFailures', 0) + 1 gene['totalFailures'] = gene.get('totalFailures', 0) + 1 gene['lastFailure'] = now ``` ### Technical Analysis The script assigns command-line arguments to `GENE_KEY`, `RESULT`, and `OUTCOME`, then inserts those values directly into Python source passed to `python3 -c`. Shell quoting does not make these values safe inside the generated Python program. An argument containing Python quote delimiters and additional syntax can terminate its intended string literal and introduce executable Python statements. The preliminary gene-key existence check is also vulnerable because `GENE_KEY` is interpolated into this Python expression: ```python assert '$GENE_KEY' in d ``` Consequently, the check cannot ...[truncated 1729 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
gene-engine.sh:354
Finding

Python Code Injection Through Untrusted Gene State Values

Content
View full analysis
0 else 0)") ``` ```bash # 3. 唤醒率低扣分 if [ "$wake_up_rate" != "null" ] && [ "$wake_up_rate" != "None" ] && [ "$wake_up_rate" != "N/A" ]; then rate_int=$(python3 -c "print(int(float('$wake_up_rate') * 100))") if [ "$rate_int" -lt 50 ]; then HEALTH_SCORE=$((HEALTH_SCORE - 10)) HEALTH_DETAILS+=("$short_name: 唤醒率${rate_int}% (-10)") fi fi ``` ### Technical Analysis The values in `triggered_count`, `activation_count`, and `wake_up_rate` originate from `gene-state.json`. They are interpolated directly into Python source executed with `python3 -c`. For example, the resulting source is constructed in this form: ```python tc=; ac=; ... ``` The script assumes these state fields are valid numeric literals but does not enforce their JSON types before generating Python code. A malicious value containing Python syntax can therefore alter the program that is executed. Quoting `wake_up_rate` inside `float('...')` is also insufficient because a crafted quote can terminate that string literal. Although exploitation requires control over or corruption of `gene-state.json`, the engine is intended to run routinely as part of a heartbeat process. This creates a delayed execution path in which malicious state data becomes executable code during a later trusted run. ### Attack Path 1. An attacker or compromised local workflow obtains write access to `~/.openclaw/workspace/memory/gene-state.json`. 2. The attacker replaces a relevant numeric field, such as `triggeredCount`, `activationCount`, or `wakeUpRate`, with crafted content containing Python syntax. 3. The heartbeat process invokes `gene-engine.sh`. 4. ...[truncated 988 chars]
Remediation
View remediation
triggered: raise SystemExit("Gene counters are outside the permitted range") print(round(activated / triggered, 2) if triggered > 0 else 0) PY ) ``` The health-rate conversion should follow the same pattern: ```bash rate_int=$( python3 - "$wake_up_rate" <<'PY' import sys try: rate = float(sys.argv[1]) except ValueError: raise SystemExit("Invalid wake-up rate") if not 0.0 <= rate <= 1.0: raise SystemExit("Wake-up rate is outside the permitted range") print(int(rate * 100)) PY ) ``` Further hardening should include: 1. Validate the complete JSON schema immediately after loading the state file. 2. Require counters to be non-negative integers. 3. Require `wakeUpRate` to be a finite number between `0.0` and `1.0`. 4. Reject booleans, strings, arrays, and objects where numeric fields are expected. 5. Restrict state-file and directory permissions to the dedicated Agent account. 6. Prefer a single Python program for state loading, validation, calculations, and atomic updates rather than repeatedly transferring data between shell and generated Python programs. ]]>
Vulnerability Patterns
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (5)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The code only updates persisted state for a named gene based on a provided success/fail outcome. It does include limited cooldown management via failure thresholds and computes a simple activation ratio, which partially aligns with cooldown/health concepts. However, it does not implement the broader declared functionality: there is no retirement check logic, no active probing, and no autonomous engine behavior. Its primary purpose is narrower and materially different—a local recorder/updater for trigger outcomes—so the description overstates what this code chunk actually does.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill advertises and instructs use of local scripts plus reads/writes to memory/gene-state.json and gene-metrics.log, but it does not declare an explicit tool scope such as permissions or allowed-tools. In an agent environment, undeclared file access weakens least-privilege controls and can cause operators or orchestrators to grant broader filesystem capabilities than intended.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The description field presents the skill in Chinese only, and the rest of the document likewise assumes Chinese-language use. Under the policy, language constraints should either be optional for the user or explicitly justified as region-specific; neither is present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This shell script fixes the timezone to Asia/Shanghai and all comments/output strings are in Chinese, which imposes a specific language/locale on users and downstream operators. Under the policy, locale restrictions should be opt-in or clearly justified; here there is no visible user choice or rationale in the file.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script hard-codes TZ=Asia/Shanghai for timestamps and uses Chinese-only user-facing messages in comments and console output. This imposes a specific locale/language choice on all users without offering a choice or documenting a justified regional limitation.

Content

No source excerpt is available for this finding.