1
我試圖從代碼運行Microsoft Rdp應用程序。Java中的命令注入漏洞
我有以下的僞代碼和SonarQube
抱怨Command Injection Vulnerability
String rdpFilePath = myObject.getRdpFilePath() // get path of .rdp settings file
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("mstsc", rdpFilePath).start();
SonarQube問題解釋如下:
-Potential Command Injection-
The highlighted API is used to execute a system command.
If unfiltered input is passed to this API, it can lead to arbitrary command execution.
如何過濾我的輸入和如何解決這個安全問題?
嗨,我已經添加了rdpFilePath一致性檢查和可讀性檢查。但即使在這種情況下,SonarQube也會警告有關命令注入的漏洞。我正在尋找的是解決這個問題的最安全的解決方案。 –
您絕對沒有所有這些檢查的安全問題。但SonarQube無法理解您的過濾代碼,並會繼續警告潛在的安全風險。您可以禁用代碼塊的特定警告。檢查這[回答](https://stackoverflow.com/questions/10971968/turning-sonar-off-for-certain-code)。 – berserkk