The vulnerability is a path traversal in the go-tuf library's TAP 4 Multirepo Client. An attacker can provide a specially crafted repository name in a map file, which is then used to construct a file path. The lack of validation on the repository name allows for path traversal characters (../), leading to arbitrary file writes on the system, constrained by the permissions of the running process.
The analysis of the patch d361e2ea24e427581343dee5c7a32b485d79fcc0 reveals the fix. A new function, validateRepoName, is introduced to sanitize the repository names using a regular expression. This validation is performed within the New function before the client initialization process begins.
The core of the vulnerability lies in the initTUFClients method, which, according to the vulnerability description, uses the unsanitized repoName in a filepath.Join operation. The patch confirms this by adding the sanitization step in the New function, which is the entry point for creating a MultiRepoClient and subsequently calls initTUFClients.
Therefore, two functions are identified as relevant for a runtime profile during exploitation:
multirepo.(*MultiRepoClient).initTUFClients: This is the function where the path traversal occurs. It takes the malicious repoName and uses it to construct a file path, leading to the arbitrary file write.
multirepo.New: This function orchestrates the creation of the multirepo client and was modified to include the fix. In a vulnerable version, it would call initTUFClients with the unsanitized, malicious repoName.