Permissions scripting
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, node.js
- 領域
- security
研究方向
The issue does not name implementation files or tests. Start by reading Node.js's existing permission model and tracing how permission checks handle filesystem, child-process, and network access. The proposal needs design decisions about the script API, how it interacts with existing flags, and how checks are enforced; done means those behaviors are specified and covered by tests.
由索引模型根據 Issue 內容生成。
描述
What is the problem this feature will solve?
Right now, permissions are either all-or-nothing, or each path must be manually specified.
There is also a lack of scoping on most permission flags. While adding scoping to these flags would help significantly, it would be helpful to be able to write custom logic to scope them in a more fine-grained fashion.
This feature request is primarily motivated by the lack of scoping on child. Initially I had drafted a feature request to add simple allow-listed scoping for child, but if, for instance, the python executable were to be allow-listed, a malicious script could run:
function portable_rm(file) {
if (process.permission.has('fs.write', file) {
// unlink file using node apis
} else if (process.permission.has('child', 'rm') {
// exec rm file
} else if (process.permission.has('child', 'python') {
// exec python -c 'import shutil; shutil.rmtree(...)'
} // etc.
}
By using regex (or other custom logic), we can prevent these types of attacks by further limiting the command lines to known arguments.
What is the feature you are proposing to solve the problem?
A script that allows for custom scoping on all permission grants:
import path from 'node:path';
// Helper: path_str would already be an absolute path
function _check_path(path_str, allow_list) {
for (const allowed_path of allow_list) {
if (path.matchesGlob(path_str, path.resolve(allowed_path)))
return true;
}
return false;
}
function check_fs_read(path_str) {
return _check_path(path_str, [
'/foo/*',
'./bar/baz.txt'
]);
}
function check_fs_write(path_str) {
return _check_path(path_str, [
'./bar/baz.txt'
]);
}
function check_child(exec, args) {
if (exec === "python") {
if (args.length !== 2) return false;
return args[0] === "myproc.py";
} else if (exec === "esbuild") {
if (args.length < 1) return false;
return /^--(bundle|minify)$/.test(args[0]);
}
return false;
}
function check_net(addr) {
return /^https:\/\/([^/]*\.)?mycompany\.com\//.test(addr);
}
export default {
fs_read: check_fs_read,
fs_write: check_fs_write,
child: check_child,
net: check_net,
// any permission missing here would be denied by default, unless a respective --allow-* flag exists
}
It could then be run with (e.g.) node --permission --permissions-script=./permissions.js ...
The scoping does not necessarily have to be perfect, as just needs to match what the project knows it requires.
There would naturally be a minor performance hit, but this would allow for powerful scoping that would allow for projects to have permissions exactly as fine-grained as they needed.
On our end, the added security benefit far outweighs the performance hit, as it allows for better security during development. For deployment, we can replace the permission model with containers to remove the performance impact.
What alternatives have you considered?
-
Using a socket-based permission broker: https://docs.deno.com/runtime/fundamentals/security/#permission-broker
-
Adding regex-based allow-listing for
childandnet.
- 主要語言
- JavaScript
- 星號
- 123k
- 分支
- 39.3k
- 平均合併
- 4 天 16 小時
- 30 天內合併 PR
- 227
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
nodejs/node 的其他 Issue
-
http2: content-encoding is incorrectly listed in kSingleValueHeaders可能已有人在做 @inoway46 於 1 天前認領。 未關閉confirmed-bug http2
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first key可能已有人在做 @helmipradita 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already exist可能已有人在做 @Sepandard 於 37 天前認領。 未關閉doc
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
Stream.prototype.forEach will block in first promise in queue before read more chunk可能已有人在做 @mmustafasenoglu 於 38 天前認領。 未關閉doc
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
相似的 Issue
-
ready-for-agent
難度 2/5 1-3 小時 新手友好度 78/100
LucasSantana-Dev/Lucky#2945 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
brijeshb42/monaco-vim#175 ·
-
good first issue
難度 2/5 3-5 天 新手友好度 62/100
paipai1999/POS-system#3 ·
-
good first issue
難度 2/5 1-3 小時 新手友好度 85/100
r-afael/better-yt-recommendations#36 ·
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 66/100
microsoft/playwright#43875 · 1 則留言 ·
維護者通常 1 天內回覆