fix(framework/tools): eval injection, broken JSON, tmpfile leak #549
Reference in New Issue
Block a user
Delete Branch "fix/tooling-eval-injection-jq-json"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes three confirmed defects in
packages/mosaic/framework/tools/git/.F-01 (HIGH) — Shell injection in issue-edit.sh and issue-assign.sh
Both scripts built CLI commands via string interpolation then executed them with
eval. A title/body/label containing$(id)would execute arbitrary code. Fixed by converting all eval sites to Bash arrays with proper quoting. For the Gitea path, replacedget_gitea_repo_args()(which emits%q-escaped strings designed for eval) withget_repo_slug()+get_gitea_login()passed as array elements.F-07 (MED) — Broken JSON in milestone-create.sh
The GitHub API JSON payload was built by string interpolation. A title containing
"or$would produce malformed JSON and fail the API call. Fixed withjq -n --arg. Optional description key is omitted when empty, preserving existing behaviour.F-13 (LOW) — Tmpfile leak in pr-metadata.sh
curl_gitea_pull()created a mktemp tmpfile but only cleaned it up in success paths. An early exit (viaset -eor SIGINT) leaked the file. Fixed by addingtrap 'rm -f "$body_file"' EXITimmediately after the mktemp call.Test evidence
bash -nsyntax check: all 4 files passTITLE='$(touch /home/hermes/agent-work/PWNED)'passed as literal string to stub CLI; PWNED file NOT createdjq -n --argproduces valid JSON with titles containing",$, and\; description key omitted when emptyNo merge — awaiting orchestrator go-ahead per AGENTS.md rule 38.
Fixes #548