JDK-6440902 : Vista: Runtime.exec() throws an IOException: CreateProcess: error=5 from plugin applet
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2006-06-20
  • Updated: 2011-02-16
  • Resolved: 2006-08-04
Description
FULL PRODUCT VERSION :
1.6.0-beta-b59g

ADDITIONAL OS VERSION INFORMATION :
Windows 6.0.5384

A DESCRIPTION OF THE PROBLEM :
Whenever a Java Applet attempts to run a command using Runtime.exec(), an IOException error is thrown:

java.io.IOException: CreateProcess: <command> error=5

Apparently, "error=5" means "Access Denied". The applet is signed and trusted by the user. The same applet works fine in IE7 on Windows XP.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the included source code.
2. Put the .class file into a signed JAR file.
3. Run the applet from a simple test page:

<html>
<head>
<title>Run a command via an applet</title>
</head>
<body>
<applet code="RunCommand.class" archive="RunCommand.jar" width="1" height="1">
<param name="cmd" value="ipconfig">
</applet>
</body>
</html>

4. View the console output.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The console should show the output of the command that the applet ran (ipconfig)
ACTUAL -
The IOException is displayed.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: CreateProcess: ipconfig error=5

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.applet.*;
import java.io.*;

public class RunCommand extends Applet
{
    public void start()
    {
        String cmd = getParameter("cmd");
        if (cmd != null) {
            try {
                Process p = Runtime.getRuntime().exec(cmd);

                InputStream is = p.getInputStream();
                byte[] buffer = new byte[4096];
                String results = "";
                int result = is.read(buffer);
                while (result >= 0) {
                    results += new String(buffer);
                    result = is.read(buffer);
                }
                System.out.println("Output of \"" + cmd + "\" is: ");
                System.out.println(results);
            } catch (Exception e) {
                System.out.println("Error while running cmd: " + e);
            }
        } else {
            System.out.println("No command available");
        }
    }
}

---------- END SOURCE ----------

Comments
EVALUATION Latest versions of windows vista allow plugin applet or plugin itself to call runtime.exec() after displaying an additional warning to the user.
04-08-2006

EVALUATION The window Vista has taken the new security model and won't allow low process (JPI in IE) to create a new process. Bug #6432317 has the same issue.
20-06-2006