T09 · Insecure Skill Coding Practices
- Location
scripts/harden.sh:34- Finding
Root Command Injection Through Unvalidated SSH Port
- Content
View full analysis
/tmp/root-command-output #' ``` 3. The value is stored without validation in `SSH_PORT` ...[truncated 815 chars]- Remediation
View remediation
65535 )); then printf 'Invalid SSH port: %s\n' "$SSH_PORT" >&2 exit 1 fi ``` 3. Replace string-based execution with an array-aware helper: ```bash run() { if [[ "$DRY_RUN" == "true" ]]; then printf '[DRY-RUN]' printf ' %q' "$@" printf '\n' else "$@" fi } run ufw allow "${SSH_PORT}/tcp" comment SSH ``` 4. Generate configuration files using safe templates after validation. Do not pass heredoc construction through `eval`. 5. Validate all other user-controlled options, including `OPENCLAW_USER` and `OPENCLAW_CONFIG_DIR`, according to strict expected formats. 6. Add regression tests using shell metacharacters, whitespace, command substitutions, negative numbers, and out-of-range ports. ]]>
