The vulnerability lies in the handling of Chart.lock files during a dependency update. An attacker can craft a Helm chart where the Chart.lock is a symbolic link to a sensitive file, such as a user's shell profile (e.g., ~/.bashrc). The Chart.yaml file can be crafted with malicious content that will be written into the Chart.lock file.
When a victim runs helm dependency update on this malicious chart, the writeLock function in pkg/downloader/manager.go is called. Prior to the patch, this function did not validate whether the lock file was a symlink. It would proceed to write the dependency information, which is derived from the malicious Chart.yaml, into the file path pointed to by the Chart.lock symlink. This overwrites the target file with attacker-controlled content, which can be executed by the system or user at a later time, resulting in code execution.
The patch, introduced in commit 4b8e61093d8f579f1165cdc6bd4b43fa5455f571, addresses this by adding a check using os.Lstat within the writeLock function. This check explicitly verifies if the lock file is a symlink. If it is, the operation is aborted, and an error is returned, thus preventing the malicious file write and mitigating the vulnerability.