This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clobber a Link if it's in the way of a File
Fixes isaacs/node-tar#212
- Loading branch information
6a77d2f
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.
Does this fix really solve the issue? Doesn't it make it just racy? (e.g. if at the time of check the file is a regular one and it is switched to an hardlink just before the
create()
function is called)6a77d2f
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.
I don't believe this patch is attempting to resolve a TOCTOU condition. The context of the original issue (https://hackerone.com/reports/344595) is that arbitrary files on the filesystem could be overwritten if a crafted tar archive were extracted.
Within that context, I don't believe this fix is has a race condition. It is not trying to prevent general TOCTOU issues. Rather, it's preventing the condition where you're in the process of iterating through the entries in a tar archive and you:
Without this fix, this scenario would result in /etc/passwd being overwritten with the contents of the regular file "LINK".
All that being said, I am really not a javascript/node.js developer, so:
6a77d2f
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.
True, though I was not able to trigger the issue while extracting a tar. Maybe I'm just missing something, but I ended up analyzing the issue in the context of a copy from one directory to another. Also, from reading various comments around this seemed more like a security fix to make npm-audit happy.