-
Notifications
You must be signed in to change notification settings - Fork 1
add cmd-injection.js #3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // https://documentation.blackduck.com/bundle/coverity-docs/page/checker-ref/checkers/NO/os_cmd_injection.html | ||
|
|
||
| const express = require("express"); | ||
| const app = express(); | ||
|
|
||
| app.get("/run", function run(req, res, next) { // OS_CMD_INJECTION defect | ||
| require("child_process").exec(req.query.cmd); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Automated PR Comment From coverityCoverity Issue - OS Command InjectionHigh CWE-78 A user can change the intent of an operating system command. This change may result in the disclosure, destruction, or modification of sensitive data or operating system resources. How to fixEnsure the tainted data cannot modify the intent of the OS command. Sanitize the data before using inside a sensitive function call. If possible, use a safer library or API call instead. |
||
| res.send("Done"); | ||
| }); | ||
| app.listen(1337, function() { | ||
| console.log("Express listening..."); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated PR Comment From coverity
Coverity Issue - Sending X-Powered-By header
Low CWE-201
HTTP responses contain an
X-Powered-Byheader that reveals information about the server which helps attackers exploit known vulnerabilities or craft more targeted exploits.How to fix
Use
app.disable('x-powered-by')to disable theX-Powered-Byheader. If you're using an older version of Express that does not support this setting and you can't upgrade, create a middleware to callres.removeHeader("x-powered-by")whereresis the response object.