Repository navigation
Improve the safety of the cache filename construction mechanism. - #3110
Merged
Merged
Conversation
When downloading a file, the cached filename is based on the `Content-Disposition` header, or the server-provided URL in the response. The strategy used to construct the cache filename was based on using `/` as filename separator. However, if the user is on Windows, `\` is a valid filename separator. A path of `..\evil.exe` will be parsed as a valid cache filename in the parent directory of the download location. An attacker can use this approach to construct an arbitrary location on the user's machine and write content to that location. If the file has hash verification, the file will *not* be written unless the hash matches. However a temporary file with a `.download` extension will be created in same directory. This PR modifies the cache name construction process so that it will: * use both `/` and `\` as a basis for extracting the filename. * strip any leading or trailing spaces or periods in the name * reject any filename that contains a `:` (since this will be used to reference Windows drives, or NTFS alternate resource streams) * reject any empty filename * reject any attempt to reference the current or parent directory * reject any filename longer than 200 characterrs * reject any filename that is from the Windows device set. It also modifies the temporary file creation process so that the temporary filename isn't affected by the cache name. This is a mitigation for GHSA-j2qc-j92x-qqhj / CVE TBA.
freakboy3742
force-pushed
the
win-path-traversal
branch
from
October 26, 2026 22:41
7ecd757 to
f734eb9
Compare
freakboy3742
added a commit
to Skytuhua/briefcase
that referenced
this pull request
Oct 28, 2026
…ware#3110) When downloading a file, the cached filename is based on the `Content-Disposition` header, or the server-provided URL in the response. The strategy used to construct the cache filename was based on using `/` as filename separator. However, if the user is on Windows, `\` is a valid filename separator. A path of `..\evil.exe` will be parsed as a valid cache filename in the parent directory of the download location. An attacker can use this approach to construct an arbitrary location on the user's machine and write content to that location. If the file has hash verification, the file will *not* be written unless the hash matches. However a temporary file with a `.download` extension will be created in same directory. This PR modifies the cache name construction process so that it will: * use both `/` and `\` as a basis for extracting the filename. * strip any leading or trailing spaces or periods in the name * reject any filename that contains a `:` (since this will be used to reference Windows drives, or NTFS alternate resource streams) * reject any empty filename * reject any attempt to reference the current or parent directory * reject any filename longer than 200 characterrs * reject any filename that is from the Windows device set. It also modifies the temporary file creation process so that the temporary filename isn't affected by the cache name. This is a mitigation for GHSA-j2qc-j92x-qqhj.
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.
When downloading a file, the cached filename is based on the
Content-Dispositionheader, or the server-provided URL in the response. The strategy used to construct the cache filename was based on using/as filename separator. However, if the user is on Windows,\is a valid filename separator. A path of..\evil.exewill be parsed as a valid cache filename in the parent directory of the download location. An attacker can use this approach to construct an arbitrary location on the user's machine and write content to that location.If the file has hash verification, the file will not be written unless the hash matches. However a temporary file with a
.downloadextension will be created in same directory.This PR modifies the cache name construction process so that it will:
/and\as a basis for extracting the filename.:(since this will be used to reference Windows drives, or NTFS alternate resource streams)It also modifies the temporary file creation process so that the temporary filename isn't affected by the cache name.
This is a mitigation for GHSA-j2qc-j92x-qqhj (to be announced shortly). A CVE has been requested.
Thanks to @fjjjuv for reporting this issue, and for their assistance reviewing this draft PR.
PR Checklist:
Assisted-by: Claude Opus 5.5