JavaScript

JavaScript

Made by DeepSource

Unsafe permissions set on a file JS-D017

Security
Major
a01 cwe-269 sans top 25 owasp top 10

Setting unsafe POSIX file permissions can be insecure and can lead to unintended access to files.

In Unix, the "others" class refers to all users except the owner of the file and the members of the group assigned to this file. Granting permissions to this group of users can lead to unintended access to files.

Bad Practice

const fs = require('fs');
const process = require('process');

fs.chmodSync("/tmp/fs", 0o777); // Sensitive
  // ...
})
process.umask(0o777); // Sensitive

Recommended

const fs = require('fs');
const process = require('process');

fs.chmodSync("/tmp/fs", 0o770); // Compliant
  // ...
})
process.umask(0o770); // Compliant

References