| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7b01040 commit 2a12664
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -421,6 +421,24 @@ The following are **not** vulnerabilities in Node.js: | |||
| 421 | 421 | restrictions of their parent process. Passing an empty or modified `execArgv` | |
| 422 | 422 | to a worker does not grant it additional permissions. | |
| 423 | 423 | ||
| 424 | + #### Virtual File System (`node:vfs`) | ||
| 425 | + | ||
| 426 | + The experimental [Virtual File System](https://nodejs.org/api/vfs.html) | ||
| 427 | + (`node:vfs`) is a virtualized file-system API for tests, fixtures, embedded | ||
| 428 | + assets, and application-managed storage. It is **not** a sandbox, permission | ||
| 429 | + system, or security boundary for untrusted code. | ||
| 430 | + | ||
| 431 | + Code that can load `node:vfs`, receive a `VirtualFileSystem` instance, install a | ||
| 432 | + mount, choose a provider, or pass paths to VFS APIs is trusted application code. | ||
| 433 | + A VFS mount only redirects matching file-system calls; it does not hide or | ||
| 434 | + restrict access to the host file system. `RealFSProvider` root checks and | ||
| 435 | + read-only providers are implementation behavior, not security guarantees. | ||
| 436 | + | ||
| 437 | + Reports that rely on using VFS to isolate untrusted JavaScript, native code, or | ||
| 438 | + user-controlled paths are not considered Node.js vulnerabilities. Use OS-level | ||
| 439 | + isolation, such as separate users, containers, or platform sandboxes, when a | ||
| 440 | + security boundary is required. | ||
| 441 | + | ||
| 424 | 442 | #### V8 Sandbox | |
| 425 | 443 | ||
| 426 | 444 | The V8 sandbox is an in-process isolation mechanism internal to V8 that is not | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,10 +10,9 @@ added: v26.4.0 | |||
| 10 | 10 | ||
| 11 | 11 | <!-- source_link=lib/vfs.js --> | |
| 12 | 12 | ||
| 13 | - The `node:vfs` module provides an in-memory virtual file system with a | ||
| 14 | - `node:fs`-like API. It is useful for tests, fixtures, embedded assets, and other | ||
| 15 | - scenarios where you need a self-contained file system without touching the | ||
| 16 | - actual file-system. | ||
| 13 | + The `node:vfs` module provides a virtual file system with a `node:fs`-like API. | ||
| 14 | + It is useful for tests, fixtures, embedded assets, and other scenarios where you | ||
| 15 | + need a self-contained file system without touching the actual file-system. | ||
| 17 | 16 | ||
| 18 | 17 | To access it: | |
| 19 | 18 | ||
@@ -28,6 +27,22 @@ const vfs = require('node:vfs'); | |||
| 28 | 27 | This module is only available under the `node:` scheme, and only when Node.js | |
| 29 | 28 | is started with the `--experimental-vfs` flag. | |
| 30 | 29 | ||
| 30 | + ## Security | ||
| 31 | + | ||
| 32 | + The VFS API is not a sandbox, permission system, or access-control mechanism. | ||
| 33 | + It does not isolate untrusted code from the host file system or from other | ||
| 34 | + Node.js capabilities. Code that can access a [`VirtualFileSystem`][] instance, | ||
| 35 | + mount it, select its provider, or pass paths to it is trusted application code. | ||
| 36 | + | ||
| 37 | + Mounting a VFS only redirects supported [`node:fs`][] calls whose resolved paths | ||
| 38 | + are under the mount point. It does not prevent code from using other paths or | ||
| 39 | + other Node.js APIs to access resources available to the process. | ||
| 40 | + [`RealFSProvider`][] maps VFS paths under its configured root and rejects paths | ||
| 41 | + that resolve outside that root, but that check is not a security boundary. Do | ||
| 42 | + not rely on VFS to run untrusted code; use operating-system-level isolation, | ||
| 43 | + such as separate users, containers, or platform sandboxes, when a security | ||
| 44 | + boundary is required. | ||
| 45 | + | ||
| 31 | 46 | ## Basic usage | |
| 32 | 47 | ||
| 33 | 48 | ```cjs | |
@@ -68,7 +83,7 @@ const vfs = require('node:vfs'); | |||
| 68 | 83 | const memoryVfs = vfs.create(); | |
| 69 | 84 | ||
| 70 | 85 | // Explicit provider | |
| 71 | - const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/sandbox')); | ||
| 86 | + const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/vfs-root')); | ||
| 72 | 87 | ``` | |
| 73 | 88 | ||
| 74 | 89 | ## Class: `VirtualFileSystem` | |
@@ -257,10 +272,11 @@ myVfs.writeFileSync('/x.txt', 'fail'); // throws EROFS | |||
| 257 | 272 | added: v26.4.0 | |
| 258 | 273 | --> | |
| 259 | 274 | ||
| 260 | - A provider that wraps a directory (i.e. one on the actual file system) and exposes its | ||
| 261 | - contents through the VFS API. All VFS paths are resolved relative to | ||
| 262 | - the root and verified to stay inside it; symbolic links resolving | ||
| 263 | - outside the root are rejected. | ||
| 275 | + A provider that wraps a directory (i.e. one on the actual file system) and | ||
| 276 | + exposes its contents through the VFS API. All VFS paths are resolved relative to | ||
| 277 | + the root and verified to stay inside it; symbolic links resolving outside the | ||
| 278 | + root are rejected. This path mapping is not a sandbox or access-control | ||
| 279 | + mechanism. | ||
| 264 | 280 | ||
| 265 | 281 | ### `new RealFSProvider(rootPath)` | |
| 266 | 282 | ||
@@ -274,8 +290,8 @@ added: v26.4.0 | |||
| 274 | 290 | ```cjs | |
| 275 | 291 | const vfs = require('node:vfs'); | |
| 276 | 292 | ||
| 277 | - const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/sandbox')); | ||
| 278 | - realVfs.writeFileSync('/file.txt', 'hello'); // writes /tmp/sandbox/file.txt | ||
| 293 | + const realVfs = vfs.create(new vfs.RealFSProvider('/tmp/vfs-root')); | ||
| 294 | + realVfs.writeFileSync('/file.txt', 'hello'); // writes /tmp/vfs-root/file.txt | ||
| 279 | 295 | ``` | |
| 280 | 296 | ||
| 281 | 297 | ### `realFSProvider.rootPath` | |
@@ -303,6 +319,7 @@ fields use synthetic but stable values: | |||
| 303 | 319 | * Times default to the moment the entry was created/last modified. | |
| 304 | 320 | ||
| 305 | 321 | [`MemoryProvider`]: #class-memoryprovider | |
| 322 | + [`RealFSProvider`]: #class-realfsprovider | ||
| 306 | 323 | [`VirtualFileSystem`]: #class-virtualfilesystem | |
| 307 | 324 | [`VirtualProvider`]: #class-virtualprovider | |
| 308 | 325 | [`fs.BigIntStats`]: fs.md#class-fsbigintstats | |
| Back | FazBrowse Home | New Git URL |
0 commit comments