Skip to content

Commit cf85d54

Browse files
RafaelGSSaduh95
authored andcommitted
permission: disable FileHandle utimes with permission model
PR-URL: nodejs-private/node-private#873 Reviewed-By: Antoine du Hamel <[email protected]> CVE-ID: CVE-2026-48935 Refs: https://hackerone.com/reports/3625987
1 parent 138c702 commit cf85d54

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

lib/internal/fs/promises.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,9 @@ async function utimes(path, atime, mtime) {
11541154
}
11551155

11561156
async function futimes(handle, atime, mtime) {
1157+
if (permission.isEnabled()) {
1158+
throw new ERR_ACCESS_DENIED('futimes API is disabled when Permission Model is enabled.');
1159+
}
11571160
atime = toUnixTimestamp(atime, 'atime');
11581161
mtime = toUnixTimestamp(mtime, 'mtime');
11591162
return await PromisePrototypeThen(
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Flags: --permission --allow-fs-read=*
2+
'use strict';
3+
4+
const common = require('../common');
5+
const { isMainThread } = require('worker_threads');
6+
7+
if (!isMainThread) {
8+
common.skip('This test only works on a main thread');
9+
}
10+
11+
if (!common.hasCrypto) {
12+
common.skip('no crypto');
13+
}
14+
15+
const assert = require('assert');
16+
const { open } = require('fs/promises');
17+
const fixtures = require('../common/fixtures');
18+
19+
const regularFile = fixtures.path('permission', 'deny', 'regular-file.md');
20+
21+
// FileHandle.utimes() must be blocked when the permission model is enabled,
22+
// consistent with fs.futimes() / fs.futimesSync().
23+
(async () => {
24+
const fh = await open(regularFile, 'r');
25+
try {
26+
await assert.rejects(
27+
fh.utimes(Date.now(), Date.now()),
28+
common.expectsError({ code: 'ERR_ACCESS_DENIED' }),
29+
);
30+
} finally {
31+
await fh.close();
32+
}
33+
})().then(common.mustCall());

0 commit comments

Comments
 (0)