harden: sanitize child_process call in init.mjs... - #53
Conversation
…ss security vulnerability Automated security fix generated by OrbisAI Security
|
Thanks — the The ref validator regex Two options, either is fine:
Prefer option 1 — a single |
…lowClone
The ref validator regex allowed a leading dash, so a ref like
--upload-pack would pass the guard and be forwarded to git as an
option flag (argument injection, no shell required). Add a
ref.startsWith('-') check alongside the regex and clean up the
redundant \- escape in the character class.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review comments addressed. Pls review. |
|
Confirmed — commit |
Summary
Harden input handling in
bin/init.mjs(flagged by semgrep).Vulnerability
javascript.lang.security.detect-child-process.detect-child-processbin/init.mjs:945Description: Detected calls to child_process from a function argument
ref. This could lead to a command injection if the input is user controllable. Try to avoid calls to child_process, and if it is needed ensure user input is correctly sanitized or sandboxed.Threat Model Context
This is a Node.js library - vulnerabilities affect downstream consumers who use this package.
Changes
bin/init.mjsBehavior Preservation
The change is scoped to 1 file on the vulnerable path; it only tightens handling of untrusted input and leaves valid inputs unaffected.
This patch removes an exploit primitive — a code pattern that, while not independently exploitable today, could be chained with other weaknesses by automated exploit-development tooling. Proactive removal of such primitives raises the bar against increasingly capable automated attack tools.
Automated security fix by OrbisAI Security