-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib,permission: restrict process.binding when pm is enabled
PR-URL: nodejs-private/node-private#438 Fixes: nodejs-private/node-private#422 CVE-ID: CVE-2023-32558
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const common = require('../../common'); | ||
common.skipIfWorker(); | ||
|
||
const assert = require('assert'); | ||
|
||
{ | ||
assert.throws(() => { | ||
process.binding(); | ||
}, common.expectsError({ | ||
code: 'ERR_ACCESS_DENIED', | ||
})); | ||
} | ||
|
||
{ | ||
assert.throws(() => { | ||
process.binding('async_wrap'); | ||
}, common.expectsError({ | ||
code: 'ERR_ACCESS_DENIED', | ||
})); | ||
} | ||
|
||
{ | ||
assert.throws(() => { | ||
process.binding('fs'); | ||
}, common.expectsError({ | ||
code: 'ERR_ACCESS_DENIED', | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfWorker(); | ||
|
||
if (!common.hasCrypto) { | ||
common.skip('no crypto'); | ||
} | ||
|
||
const { spawnSync } = require('child_process'); | ||
const assert = require('assert'); | ||
const fixtures = require('../common/fixtures'); | ||
const file = fixtures.path('permission', 'processbinding.js'); | ||
|
||
// Due to linting rules-utils.js:isBinding check, process.binding() should | ||
// not be called when --experimental-permission is enabled. | ||
// Always spawn a child process | ||
{ | ||
const { status, stderr } = spawnSync( | ||
process.execPath, | ||
[ | ||
'--experimental-permission', '--allow-fs-read=*', file, | ||
], | ||
); | ||
assert.strictEqual(status, 0, stderr.toString()); | ||
} |