Switch executeCommand from shell exec to argv-based execFile (CWE-78)#164
Open
JAE0Y2N wants to merge 1 commit into
Open
Switch executeCommand from shell exec to argv-based execFile (CWE-78)#164JAE0Y2N wants to merge 1 commit into
JAE0Y2N wants to merge 1 commit into
Conversation
Contributor
|
Thanks. Fixed for 2.12.8. Got inspiration from your degit PR. Credit you in commit. Visible in branch: https://github.com/tiged/tiged/tree/fix/release-2.12-cwe78 Will soon look at this, to get it merged in main branch. But most important was to fix the publicly released version. Fix has been deployed: https://www.npmjs.com/package/tiged?activeTab=versions |
josepootchepo12-rgb
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
src/utils.tsdefinesexecuteCommandaspromisify(child_process.exec). The shell form spawns/bin/sh -c <command>and parses shell metacharacters in interpolated arguments. Three call sites pass user-controlledrepo.url,repo.ref, andurl(sourced from the slug, e.g.user/repo#refs/...) into template strings:src/utils.ts:639—git ls-remote ${repo.url} ${repo.ref}src/utils.ts:806—git fetch --depth 1 ${repo.url} ${ref}src/tiged.ts:1095-1105— three compound branches:cd ${dest} && git init && git remote add origin ${url} && git fetch --depth 1 origin ${ref} && git checkout FETCH_HEAD;separatorsgit clone --depth 1 ${url} ${dest}A repo slug like
foo/bar; touch /tmp/pwnedparses under the shell asgit ls-remote foo/bar+touch /tmp/pwned. CWE-78.How this PR fixes it
executeCommandnow delegates topromisify(child_process.execFile). The new signature is(cmd, args?, options?):args, the array is passed toexecFileverbatim — no shell, no metacharacter parsing.'git --version','git init','git rev-list FETCH_HEAD'), the back-compat path splits and runs throughexecFilefor safety. Only developer-authored constants use this path.The five user-input call sites are rewritten to argv form. The shell-compound branches in
src/tiged.tscollapse into sequentialexecuteCommandcalls with thecwdoption — once you drop the shell, the Windows&&vs POSIX;separator distinction disappears.How to verify
The companion fix landed on
Rich-Harris/degitas PR #404 (same maintainer pattern, same execFile switch).Surface
Two files, ~50 LOC. No new dependencies. No tests added — happy to add a
child_process.execspy that asserts execFile is the only sink if you'd like.