-
Notifications
You must be signed in to change notification settings - Fork 1
๐ก๏ธ Sentinel: [HIGH] Fix path traversal in file download #1479
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
Changes from all commits
b497a17
994259f
e0aeba9
0cd7b2d
4f19f84
78e7532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -267,7 +267,7 @@ def _parser_key_for(parse_content_type: str, parse_status: str) -> str: | |
| def _safe_filename(filename: str | None) -> str: | ||
| """Return a basename-only attachment display filename.""" | ||
| display_filename = strip_html_markup(_sanitize_nul(filename or "attachment")) | ||
| display_filename = Path(display_filename).name.strip() | ||
| display_filename = Path(display_filename.replace('\\', '/')).name.strip() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ Maintainability & Code Quality | ๐ก Minor | โก Quick win Add a regression test for Windows-style separators before merging. The existing test in As per coding guidelines, TDD is expected: add or update tests before production code changes. ๐ค Prompt for AI AgentsSource: Coding guidelines |
||
| if display_filename in {"", ".", ".."}: | ||
| return "attachment" | ||
| return display_filename | ||
|
|
||
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.
๐ Info: Backslash filenames truncated on POSIX
Backslash is a valid POSIX filename character. After the change
_safe_filenametreats it as a separator, so a legitimate name likemy\file.txtbecomesfile.txt. Acceptable trade-off for the traversal fix, but names containing literal backslashes lose the leading portion.Was this helpful? React with ๐ or ๐ to provide feedback.