-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Swift: Add Unsafe Unpacking Query (CWE-022) #14888
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
Conversation
Hello maikypedia 👋 In the meantime, feel free to make changes to the pull request. If you'd like to maximize payout for your this and future submissions, here are a few general guidelines, that we might take into consideration when reviewing a submission.
Please note that these are guidelines, not rules. Since we have a lot of different types of submissions, the guidelines might vary for each submission. Happy hacking! |
Hi @maikypedia, Thank you for this contribution. The QL appears to be to a high standard and I'm interested to see what this query can find. After the Security Lab team have taken a look I'll be happy to give a more detailed review from the Swift / QL perspective. Feel free to |
QHelp previews: swift/ql/src/experimental/Security/CWE-022/UnsafeUnpack.qhelpArbitrary file write during a zip extraction from a user controlled sourceUnpacking files from a malicious zip without properly validating that the destination file path is within the destination directory, or allowing symlinks to point to files outside the extraction directory, allows an attacker to extract files to arbitrary locations outside the extraction directory. This helps overwrite sensitive user data and, in some cases, can lead to code execution if an attacker overwrites an application's shared object file. RecommendationConsider using a safer module, such as: ExampleThe following examples unpacks a remote zip using `Zip.unzipFile()` which is vulnerable to path traversal.
The following examples unpacks a remote zip using `fileManager.unzipItem()` which is vulnerable to symlink path traversal.
Consider using a safer module, such as:
References
|
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.
Hi, sorry for the long wait. The query looks great, I've suggested a few minor fixes and changes.
swift/ql/test/query-tests/Security/CWE-022-Unsafe-Unpack/UnsafeUnpack.swift
Outdated
Show resolved
Hide resolved
swift/ql/test/query-tests/Security/CWE-022-Unsafe-Unpack/UnsafeUnpack.swift
Outdated
Show resolved
Hide resolved
swift/ql/test/query-tests/Security/CWE-022-Unsafe-Unpack/UnsafeUnpack.expected
Outdated
Show resolved
Hide resolved
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Thanks for addressing the comments. CI has noticed that we're missing a change note. This will be a new file in
|
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.
Great, I think this is ready to merge.
Thank you for your contribution! ✨
@maikypedia you should be able to hit "Merge pull request" now if you're also satisfied that this is finished. |
![]() I can't 😅 |
Ah, sorry, I didn't know that was a thing. Merging now. |
This pull request adds a query for Unsafe Unpacking covering Zip and ZIPFoundation.
Looking forward to your suggestions.