Skip to content

add CommandInjection.java - #164

Closed
chuckaude wants to merge 1 commit into
mainfrom
chuckaude-patch-2
Closed

chuckaude wants to merge 1 commit into
mainfrom
chuckaude-patch-2

Conversation

@chuckaude

Copy link
Copy Markdown

No description provided.

public class CommandInjection {
public static Process runCmd(HttpServletRequest request) throws IOException {
String command = request.getParameter("command");
ProcessBuilder builder = new ProcessBuilder("sh", command);

Copy link
Copy Markdown

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.

public class CommandInjection {
public static Process runCmd(HttpServletRequest request) throws IOException {
String command = request.getParameter("command");
ProcessBuilder builder = new ProcessBuilder("sh", command);

Copy link
Copy Markdown

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

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 fix

Ensure the tainted data cannot modify the intent of the OS command. If possible, use a safer library or API call instead.

@chuckaude chuckaude closed this Aug 5, 2026
@chuckaude
chuckaude deleted the chuckaude-patch-2 branch August 5, 2026 15:29
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.

1 participant