T09 · Insecure Skill Coding Practices
- Location
references/obs-lib.sh:36- Finding
Arbitrary Command Execution Through eval-Based curl Construction
- Content
View full analysis
- Remediation
View remediation
&2 return 2 ;; esac if [ -n "$OBS_USERNAME" ] && [ -n "$OBS_TOKEN" ]; then curl_args+=(-u "$OBS_USERNAME:$OBS_TOKEN") fi curl_args+=(-H "Content-Type: $content_type") if [ -n "$data" ]; then if [[ "$data" == @* ]]; then curl_args+=(--data-binary "$data") else curl_args+=(--data-binary "$data") fi fi curl "${curl_args[@]}" "$url" } ``` Additional hardening should include: 1. Validate `OBS_APIURL` with an allowlist of permitted schemes, preferably requiring HTTPS. 2. Validate HTTP methods against a fixed set. 3. Percent-encode each path and query component instead of interpolating raw object names into endpoints. 4. Avoid returning authentication options as shell-formatted text; add each option directly to an argument array. 5. Add tests using values containing spaces, quotes, semicolons, command substitutions, and newlines to verify that they are treated only as data. 6. Use `curl --fail-with-body --show-error` and handle non-success HTTP responses explicitly. ]]>
