Skip to content

Commit a67dd46

Browse files
RafaelGSSaduh95
authored andcommitted
permission: guard pipe open and chmod with net scope
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com> PR-URL: nodejs-private/node-private#885 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> CVE-ID: CVE-2026-48936 Refs: https://hackerone.com/reports/3618831
1 parent 7057c3f commit a67dd46

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/pipe_wrap.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ void PipeWrap::SetPendingInstances(const FunctionCallbackInfo<Value>& args) {
184184
void PipeWrap::Fchmod(const v8::FunctionCallbackInfo<v8::Value>& args) {
185185
PipeWrap* wrap;
186186
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.This());
187+
Environment* env = wrap->env();
187188
CHECK(args[0]->IsInt32());
188189
int mode = args[0].As<Int32>()->Value();
190+
THROW_IF_INSUFFICIENT_PERMISSIONS(env, permission::PermissionScope::kNet, "");
189191
int err = uv_pipe_chmod(&wrap->handle_, mode);
190192
args.GetReturnValue().Set(err);
191193
}

test/parallel/test-permission-net-uds.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ if (common.isWindows) {
99
}
1010

1111
const assert = require('assert');
12+
const fs = require('fs');
1213
const net = require('net');
1314
const tls = require('tls');
1415

16+
const pipePath = (name) => `/tmp/node-test-${process.pid}-${name}.sock`;
17+
18+
assert.strictEqual(process.permission.has('net'), false);
19+
1520
{
16-
const client = net.connect({ path: '/tmp/perm.sock' });
21+
const client = net.connect({ path: pipePath('perm') });
1722
client.on('error', common.mustCall((err) => {
1823
assert.strictEqual(err.code, 'ERR_ACCESS_DENIED');
1924
}));
@@ -22,7 +27,7 @@ const tls = require('tls');
2227
}
2328

2429
{
25-
const client = tls.connect({ path: '/tmp/perm.sock' });
30+
const client = tls.connect({ path: pipePath('perm-tls') });
2631
client.on('error', common.mustCall((err) => {
2732
assert.strictEqual(err.code, 'ERR_ACCESS_DENIED');
2833
}));
@@ -31,19 +36,25 @@ const tls = require('tls');
3136
}
3237

3338
{
39+
const path = pipePath('perm-server');
40+
const server = net.createServer();
3441
assert.throws(() => {
35-
net.createServer().listen('/tmp/perm-server.sock');
42+
server.listen(path);
3643
}, {
3744
code: 'ERR_ACCESS_DENIED',
3845
permission: 'Net',
3946
});
47+
assert.strictEqual(fs.existsSync(path), false);
4048
}
4149

4250
{
51+
const path = pipePath('perm-tls-server');
52+
const server = tls.createServer();
4353
assert.throws(() => {
44-
tls.createServer().listen('/tmp/perm-tls-server.sock');
54+
server.listen(path);
4555
}, {
4656
code: 'ERR_ACCESS_DENIED',
4757
permission: 'Net',
4858
});
59+
assert.strictEqual(fs.existsSync(path), false);
4960
}

0 commit comments

Comments
 (0)