Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upworker: file creation races with process.umask() #32321
Comments
|
Fwiw, this seems problematic even without worker threads, because it also affects fs operations running on the libuv thread pool? |
|
Yes, that's right. I could swear there was a warning about that in the documentation at one point (at least about changing the umask) but not anymore. IMO,
|
|
I'm reopening this. It's deprecated now but the goal is to remove it entirely. |
|
Fwiw, at least:
use this function without arguments (I didn’t even try to find anything systematically). I think part of that usage is unnecessary, but we should probably make sure that ecosystem breakage is minimal before #32499 is released, and take a lot of time before removing this entirely. |
|
I filed issues with those projects. |
|
Hmm... this is a little bit tricky in the case of node-tar. I think there's a workaround, but wanted to float this here just to see what y'all think. Tar archive entries can contain a mode field. If a file entry has a mode of So, we check the umask at the start of the unpack process to know whether a chmod will be necessary, to avoid an extra stat call during the unpack process. Of course, this is not 100% bulletproof, since the umask can change along the way, but archive unpacking is never going to be safely atomic anyway. If Whichever version of Node loses |
Legacy fix for #22 Re nodejs/node#32321
|
Created issues for the npm deps relying on I strongly recommend holding off on this until the linked issues above are resolved. |
It's deprecated in the latest Node.js due to being insecure and it's not necessary to use it in the first place because the umask is automatically applied when creating the directory. Refs: nodejs/node#32321 Refs: isaacs/node-mkdirp#22
|
I pinned this issue to keep track of modules that use A first step would be to create a list of known commonly used modules with CITGM and Gzemnid. |
#6) ref nodejs/node#32321 Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
It's deprecated in the latest Node.js due to being insecure and it's not necessary to use it in the first place because the umask is automatically applied when creating the directory. Refs: nodejs/node#32321 Refs: isaacs/node-mkdirp#22
|
Concurrency Sanitizer may spot race conditions. |
|
@AhmedMostafa16 Not this kind of race condition. |
This commit introduces a documentation deprecation for calling process.umask() with no arguments. PR-URL: nodejs#32499 Fixes: nodejs#32321 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This code is unsafe when worker threads are active:
node/src/node_process_methods.cc
Lines 248 to 249 in 40b559a
The
umask(0)call temporarily changes the process-wide umask and races with fs operations from other threads.Test case:
Fails within a few iterations with
unexpected mode: 666process.umask()(no arg) is allowed in workers so this test case works both ways.This bug is potentially a security issue.