Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_symlink always returns False #117

Closed
jaraco opened this issue May 26, 2024 · 2 comments
Closed

is_symlink always returns False #117

jaraco opened this issue May 26, 2024 · 2 comments
Assignees

Comments

@jaraco
Copy link
Owner

jaraco commented May 26, 2024

As reported by a user on Huntr.com.

The implementation of is_symlink is hard-coded to return False, which could give the false impression that a path is not a symlink, whereafter they may expand the zipfile using a utility that does honor symlinks, exposing access to unwanted paths.

zipp/zipp/__init__.py

Lines 392 to 396 in 051250e

def is_symlink(self):
"""
Return whether this path is a symlink. Always false (python/cpython#82102).
"""
return False

That code refers to python/cpython#82102, where CPython's zipfile implementation does not have any support for either detecting nor creating nor extracting symlinks.

However, the Path object could provide support for reflecting a symlink if present.

According to the vulnerability report, the symlink could be detected from a ZipInfo object with the following expression:

(info.external_attr >> 16) & 0o170000 == 0o120000

I'd like to verify that logic is correct.

@jaraco
Copy link
Owner Author

jaraco commented May 26, 2024

It does appear as if stat.S_ISLINK() can be used in place of == 0o120000.

@jaraco jaraco self-assigned this May 26, 2024
@jaraco jaraco closed this as completed in dc5fe8f May 26, 2024
@jaraco
Copy link
Owner Author

jaraco commented May 26, 2024

Fix released as v3.19.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant