Repository navigation
smbserver: only list entries of the queried folder in lookup_folder - #5307
Open
musthaf-bughunter wants to merge 1 commit into
Open
musthaf-bughunter wants to merge 1 commit into
musthaf-bughunter wants to merge 1 commit into
Conversation
The QueryDirectory FileName pattern is passed to Path.glob(), which follows '..' and subfolders. A match outside the share made lookup_file() raise and the session stop answering, while no match returned STATUS_NO_MORE_FILES, so a client could probe for file names anywhere on the server (e.g. '../../etc/pass*'). AI-Assisted: yes (Claude Opus 5.5)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5307 +/- ##
=======================================
Coverage 78.99% 78.99%
=======================================
Files 375 375
Lines 98802 98802
=======================================
+ Hits 78044 78046 +2
+ Misses 20758 20756 -2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SMB_Server.lookup_folderpasses the client-supplied QueryDirectoryFileNamepattern toPath.glob()(smbserver.py#L1147), which follows..and subfolder components. A match outside the share makeslookup_file()raiseFileNotFoundError(smbserver.py#L1067), which is not caught, so the session stops answering; no match returnsSTATUS_NO_MORE_FILES. A client, including a guest, can therefore probe for file names anywhere on the server's filesystem.The fix only keeps glob results whose resolved parent is the queried folder. A test is added to
smbclientserver.uts.