Skip to content

Commit 7122b41

Browse files
committed
fix: replace Runtime.exec() string concatenation with ProcessBuilder to prevent command injection (CWE-78)
1 parent 47ac069 commit 7122b41

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • page-object/src/main/java/com/iluwatar/pageobject

page-object/src/main/java/com/iluwatar/pageobject/App.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public static void main(String[] args) {
7777
} else {
7878
// Java Desktop not supported - above unlikely to work for Windows so try the
7979
// following instead...
80-
Runtime.getRuntime().exec("cmd.exe start " + applicationFile);
80+
// Use ProcessBuilder with separate arguments to avoid command injection vulnerability
81+
new ProcessBuilder("cmd.exe", "start", applicationFile.getAbsolutePath()).start();
8182
}
8283

8384
} catch (IOException ex) {

0 commit comments

Comments
 (0)