Skip to content

Conversation

07souravkunda
Copy link
Collaborator

No description provided.

@07souravkunda 07souravkunda requested a review from a team as a code owner January 2, 2024 13:16
if (WORKSPACE_MODULE_PATH) {
exports.debug(`Getting ${module} from path ${WORKSPACE_MODULE_PATH}`);
let workspace_path = null;
workspace_path = path.join(WORKSPACE_MODULE_PATH, 'node_modules', module);

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal

Detected possible user input going into a `path.join` or `path.resolve` function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.
/* Find from node path */
let node_path = null;
if (!exports.isUndefined(process.env.NODE_PATH)) {
node_path = path.join(process.env.NODE_PATH, module);

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal

Detected possible user input going into a `path.join` or `path.resolve` function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.
/* Find from global node modules path */
exports.debug(`Getting ${module} from ${GLOBAL_MODULE_PATH}`);

let global_path = path.join(GLOBAL_MODULE_PATH, module);

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal

Detected possible user input going into a `path.join` or `path.resolve` function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.
} catch (_) {
/* Find from current working directory */
exports.debug(`Getting ${module} from ${process.cwd()}`);
let local_path = path.join(process.cwd(), 'node_modules', module);

Check warning

Code scanning / Semgrep

Semgrep Finding: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal

Detected possible user input going into a `path.join` or `path.resolve` function. This could possibly lead to a path traversal vulnerability, where the attacker can access arbitrary files stored in the file system. Instead, be sure to sanitize or validate user input first.
@07souravkunda
Copy link
Collaborator Author

07souravkunda commented Jan 2, 2024

Whitelisted all the required module paths. If not in the list throw error. This will ensure any random value of the module is not allowed.

@bstack-security-github bstack-security-github merged commit f443bb6 into browserstack:master Jan 9, 2024
@pranavj1001 pranavj1001 mentioned this pull request Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants