The vulnerability described in GHSA-xjhm-gp88-8pfx allows a malicious copier template to read arbitrary files on the filesystem. This is possible due to improper handling of symbolic links within the template when the _preserve_symlinks option is set to false (the default setting).
The analysis of the patch commit b3a7b3772d17cf0e7a4481978188c9f536c8d8f6 pinpoints the exact location of the vulnerability. The changes are in the copier/_main.py file, specifically within the _render_template method of the Worker class.
The patch introduces a security check. Before this change, the code iterated through the template files and, when encountering a symlink (and _preserve_symlinks was false), it would resolve the symlink and copy the target file or directory. It did not, however, check if the resolved path of the symlink pointed to a location outside of the intended template source directory.
The added code block explicitly checks for this condition: it verifies if a file is a symlink, if symlinks are not being preserved, and if the resolved path of the symlink is outside the template's local path. If all these conditions are true, it raises a ForbiddenPathError, preventing the file from being copied.
The vulnerable function is therefore Worker._render_template, as it contains the logic that processes the template files and, prior to the patch, improperly handled symlinks, leading to the arbitrary file read. During exploitation, this function would be present in the runtime profile or stack trace as it processes the malicious symlink.