Executive brief
Snyk's vulnerability scanning tools and plugins contained a command injection flaw that could allow attackers to execute arbitrary commands on systems running the Snyk CLI. An attacker could exploit this by crafting malicious command-line arguments passed to the Snyk test command, potentially compromising build pipelines and CI/CD systems where developers use these tools to scan project dependencies for security issues.
Technical details
This is a command injection vulnerability (CWE-78) in Snyk's CLI and plugin suite resulting from an incomplete fix for CVE-2022-40764. The vulnerability stems from improper escaping of child process arguments when spawning subprocesses. An attacker can inject arbitrary shell commands by manipulating command-line flags passed to the snyk test command. Exploitation requires that a user executes the Snyk CLI on attacker-controlled or untrusted files, but in CI/CD pipeline contexts where developers control arguments, this can be leveraged for pipeline compromise. The issue has been patched across all affected plugins by properly escaping/quoting spawn arguments before passing them to child processes.
Affected products
- Snyk snyk before 1.1064.0
- Snyk snyk-mvn-plugin before 2.31.3
- Snyk snyk-gradle-plugin before 3.24.5
- Snyk snyk-cocoapods-plugin before 2.5.3
- Snyk snyk-sbt-plugin before 2.16.2
- Snyk snyk-python-plugin before 1.24.2
- Snyk snyk-docker-plugin before 5.6.5
- Snyk snyk-hex-plugin before 1.1.6
Timeline
- 2022-11-30: disclosed: Advisory published
- 2022-11-29: patched: Fixes available in Snyk Docker images as of 2022-11-29
- 2022-11-30: other: Snyk TeamCity CI/CD plugin patched as of version v20221130.093605
References
- https://github.com/snyk/cli/commit/80d97a93326406e09776156daf72e3caa03ae25a
- https://github.com/snyk/snyk-cocoapods-plugin/commit/c73e049c5200772babde61c40aab57296bf91381
- https://github.com/snyk/snyk-docker-plugin/commit/d730d7630691a61587b120bb11daaaf4b58a8357
- https://github.com/snyk/snyk-gradle-plugin/commit/bb1c1c72a75e97723a76b14d2d73f70744ed5009
- https://github.com/snyk/snyk-hex-plugin/commit/e8dd2a330b40d7fc0ab47e34413e80a0146d7ac3
- https://github.com/snyk/snyk-mvn-plugin/commit/02cda9ba1ea36b00ead3f6ec2de0f97397ebec50