Repository navigation
Conversation
poc.ts's .py code path built eight shell commands for venv creation and pip installation via template-literal interpolation into execAsync() (shell-backed child_process.exec), using values derived from the caller-supplied filePath/pocDir. The existing containment check only validates that the resolved path is inside POC_DIR; it never validates which characters the path may contain, so a filePath whose directory segment includes a quote followed by a shell separator breaks out of the surrounding quoting at each of these call sites. This mirrors the exact pattern already fixed in 60d826a for the main PoC execution call (execAsync -> execFileAsync), but these eight sites were added afterward by f8c3d6a/7bb0a63 and never revisited. Switch all eight call sites to execFileAsync with array-form arguments, matching the existing main execution call. No shell is invoked, so no quoting/escaping concern exists regardless of path content. Verified against the real compiled function: the same crafted filePath that previously created a marker file via shell injection now fails safely, with the malicious string passed through as a single inert argument (python -m venv even refuses it for containing a PATH separator, demonstrating no shell interpretation occurs).
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
poc.ts's .py code path built eight shell commands for venv creation and pip installation via template-literal interpolation into execAsync() (shell-backed child_process.exec), using values derived from the caller-supplied filePath/pocDir. The existing containment check only validates that the resolved path is inside POC_DIR; it never validates which characters the path may contain, so a filePath whose directory segment includes a quote followed by a shell separator breaks out of the surrounding quoting at each of these call sites.
This mirrors the exact pattern already fixed in 60d826a for the main PoC execution call (execAsync -> execFileAsync), but these eight sites were added afterward by f8c3d6a/7bb0a63 and never revisited.
Switch all eight call sites to execFileAsync with array-form arguments, matching the existing main execution call. No shell is invoked, so no quoting/escaping concern exists regardless of path content.
Verified against the real compiled function: the same crafted filePath that previously created a marker file via shell injection now fails safely, with the malicious string passed through as a single inert argument (python -m venv even refuses it for containing a PATH separator, demonstrating no shell interpretation occurs).
Testing
tscbuild: clean, no errors.npx vitest run src/poc.test.ts: updated the Python test's assertions to match the newexecFileAsynccall shape (it previously asserted the old, vulnerableexecAsyncstring-command call), and added a new regression test asserting afilePathcontaining shell metacharacters reachesexecFileAsyncas a single literal array argument rather than being interpolated into a shell command string.poc.test.ts(unrelated to the.pybranch) fail due to what looks like a path-separator mismatch between the test's hand-rolledmockPathhelper (POSIX-style, forward-slash) and the realpathmodule's output forPOC_DIRon Windows (backslash-separated). I confirmed viagit stashthat these exact same 4 tests fail identically before this change, so they are a pre-existing, Windows-specific test-environment issue, not a regression introduced here. I'd expect them to pass on the project's actual Linux CI.dist/poc.js(built, unmodified, from this fix): the exact craftedfilePaththat previously created a marker file via shell injection now fails safely with no injection, andpython -m venvitself rejects the malicious string outright for containing aPATHseparator -- direct confirmation that no shell interpretation of the path occurs anymore.