tags:

views:

168

answers:

4

What are common Java vulnerabilities that can be exploited to gain some sort of access to a system? I have been thinking about it recently, and havent been able to come up with much of anything - integer overflow - maybe? race condition - what does it give you?

I am not looking for things like "sql injection in a web app". I am looking for a relationship similar to buffer overflow - c/c++.

Any security experts out there that can help out? Thanks.

+1  A: 

I'm not a security expert, but there are some modules in our company that we can't code in java because it is so easy to de-compile java bytecode. We looked at obfuscation but if you want real obfuscation it comes only with a lot of problems (performance hit/loss of debug information).
One could steal our logics, replace the module with a modified version that will return incorrect results etc...

So compared to C/C++, I guess this is one "vulnerability" that stands out.

We also have a software license mechanism built-in in our java modules, but this can also be easily hacked by de-compiling and modifying the code.

Enno Shioji
+1  A: 

Including third party class files and calling upon them basically means you are running unsecure code. That code can do anything it wants if you don't have security turned on.

Pyrolistical
The same is true of installing third party C or C++ libraries, and calling upon them. That code can do *more* anything than the Java code.
Stephen P
+4  A: 

Malicious Code injection.

Because Java (or any language using an interpreter at runtime), performs linkage at runtime, it is possible to replace the expected JARs (the equivalent of DLLs and SOs) with malicious ones at runtime.

This is a vulnerability, which is combated since the first release of Java, using various mechanisms.

  • There are protections in places in the classloaders to ensure that java.* classes cannot be loaded from outside rt.jar (the runtime jar).
  • Additionally, security policies can be put in place to ensure that classes loaded from different sources are restricted to performing only a certain set of actions - the most obvious example is that of applets. Applets are constrained by the Java security policy model from reading or writing the file system etc; signed applets can request for certain permissions.
  • JARs can also be signed, and these signatures can be verified at runtime when they're loaded.
  • Packages can also be sealed to ensure that they come from the same codesource. This prevents an attacker from placing classes into your package, but capable of performing 'malicious' operations.

If you want to know why all of this is important, imagine a JDBC driver injected into the classpath that is capable of transmitting all SQL statements and their results to a remote third party. Well, I assume you get the picture now.

Vineet Reynolds
This exact concept just came to mind, and I was going to mention it. But, I have a hard time of wrapping my head around how one would take advantage of this... Can you provide a use case of how someone could inject a malicious jar? A lot of overflow exploits are done simply by viewing a web page, or processing an image. Maybe I am just thinking about it all wrong, and this is a whole different world of vulnerabilities...
wuntee
Well, the last few sentences cover that. Since Java is usually used on the enterprise side of the industry, in the server farms, you would usually need a willing system administrator, or a compromised server to pull this off. I'll consider the second scenario since it is more plausible. Imagine a server (facing the internet) with a root access exploit or similar that allows an attacker to modify files on it at any possible location. Such an attacker would be able to upload his malicious payload present in, say the javax.sql.* namespace (contd.).....
Vineet Reynolds
If he were able to replace PreparedStatement.class with his own variety, and get it loaded before the one in rt.jar, then it is really left to his imagination on what is possible if such a security hole exists. He could record all the data flowing back and forth the application server and the database, and possibly upload it periodically to an external server. Thankfully, the protections in place are probably good enough for today.
Vineet Reynolds
To get more imaginative on this topic, assume that the Swing classes have been compromised by an attacker on the client desktop, and that all password fields now capture the plaintext password and uploads it to another site. It is similar to the Mozilla "sniffer" malware that was yanked off the addons list, a few days back.Some of these attacks were possible before Sun introduced protection for the java.* and javax.* classes via the bootstrap classloader mechanism. Attacks would have been carried out using a custom classloader that loaded the attacker's classes before the classes from rt.jar
Vineet Reynolds
For example RMI downloads the code for stub classes from the remote system. The stub class can be something evil.
stribika
@wuntee As an example of injecting a malicious jar, consider the recent vulnerability in the Spring framework: http://www.springsource.com/security/cve-2010-1622
Sami Koivu