T09 · Insecure Skill Coding Practices
- Location
scripts/reconcile.sh:39- Finding
Predictable Temporary Files Allow Symlink-Based File Overwrite
- Content
View full analysis
"$JOB/reconcile.jq" ([.subtitles[].words[]]) as $W | def toks(s): (s | gsub("[[:space:]]+"; " ") | ltrimstr(" ") | rtrimstr(" ") | if . == "" then [] else split(" ") end); (.timeline | length) as $T | [ range(0; $T) as $i | { cursor: 0, timeline: .timeline, words: $W, ok: true, failidx: null } | reduce range(0; $T) as $j (.; (.timeline[$j].vo_line) as $vl | (toks($vl) | length) as $n | if (.cursor + $n) > (.words | length) then .ok = false | .failidx = $j else (.words[.cursor]) as $first | (.words[.cursor + $n - 1]) as $last | .timeline[$j].start_time = $first.start | .timeline[$j].end_time = $last.end | .cursor = (.cursor + $n) end ) ] | last | if (.ok | not) then error("RECONCILE_OVERRUN at segment \(.failidx): vo_line word count exceeds remaining measured words") else { timeline: .timeline, audio_duration: .timeline[-1].end_time } end JQEOF OUT=$(mktemp) jq -f "$JOB/reconcile.jq" "$INPUT" > "$OUT" 2> "$JOB/.reconcile.err" ``` ### Technical Analysis The script creates `reconcile.jq` and `.reconcile.err` at predictable paths inside the caller-selected job directory. Shell output redirection follows symbolic links, and the script does not verify that either destination is a regular file owned by the expected user. Consequently, if an attacker can prepare or modify the job directory, they can create either predictable path as a symbolic link to another file. The redirections will then truncate or overwrite the linked target with the privileges of the account running the skill. The use of `mktemp` for `OUT` does not protect the two files written directly under `$JOB`. In addition, `reconcile.jq` is not remov ...[truncated 1263 chars]- Remediation
View remediation
