Skip to content

Commit 7057c3f

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 d1be630 commit 7057c3f

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
@@ -1802,6 +1802,9 @@ async function utimes(path, atime, mtime) {
18021802
}
18031803

18041804
async function futimes(handle, atime, mtime) {
1805+
if (permission.isEnabled()) {
1806+
throw new ERR_ACCESS_DENIED('futimes API is disabled when Permission Model is enabled.');
1807+
}
18051808
atime = toUnixTimestamp(atime, 'atime');
18061809
mtime = toUnixTimestamp(mtime, 'mtime');
18071810
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)