-
-
Notifications
You must be signed in to change notification settings - Fork 196
Attempt to fix v2 file overwrite vulnerability #213
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
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 |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ function Parse () { | |
| me._stream = new BlockStream(512) | ||
| me.position = 0 | ||
| me._ended = false | ||
| me._hardLinks = [] | ||
|
|
||
| me._stream.on("error", function (e) { | ||
| me.emit("error", e) | ||
|
|
@@ -250,7 +251,20 @@ Parse.prototype._startEntry = function (c) { | |
|
|
||
| if (onend) entry.on("end", onend) | ||
|
|
||
| if (entry.type === "File") { | ||
|
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. I'm not so sure if it's customary in this project, but I'd love to see a few comments explaining how this mitigates the security issue. May be valuable for someone maintaining this code in the future. Thanks! 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. Another request would be to cover the edge cases that exercise this logic in unit tests. |
||
| this._hardLinks.forEach(function(link) { | ||
| if (link.path === entry.path) { | ||
|
Owner
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. While this addresses the vulnerability, it's not an ideal fix, because it also changes the behavior of the export. A better solution would be to remove the file (or even just |
||
| ev = "ignoredEntry" | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| this._entry = entry | ||
|
|
||
| if (entry.type === "Link") { | ||
| this._hardLinks.push(entry) | ||
| } | ||
|
|
||
| var me = this | ||
|
|
||
| entry.on("pause", function () { | ||
|
|
||
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.
A
link -> targetmap object would be a more efficient and useful data structure than an array.