permission: disable FileHandle utimes with permission model

PR-URL: https://github.com/nodejs-private/node-private/pull/873
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
CVE-ID: CVE-2026-48935
Refs: https://hackerone.com/reports/3625987
This commit is contained in:
RafaelGSS authored and Antoine du Hamel committed 2026-06-17 20:02:06 +02:00
1 parent 138c70294b
commit cf85d54839
2 files changed
+36

No files matched your search

+3
View File
@@ -1154,6 +1154,9 @@ async function utimes(path, atime, mtime) {
}
async function futimes(handle, atime, mtime) {
if (permission.isEnabled()) {
throw new ERR_ACCESS_DENIED('futimes API is disabled when Permission Model is enabled.');
}
atime = toUnixTimestamp(atime, 'atime');
mtime = toUnixTimestamp(mtime, 'mtime');
return await PromisePrototypeThen(
@@ -0,0 +1,33 @@
// Flags: --permission --allow-fs-read=*
'use strict';
const common = require('../common');
const { isMainThread } = require('worker_threads');
if (!isMainThread) {
common.skip('This test only works on a main thread');
}
if (!common.hasCrypto) {
common.skip('no crypto');
}
const assert = require('assert');
const { open } = require('fs/promises');
const fixtures = require('../common/fixtures');
const regularFile = fixtures.path('permission', 'deny', 'regular-file.md');
// FileHandle.utimes() must be blocked when the permission model is enabled,
// consistent with fs.futimes() / fs.futimesSync().
(async () => {
const fh = await open(regularFile, 'r');
try {
await assert.rejects(
fh.utimes(Date.now(), Date.now()),
common.expectsError({ code: 'ERR_ACCESS_DENIED' }),
);
} finally {
await fh.close();
}
})().then(common.mustCall());