Buffer overrun in "Antitrust"

Skip this unless you're really, really geeky.

Still with us? OK. In the movie "Antitrust", there's a screenshot of some code that has a possible Denial Of Service vulnerability:

/* are we doing a GET or just a HEAD */
            boolean doingGet;
            /* beginning of file name */
            int index;
            if (buf[0] == (byte)'G' &&
                buf[1] == (byte)'E' &&
                buf[2] == (byte)'T' &&
                buf[3] == (byte)' ') {
                doingGet = true;
                index = 4;
            } else if (buf[0] == (byte)'H' &&
                       buf[1] == (byte)'E' &&
                       buf[2] == (byte)'A' &&
                       buf[3] == (byte)'D' &&
                       buf[4] == (byte)' ') {
                doingGet = false;
                index = 5;
            } else {
                /* we don't support this method */
                ps.print("HTTP/1.0 " + HTTP_BAD_METHOD +
                           " unsupported method type: ");
                ps.write(buf, 0, 5);
                ps.write(EOL);
                ps.flush();
                s.close();
                return;
            }

Because I can't resist such things, I paused the movie to read over the code. Now, I'm assuming this is Java instead of C++ because boolean wasn't spelled bool, although I'm not sure why they'd be using Java for performance critical code. Anyway. See the ps.write(buf, 0, 5); line near the end? Well, buf is presumably the string that the client sent to the server. If the client is broken (or malicious) enough to misspell "GET" and "HEAD", then the server politely tries to tell the client what it did wrong by sending buf's value back.

Which brings us to the hack. If buf is less than five characters long, then that ps.write line will attempt to read past the end of buf. If the calling function doesn't handle index error exceptions, boom! The service crashes: Denial Of Service. Note that this is still better than the C++ equivalent, which would write the contents of memory immediately following the end of buf back to the client.

No, I'm not exactly good at sitting back and watching movies.

Finally I find out that I am

Finally I find out that I am not alone with this Buffer Overunn Detected and I tried different solutions but I when I go the control panel and I check on the audio thats when i see this pop up. What Do I Do?
download movies on dvd

Java isn't slow

First of all... Java is not slow. There's a bad misconception in the world that Java is slow because of the previous experiences with Java Applets and prior versions of the JRE. Java, now, is rather speedy, although, I still wouldn't recommend using the Java applets in their current state. Java, in my opinion, is more for the server side platform than for client side code, although there are several really nice Java applications such as Azureus.

As for the code, at most you may get an IndexOutOfBoundsException; and unless you rolled your own application server (I'm assuming this code is in a Java Servlet), the most that you would get is a 500 error with a stack trace; not a server crash and Denial Of Service.

This is also just extremely bad code. If they wanted to find out the request "method", the would could use several ways:

// if you only have access to the HttpServletRequest object
if ("GET".equals(request.getMethod())) {
} else if ("HEAD".equals(request.getMethod()) {
}

If you're inside your own servlet, just implement the doGet() and doHead() methods that the abstract HttpServlet superclass provides.

As a side note, at least this this movie shows code, unlike the movie "Hackers". "Hackers" shows a virus that looks like pacman eating the contents on the screen.

Another favorite is Jurassic park, when the girl was trying to turn the power grid back on and exclaimed "This is a Unix system ... I know this!" even though it looked like a 3D flight simulator.

Java is slow

Java is pretty spritely what the kinds of things you'd want to use it for, but this was supposed to be the front end to an extremely optimized high-load streaming media server. That's one of the cases where I wouldn't want to use Java. In all fairness, I wouldn't want to use C++ there either most likely. It seems like the sort of place where you'd want to be a little closer to the metal (or very much further away with something like Lisp or OCaml with scary optimizations).

This is also just extremely bad code. If they wanted to find out the request "method", the would could use several ways

But would that involve object creation (such as String objects with values "GET" and "HEAD")? IANA Java expert by any means. Is it smart enough to optimize that into a single initialization and keep reusing those objects?

As a side note, at least this this movie shows code, unlike the movie "Hackers". "Hackers" shows a virus that looks like pacman eating the contents on the screen.

I'm not complaining. I like the fact that it's realistic enough that it can be nitpicked, instead of just flat-out dismissing it as fictional.

Another favorite is Jurassic park, when the girl was trying to turn the power grid back on and exclaimed "This is a Unix system ... I know this!" even though it looked like a 3D flight simulator.

You mean SGI's FSN 3D file manager? ;-)

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
five times equals 20
Solve this math question and enter the solution with digits. E.g. for "two plus four = ?" enter "6".

Powered by Drupal - Modified by Danger4k