Repository navigation
Conversation
Signed-off-by: Rp-13-byt <rajenpatel1902@gmail.com>
124254d to
6a1994c
Compare
|
Hi maintainers, I’d appreciate a review of this PR when someone has a chance. The change focuses on validating filenames received through the HTTP I’ve kept the changes focused on the HTTP download path to make the fix easier to review. Could you please let me know whether the validation and fallback behavior align with the project’s expectations, or if there are any edge cases you’d recommend addressing? I’d also like to become more involved in the ScanCode.io contributor community. Could you point me toward the preferred community channel, such as an official Slack workspace, chat group, or contributor discussion forum, where developers can discuss ongoing work and coordinate contributions? I’m happy to make any adjustments based on your feedback. Thanks for your time and for maintaining ScanCode.io. |
Summary
Fixes a potential path traversal vulnerability in
fetch_http()where an untrustedContent-Dispositionheader filename could escape the intended download directory.Root Cause
fetch_http()directly usedparams.get("filename")from the untrusted response headerContent-Dispositionto construct the targetoutput_file = Path(download_directory, filename)without validating path containment or stripping traversal sequences.Changes
is_safe_filename()to validate that filenames do not contain POSIX or Windows path separators (/,\), Windows drive prefixes (:), null or control characters (\x00-\x1f,\x7f), or relative directory references (.,..).Path.resolve()and enforceis_relative_to()containment checks, preventing directory escapes and symlink redirection outside the download folder.Content-Dispositionhas an empty or whitespace-only filename parameter.ValueErrorif an invalid, unsafe, or traversal-attempt filename is encountered.test_fetch.pyfor traversal sequences, absolute paths, Windows path syntax, control/null characters, empty names, safe names, and symlink escapes.