The vulnerability is a classic path traversal issue located in the retrieveWorkspace function within the Build struct in pkg/build/build.go. This function's purpose is to extract a tar archive, which represents the build workspace, from a QEMU virtual machine. The core of the vulnerability lies in the lack of validation of the file paths for the entries within the tar archive before they are written to the host's filesystem.
The security advisory and the commit message for the patch 6e243d0d46699f837d7c392397a694d2bcc7612b confirm this. The patch introduces a new helper function, isValidPath, specifically designed to prevent path traversal by checking for absolute paths, '..' sequences, and null bytes.
Inside the vulnerable retrieveWorkspace function, the patch strategically inserts calls to this new isValidPath function at critical points:
- It validates the
hdr.Name for every single entry in the tar archive, which is the primary fix that closes the path traversal loophole.
- It adds further validation for
hdr.Linkname for both symbolic links (tar.TypeSymlink) and hard links (tar.TypeLink), preventing attacks where a link might point to a sensitive file outside the workspace.
Because the vulnerability is triggered during the processing of a malicious tar file by this function, Build.retrieveWorkspace is the precise function that would be active and appear in a runtime profile or stack trace during an exploit.