The vulnerability is a path traversal issue in the shame next command of the shamefile tool. The root cause lies in the print_entry_snippet function, which was responsible for displaying a code snippet for a given shame entry. This function improperly trusted the location field from the shamefile.yaml file, which can be controlled by an attacker.
The vulnerable version of print_entry_snippet would construct a file path based on this location and read the file from the disk to generate the snippet. An attacker could create a malicious shamefile.yaml where the location for an entry points to a sensitive file on the user's system (e.g., /etc/passwd or SSH keys) using path traversal sequences (../) or absolute paths.
When a victim runs the shame next command in a repository containing this malicious shamefile.yaml, the print_entry_snippet function would be called. It would then proceed to read the specified sensitive file and print one line of its content to the user's terminal, leading to information disclosure.
The patch resolves this vulnerability by fundamentally changing how the snippet is generated. The print_entry_snippet function no longer reads from the file system. Instead, it now relies on a content field within the shame entry itself, which is a pre-cached copy of the relevant line of code. This change, verified by the new test format_entry_snippet_uses_content_field_not_filesystem, effectively severs the connection between snippet rendering and direct file access, thus mitigating the path traversal risk.