Melange Patch Pipeline Arbitrary Command Execution Vulnerability
Vulnerability
A vulnerability in the Melange package's patch pipeline allows for arbitrary command execution on the build host. This issue is present in versions 0.10.0 prior to 0.40.3. The vulnerability arises because the patch pipeline in 'pkg/build/pipelines/patch.yaml' improperly embeds input-derived values into shell scripts, lacking adequate quoting and validation. This oversight enables the injection of shell metacharacters that can escape their intended context. The flaw affects the built-in patch pipeline, which can be accessed through 'melange build' and 'melange license-check' operations. An attacker capable of manipulating patch-related inputs, such as through pull request-driven CI, build-as-a-service, or by altering Melange configurations, could exploit this vulnerability to execute arbitrary commands with the privileges of the Melange build process.
Impact
Successful exploitation allows for arbitrary command execution on the build host, with the same privileges as the Melange build process.
Reproduction
The vulnerability can be reproduced by creating a series file or patch file that includes shell metacharacters, such as backticks or command substitutions. This can be done by influencing the inputs to the Melange patch pipeline, for example, through a pull request that triggers a CI build. Once the pipeline is executed, the embedded shell metacharacters will be processed, leading to the execution of the injected commands.
Remediation
Users can upgrade to Melange version 0.40.5, where this vulnerability has been patched.
Vulnerability Rating
Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.
