Skip to content

Commit 686da19

Browse files
tniessenRafaelGSS
authored andcommitted
deps: disable io_uring support in libuv by default
setuid() does not affect libuv's internal io_uring operations if initialized before the call to setuid(). This potentially allows the process to perform privileged operations despite presumably having dropped such privileges through a call to setuid(). Similar concerns apply to other functions that modify the process's user identity. This commit changes libuv's io_uring behavior from opt-out (through UV_USE_IO_URING=0) to opt-in (through UV_USE_IO_URING=1) until we figure out a better long-term solution. PR-URL: nodejs-private/node-private#529 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> CVE-ID: CVE-2024-22017
1 parent f7b44bf commit 686da19

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

deps/uv/src/unix/linux.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,9 @@ static int uv__use_io_uring(void) {
431431
use = atomic_load_explicit(&use_io_uring, memory_order_relaxed);
432432

433433
if (use == 0) {
434+
/* Disable io_uring by default due to CVE-2024-22017. */
434435
val = getenv("UV_USE_IO_URING");
435-
use = val == NULL || atoi(val) ? 1 : -1;
436+
use = val != NULL && atoi(val) ? 1 : -1;
436437
atomic_store_explicit(&use_io_uring, use, memory_order_relaxed);
437438
}
438439

doc/api/cli.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,22 @@ threadpool by setting the `'UV_THREADPOOL_SIZE'` environment variable to a value
27382738
greater than `4` (its current default value). For more information, see the
27392739
[libuv threadpool documentation][].
27402740

2741+
### `UV_USE_IO_URING=value`
2742+
2743+
Enable or disable libuv's use of `io_uring` on supported platforms.
2744+
2745+
On supported platforms, `io_uring` can significantly improve the performance of
2746+
various asynchronous I/O operations.
2747+
2748+
`io_uring` is disabled by default due to security concerns. When `io_uring`
2749+
is enabled, applications must not change the user identity of the process at
2750+
runtime, neither through JavaScript functions such as [`process.setuid()`][] nor
2751+
through native addons that can invoke system functions such as [`setuid(2)`][].
2752+
2753+
This environment variable is implemented by a dependency of Node.js and may be
2754+
removed in future versions of Node.js. No stability guarantees are provided for
2755+
the behavior of this environment variable.
2756+
27412757
## Useful V8 options
27422758

27432759
V8 has its own set of CLI options. Any V8 CLI option that is provided to `node`
@@ -2839,6 +2855,8 @@ done
28392855
[`dnsPromises.lookup()`]: dns.md#dnspromiseslookuphostname-options
28402856
[`import` specifier]: esm.md#import-specifiers
28412857
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
2858+
[`process.setuid()`]: process.md#processsetuidid
2859+
[`setuid(2)`]: https://man7.org/linux/man-pages/man2/setuid.2.html
28422860
[`tls.DEFAULT_MAX_VERSION`]: tls.md#tlsdefault_max_version
28432861
[`tls.DEFAULT_MIN_VERSION`]: tls.md#tlsdefault_min_version
28442862
[`unhandledRejection`]: process.md#event-unhandledrejection

0 commit comments

Comments
 (0)