Skip to content

Commit ef1c0d7

Browse files
RafaelGSStargos
authored andcommitted
src,permission: handle process.chdir on pm
PR-URL: #53175 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
1 parent 90b632e commit ef1c0d7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/node_process_methods.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ static void Chdir(const FunctionCallbackInfo<Value>& args) {
8383
CHECK_EQ(args.Length(), 1);
8484
CHECK(args[0]->IsString());
8585
Utf8Value path(env->isolate(), args[0]);
86+
THROW_IF_INSUFFICIENT_PERMISSIONS(
87+
env, permission::PermissionScope::kFileSystemRead, path.ToStringView());
8688
int err = uv_chdir(*path);
8789
if (err) {
8890
// Also include the original working directory, since that will usually

test/fixtures/permission/fs-read.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@ const regularFile = __filename;
387387
}));
388388
}
389389

390+
// process.chdir
391+
{
392+
assert.throws(() => {
393+
process.chdir(blockedFolder);
394+
}, common.expectsError({
395+
code: 'ERR_ACCESS_DENIED',
396+
permission: 'FileSystemRead',
397+
resource: blockedFolder,
398+
}));
399+
}
400+
390401
// fs.lstat
391402
{
392403
assert.throws(() => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy