Skip to content

Commit b270cdb

Browse files
committed
vfs: remove vfs-mount and vfs-unmount process events
Remove the vfs-mount/vfs-unmount events emitted on process, as they are insufficient as a security control and a proper permission system is needed instead.
1 parent 3b8e89c commit b270cdb

File tree

3 files changed

+0
-184
lines changed

3 files changed

+0
-184
lines changed

doc/api/vfs.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -951,32 +951,6 @@ This is particularly dangerous because:
951951
* Only specific targeted files are affected.
952952
* Other operations appear to work normally.
953953

954-
### Monitoring VFS mounts
955-
956-
To help detect unauthorized VFS usage, `node:process` emits events when
957-
a VFS is mounted or unmounted:
958-
959-
```cjs
960-
process.on('vfs-mount', (info) => {
961-
console.log(`VFS mounted at ${info.mountPoint}`);
962-
console.log(` overlay: ${info.overlay}`);
963-
console.log(` readonly: ${info.readonly}`);
964-
});
965-
966-
process.on('vfs-unmount', (info) => {
967-
console.log(`VFS unmounted from ${info.mountPoint}`);
968-
});
969-
```
970-
971-
The event object contains:
972-
973-
* `mountPoint` {string} The path where the VFS is mounted.
974-
* `overlay` {boolean} Whether overlay mode is enabled.
975-
* `readonly` {boolean} Whether the VFS is read-only.
976-
977-
Applications can use these events to log VFS activity, alert on suspicious
978-
mounts (such as mounting over system paths), or enforce security policies.
979-
980954
### Recommendations
981955

982956
* **Audit dependencies**: Be cautious of third-party modules that use VFS, as

lib/internal/vfs/file_system.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,29 +235,13 @@ class VirtualFileSystem {
235235
this.#hookProcessCwd();
236236
}
237237

238-
// Emit mount event for security monitoring
239-
process.emit('vfs-mount', {
240-
mountPoint: this[kMountPoint],
241-
overlay: this[kOverlay],
242-
readonly: this[kProvider].readonly,
243-
});
244-
245238
return this;
246239
}
247240

248241
/**
249242
* Unmounts the VFS.
250243
*/
251244
unmount() {
252-
// Emit unmount event before clearing state (only if currently mounted)
253-
if (this[kMounted]) {
254-
process.emit('vfs-unmount', {
255-
mountPoint: this[kMountPoint],
256-
overlay: this[kOverlay],
257-
readonly: this[kProvider].readonly,
258-
});
259-
}
260-
261245
this.#unhookProcessCwd();
262246
if (this[kModuleHooks]) {
263247
loadModuleHooks();

test/parallel/test-vfs-mount-events.js

Lines changed: 0 additions & 142 deletions
This file was deleted.

0 commit comments

Comments
 (0)