Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js/command-line-injection #49

Open
armorcodegithubpreprod bot opened this issue Mar 20, 2024 · 1 comment
Open

js/command-line-injection #49

armorcodegithubpreprod bot opened this issue Mar 20, 2024 · 1 comment

Comments

@armorcodegithubpreprod
Copy link

Uncontrolled command line
Using externally controlled strings in a command line may allow a malicious user to change the meaning of the command.
This command line depends on a user-provided value.
Commit SHA: 459cd0f
Line Number: 130
Tool Name: CodeQL

File Path: src/app.controller.ts:130

Mitigation: # Uncontrolled command line
Code that passes user input directly to require('child_process').exec, or some other library routine that executes a command, allows the user to execute malicious code.

Recommendation

If possible, use hard-coded string literals to specify the command to run or library to load. Instead of passing the user input directly to the process or library function, examine the user input and then choose among hard-coded string literals.

If the applicable libraries or commands cannot be determined at compile time, then add code to verify that the user input string is safe before using it.

Example

The following example shows code that takes a shell script that can be changed maliciously by a user, and passes it straight to child_process.exec without examining it first.

var cp = require("child_process"),
    http = require('http'),
    url = require('url');

var server = http.createServer(function(req, res) {
    let cmd = url.parse(req.url, true).query.path;

    cp.exec(cmd); // BAD
});

References

Impact: See Description

Tool Finding Id: 9

Finding Id : 52851327

Copy link
Author

Finding [52851327] status changed to Confirmed
Note:
by vincent.goyal@armorcode.io via ArmorCode Platform

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

No branches or pull requests

0 participants