The vulnerability is a command injection within the patch pipeline of the melange build tool. The root cause was the lack of input sanitization for parameters passed to this pipeline, which are used to construct a shell script. The fixing commit, bd132535cd9f57d4bd39d9ead0633598941af030, addresses this by adding validation and quoting directly into the pipeline's shell script located in pkg/build/pipelines/patch.yaml.
The commit also introduces a new test file, pkg/build/patch_pipeline_test.go, which was crucial for identifying the vulnerable function. This test file includes a function, compilePatchPipeline, that simulates the pipeline compilation process. Within this test function, a call is made to c.compilePipeline(...), where c is an object of type *Compiled. This explicitly identifies chainguard.dev/melange/pkg/build.(*Compiled).compilePipeline as the Go function responsible for processing the pipeline and its inputs. This function takes user-controlled data and substitutes it into the script template. Because it originally did so without sanitization, it is the function responsible for creating the injectable command string, making it the primary vulnerable function that would be observed in a runtime profile during exploitation.