Skip to content

JavaScript: Add tar-stream extraction to ZipSlip query.#1118

Merged
semmle-qlci merged 5 commits intogithub:masterfrom
jcreedcmu:jcreed/tarslip
Mar 18, 2019
Merged

JavaScript: Add tar-stream extraction to ZipSlip query.#1118
semmle-qlci merged 5 commits intogithub:masterfrom
jcreedcmu:jcreed/tarslip

Conversation

@jcreedcmu
Copy link
Contributor

No description provided.

@jcreedcmu jcreedcmu requested a review from xiemaisi March 15, 2019 12:18
@jcreedcmu jcreedcmu requested a review from a team as a code owner March 15, 2019 12:18
Copy link

@xiemaisi xiemaisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but needs a change note.

Here are some suggestions for other packages to investigate, they all seem to use a fairly similar API:

https://www.npmjs.com/package/tar has a slightly different API and only seems vulnerable if you explicitly set the preservePaths option, so not sure whether that's worth modelling. It does seem very popular, though.

Let us know if you'll have the time to look into modelling these, otherwise one of us will pick it up.

}

/** A zip archive entry path access, as a source for unsafe zip extraction. */
/** Gets a property that is used to get the filename part of an archive entry. */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's "path" for unzip and "name" for tar-stream? This may be worth clarifying in the comment (but of course it's fine to allow both for both packages as you do here.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done.

@jcreedcmu
Copy link
Contributor Author

Let me know if the change note is formatted properly according to convention. I tried looking around the other recent change notes for reference.

Here are some suggestions for other packages to investigate, they all seem to use a fairly similar API:

these two look worth modelling, but I don't think I'm going to get around to it right now.

I'm looking for a part of this api surface that lets you get file contents in order to write yourself, and I only see 'extract everything for me', just like tar.

This one was easy to add, since it's a drop in replacement for unzip, so I did.

|--------------------------------|------------------------------|---------------------------------------------------------------------------|
| Expression has no effect | Fewer false-positive results | This rule now treats uses of `Object.defineProperty` more conservatively. |
| Useless assignment to property | Fewer false-positive results | This rule now ignore reads of additional getters. |
| ZipSlip | More results | This rule now considers more libraries, including tar as well as zip. |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first field should be the @name of the query, so "Arbitrary file write during zip extraction ("Zip Slip")" in this case.

* Gets a node that can be a parsed archive.
*/
private DataFlow::SourceNode parsedArchive() {
result = DataFlow::moduleImport("unzipper").getAMemberCall("Parse")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test case for this one as well?

@semmle-qlci semmle-qlci merged commit 285f8b0 into github:master Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants