T09 · Insecure Skill Coding Practices
- Location
scripts/test-memory-system.sh:55- Finding
Arbitrary Command Execution Through Workspace Environment Variables and eval
- Content
View full analysis
/dev/null 2>&1; then ((PASSED++)) log_pass "$desc" return 0 ``` The environment-derived path is embedded into command strings at the call sites: ```bash check "HOT 目录存在" "[ -d \"$MEMORY_DIR/lessons/HOT\" ]" check "WARM/errors 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/errors\" ]" check "WARM/corrections 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/corrections\" ]" check "WARM/best-practices 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/best-practices\" ]" check "WARM/feature-requests 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/feature-requests\" ]" check "WARM/decisions 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/decisions\" ]" check "WARM/projects 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/projects\" ]" check "WARM/people 目录存在" "[ -d \"$MEMORY_DIR/lessons/WARM/people\" ]" check "COLD/archive 目录存在" "[ -d \"$MEMORY_DIR/lessons/COLD/archive\" ]" ``` ### Technical Analysis The script accepts `OPENCLAW_WORKSPACE` or `CLAW_WORKSPACE` from its execution environment. These values are treated as filesystem paths but are subsequently interpolated into strings representing shell commands. The `check` function executes each resulting string with `eval`. Unlike a normal quoted path comparison, `eval` reparses the complete string as shell syntax. Shell metacharacters embedded in a workspace environment variable can therefore terminate the intended test expression and introduce arbitrary commands. The issue is exploitable when an attacker can control the environment used to launch the script. This can occur ...[truncated 1550 chars]- Remediation
View remediation
