Skip to content

Conversation

@chuckaude
Copy link

No description provided.

public class CommandInjection {
public static Process runCmd(HttpServletRequest request) throws IOException {
String filename = request.getParameter("filename");
ProcessBuilder builder = new ProcessBuilder("cat", filename);
Copy link

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

High CWE-78
Calling "ProcessBuilder". Passing the tainted value "{"cat", filename}" 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 Dec 8, 2025
@chuckaude chuckaude deleted the chuckaude-patch-1 branch December 8, 2025 20:49
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.

2 participants