I am using Process.Start in a Windows Service I created to execute an exe that I have on my server that is used for audio conversion. I am passing some user input as a parameter to this exe. The code looks something like this:
string filePath = "\ffmpeg.exe";
string parameters = String.Format(@"-i ""{0}"" -f mp3 ""{1}""",
LocalFileName,
tempDirectory + NewFileName);
ProcessStartInfo startInfo = new ProcessStartInfo(ffmpegPath, parameters);
Process proc = Process.Start(startInfo);
The variables LocalFileName and NewFileName are set from user input. If I want to protect against OS Injection, is it sufficient to strip out any & characters or is there more that I should be doing?
test & timeout 1000– Abe Miessler May 09 '14 at 05:21&as I mentioned above... Are you saying this isn't possible? Just to clarify - you do know what&does in the Windows command prompt correct? – Abe Miessler May 09 '14 at 15:27cd c:\ & dirit would execute both of those commands. As you can imagine, allowing a malicious user to do this could cause serious problems. – Abe Miessler May 09 '14 at 15:49