-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
bpo-9949: Enable symlink traversal for ntpath.realpath #15287
Conversation
This is ready to merge once CI passes. I'll do it and then rebase #15231 before merging that one. |
Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
(cherry picked from commit 75e0649) Co-authored-by: Steve Dower <steve.dower@python.org>
GH-15367 is a backport of this pull request to the 3.8 branch. |
|
|
|
|
|
while normcase(path) not in seen: | ||
seen.add(normcase(path)) | ||
try: | ||
path = _nt_readlink(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're allowing reading junction targets, you must fail a remote path here if path
is a junction, per os.lstat
. A junction target in a UNC path is meaningless to us. A junction has to target local devices on a system, i.e. its local DOS drive and volume GUID names. At best these aren't defined for us, and at worst they map to an unrelated drive on our side. If for some reason junction "spam" fails to resolve on the server, we cannot go any further. We leave it as "spam" in the UNC path, and we're done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If path
is a relative symlink, it must be evaluated relative to its parent directory, not out current directory.
https://bugs.python.org/issue9949