propagate check_magic_bytes through bz2/lzma/gzip archive scans - #41
Open
abdul-khaliq-khalid wants to merge 1 commit into
Open
propagate check_magic_bytes through bz2/lzma/gzip archive scans#41abdul-khaliq-khalid wants to merge 1 commit into
abdul-khaliq-khalid wants to merge 1 commit into
Conversation
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.
_extract_and_scan_archiveforwardscheck_magic_bytesto the recursivesecurity_scancall on the zip and tar branches, but the bz2, lzma and gzip branches leave it off, so those three fall back to the default and re-enable the fast-path rejection the caller explicitly asked to turn off. A protocol-0 pickle is all ASCII, so prefixing one with aCODE_KEYWORDSstring likeusegets it fast-path rejected as source code; scanning those bytes raw withcheck_magic_bytes=Falsescoresunsafe: 3and the same bytes in a zip also scoreunsafe: 3, but gzip, bz2 or xz wrapping drops them tounsafe: 0, so recompressing is enough to hide a payload from a caller who opted into the stricter scan. Passing the flag through at the three sites lines the compressed branches up with the raw and zip paths, and I checked benign and malicious pickles at protocols 0 and 5 to confirm the defaultcheck_magic_bytes=Truebehavior is unchanged.