Summary
A command injection vulnerability in the Serverless-Devs s init command allows unsanitized user input to reach a shell-enabled process execution function. When an attacker-controlled argument is accepted, this may allow arbitrary operating system commands to run with the privileges of the invoking process.
Affected context
The issue occurs in the Serverless-Devs CLI initialization workflow when user-supplied input is passed to child_process.spawn() with shell execution enabled. Deployments or developer environments that allow untrusted project sources or command arguments to reach s init may be exposed, particularly where the CLI has access to sensitive files, credentials, or cloud tooling.
Exploit preconditions
- Attack surface: The Serverless-Devs
s initcommand - Required access: Ability to cause a user or automation process to run
s initwith an attacker-controlled argument - Trigger point: Process creation during initialization
- Why exploitation is possible: Input reaches a shell-enabled child process without adequate sanitization, while the available input check can be bypassed by certain accepted URL forms
Why this happens
The underlying flaw is the combination of insufficient input validation and shell-enabled process execution. Passing externally influenced data to child_process.spawn() with shell: true allows shell metacharacters or command syntax to be interpreted by the operating system rather than treated solely as data. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute arbitrary commands in the local development or automation environment.
- Sensitive files, environment variables, or credentials could be accessed.
- Project files or build artifacts could be modified.
- Cloud resources or deployment pipelines could be affected when the CLI has corresponding permissions.
- Compromise could spread to connected systems through available tokens or integrations.
General mitigation guidance
Mitigation generally focuses on removing shell interpretation from application-controlled process execution and reducing trust in command arguments.
Common defensive patterns include:
- Avoiding
shell: truewhen shell features are not required. - Passing arguments through an argument array to a non-shell process API.
- Applying strict allowlisting and canonical validation to repository or project-source inputs.
- Separating URL parsing and validation from process invocation.
- Running CLI automation with dedicated, least-privilege identities and minimal filesystem access.
- Preventing secrets and broad cloud credentials from being exposed to initialization workflows.
- Treating external project sources as untrusted even when they match an expected URL format.
How teams detect issues like this
Organizations can look for:
- Static-analysis findings where user-controlled data flows into
child_processAPIs withshell: true. - Code-review signals involving string concatenation or interpolation in process commands.
- Validation logic that checks only superficial URL suffixes or formats before command execution.
- CI policies that prohibit shell-enabled child processes unless explicitly justified.
- Runtime monitoring for unexpected child-process creation, command interpreter launches, or access to sensitive environment data.
Automated code-review and data-flow analysis tools may help identify these patterns before deployment.

