Repository navigation
smbclient: resolve server-provided file names in recursive get - #5237
musthaf-bughunter wants to merge 2 commits into
Conversation
The names returned by the server during `get -r` were joined to the local destination without being resolved, so the `root in local.parents` containment check was lexical and a name such as `../evil` could write outside of the download directory. AI-Assisted: yes (Claude Fable 5.1)
|
I don't think that this work considering |
|
I think parsepath only sees the argument the user gives to get. The names that _getr joins to the local destination come straight out of query_directory (the FileName of each FILE_ID_BOTH_DIR_INFORMATION entry), nothing strips them, and the I've replaced the mocked test with one against a real server: a SMB_Server subclass whose listing contains a file named |
Description
Path traversal in
smbclient.get -r. In_getr()the file names returned by the server are joined to the local destination without being resolved, so theroot not in local.parentscheck runs on the lexical path and a directory entry named../evilpasses it (PurePath.parentsdoes not collapse..). A hostile server can make the client write files, or create directories, outside of the directory it downloads into.Repro: a server whose listing contains
../evil, seescapy/scapy/layers/smbclient.py
Lines 1745 to 1750 in aa87edd
smbclientserver.utsis the minimal version of it and does not need samba.Fix: resolve the local path before the containment check, and the root that
get()hands to_getr(), as the comment next to the check already requires.