The vulnerability exists because the VFS.canonical and VFS.dcanonical functions in copyparty/authsrv.py did not properly enforce access restrictions for shares created for single files. These functions are responsible for resolving user-provided paths to filesystem paths. The lack of validation allowed an attacker to guess and access other files in the same directory as the shared file.
The patch addresses this by introducing two new functions, _canonical_shr and _dcanonical_shr, which are specifically designed to handle path resolution for shares. These new functions check if the requested file is in the list of explicitly shared files (self.shr_files). If the file is not in the list, the functions return a value that prevents access.
The _reload function, which is responsible for setting up the virtual file system, is modified to use these new secure functions whenever a share is detected. This ensures that all path resolutions for shared files go through the new, more secure logic, effectively closing the vulnerability.