Permissions scripting
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript, node.js
- Domaine
- security
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- JavaScript
- Étoiles
- 123k
- Forks
- 39.3k
- Merge moyen
- 4 j 15 h
- PR mergées (30 j)
- 238
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nodejs/node
-
util: parseArgs() treats a `-` inside a short option group as the `--` terminatorPeut-être pris @yohannesjoya l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
http2: content-encoding is incorrectly listed in kSingleValueHeadersPeut-être pris @inoway46 l’a pris il y a 2 jours. Ouverteconfirmed-bug http2
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
nodejs/node#67151 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first keyPeut-être pris @helmipradita l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Peut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
nodejs/node#66551 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existPeut-être pris @Sepandard l’a pris il y a 38 jours. Ouvertedoc
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nodejs/node
Issues similaires
-
good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
modrollstudio/Modroll-Studio-Website#80 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
-
area: panel enhancement
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
GabrielGirardi/ledge#7 ·
-
0. Needs triage 35-feedback bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
A-linter
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
oxc-project/oxc#28783 ·
Les mainteneurs répondent en général sous 1 jour