fix(security): replace new Function template evaluation and shelljs with execFile - #7
Conversation
|
Adding execution evidence — and correcting one thing I got wrong in the PR description. Reproduced on 3.1.1 — the current npm latest, driving the module's own fileName = 'x$(touch canary.txt)'
// rendered: mkdir -p ./out && unzip -d ./out -o "x$(touch canary.txt)"
// -> canary.txt is createdCommand substitution executes inside the double quotes, so quoting the path is not a mitigation. Negative control: a benign The correction: my PR description implied the Affected range: |
Summary
exec()inindex.jsdynamically rendered shell script strings viarender()(which instantiatednew Function) and passed the resulting string directly toshell.exec().If
compress_fileordecompress_dircontained shell metacharacters or template literals (e.g.${...}), arbitrary code/command execution would occur on the host (CWE-78: OS Command Injection).Fix
render()and dynamic template generation with discrete argument vectors inCOMPRESS_PROFILE.shell.exec()withchild_process.execFile()passing discrete argument arrays totar,unzip,bunzip2,unrar,7z, andgunzip.fs.mkdirSync(dir, { recursive: true }).