The vulnerability lies in the improper handling of user-controllable input within the working-directory field of a Melange pipeline. This input is used to construct shell commands without proper escaping, leading to OS command injection. The analysis of the patch e51ca30cfb63178f5a86997d23d3fff0359fa6c8 reveals several functions where this pattern occurs.
The primary vulnerable function is build.buildEvalRunCommand in pkg/build/pipeline.go. It takes a workdir string and directly concatenates it into a shell script. An attacker could provide a workdir like x'; malicious_command; echo 'x to break out of the intended cd command and execute arbitrary code.
Similarly, the build.(*pipelineRunner).maybeDebug method in the same file uses the workdir to create a debug shell, presenting another injection vector.
Finally, the build.(*Build).BuildPackage method in pkg/build/build.go was also patched to prevent a similar injection vector where a file path (fullPath) was used to construct a setfattr command. While not directly tied to the working-directory field mentioned in the advisory, it represents the same class of vulnerability and was fixed in the same commit.
The fix involves introducing a new function, quoteShellArg, which uses the go-shellquote library to safely escape any special shell characters in the input before it is embedded in a command string, thus neutralizing the injection vector.