T09 · Insecure Skill Coding Practices
- Location
scripts/safe-restart.sh:32- Finding
Configuration validation relies on ambiguous substring matching
- Content
View full analysis
&1 | grep -q "valid"; then ok "配置校验通过" else fail "配置校验失败!中止重启。" openclaw config validate 2>&1 exit 1 fi ``` The same pattern is used by the configuration guard: ```bash info "运行 openclaw config validate..." if openclaw config validate 2>&1 | grep -q "valid"; then ok "OpenClaw 配置校验通过" else fail "OpenClaw 配置校验失败" openclaw config validate 2>&1 ERRORS=$((ERRORS + 1)) fi ``` ### Technical Analysis The scripts determine whether validation succeeded by searching the command's combined output for the unanchored substring `valid`. This token is also contained in words such as `invalid` and can occur in unrelated warnings or diagnostic output. Both scripts enable `pipefail`, which preserves a nonzero exit status from `openclaw` in ordinary failure cases. Consequently, exploitation requires the validator or an extension influencing its output to return zero while printing an error or ambiguous message containing `valid`. The output test nevertheless creates an unnecessary and fragile secondary success condition instead of treating the validator's documented exit status as authoritative. The scripts also invoke validation twice on failure. If validation has side effects or its result changes between executions, the displayed diagnostic may not correspond to the result used by the first check. ### Attack Path 1. A malformed or semantically unacceptable configuration is supplied to OpenClaw. 2. The validation command, or a plugin participating in validation, returns exit status zero while emitting text such as `invalid configuration` or another message containing `valid`. 3. `grep -q "valid" ...[truncated 623 chars]- Remediation
View remediation
&1); then printf '%s\n' "$VALIDATION_OUTPUT" ok "Configuration validation passed" else printf '%s\n' "$VALIDATION_OUTPUT" >&2 fail "Configuration validation failed; restart aborted" exit 1 fi ``` Apply the same change to `scripts/config-guard.sh`. If a textual success marker is required by the OpenClaw interface, match a documented, anchored, machine-readable token rather than the substring `valid`. ]]>
