Repository navigation
add CommandInjection.java #164
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
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,13 @@ | ||
| // https://documentation.blackduck.com/bundle/coverity-docs/page/checker-ref/checkers/NO/os_cmd_injection.html | ||
|
|
||
| import java.io.*; | ||
| import javax.servlet.http.HttpServletRequest; | ||
|
|
||
| public class CommandInjection { | ||
| public static Process runCmd(HttpServletRequest request) throws IOException { | ||
| String command = request.getParameter("command"); | ||
| ProcessBuilder builder = new ProcessBuilder("sh", command); | ||
|
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. Auto-generated PR comment (Coverity)Coverity Issue - OS Command InjectionPriority: High Calling "ProcessBuilder". Passing the tainted value "{"sh", command}" to the process-invoking API may allow an attacker to modify the intention of the command. 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. If possible, use a safer library or API call instead. |
||
| Process process = builder.start(); | ||
| return(process); | ||
| } | ||
| } | ||
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.
Auto-generated PR comment (Coverity)
Coverity Issue - OS Command Injection
Priority: High
Vulnerability: CWE-78
CID: 10014
View in Coverity Connect
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
How to fix
Ensure that external-influenced data cannot modify the intent of the OS command. Sanitize the data before using it inside a sensitive function call. If possible, use a safer library or API call instead.