This question is similar to Exploitable PHP Functions.
Tainted data comes from the user, or more specifically an attacker. When a tainted variable reaches a sink function, then you have a vulnerability. For instance a function that executes a sql query is a sink, and GET/POST variables are sources of taint.
What are all of the sink functions in the Java class library (for any flavor of Java)? I am looking for functions that introduce a vulnerability or software weakness. I am particularly interested in Remote Code Execution vulnerabilities. Are there whole classes/libraries that contain nasty functionally that a hacker would like to influence? How do people accidentally make dangerous Java code?
With a critical CVSS rating of 9.8, Spring4Shell leaves affected systems vulnerable to remote code execution (RCE). To illustrate why Spring4Shell is such a critical vulnerability, it helps to understand how Spring works.
While Java is considered relatively safe because it is a server side language, there are still multiple ways to attack and access secure code you'd like to remain private. Here are the top ten Java security vulnerabilities to keep in mind as you code away.
The default deployment method for Spring Boot (executable JAR) is not vulnerable to the exploit.
Certain Java SE (JDK and JRE) versions are susceptible to vulnerabilities that could allow the compromise of Java SE via network access, lead to unauthorized ability to cause a frequently repeatable crash (DoS) of Java SE, or allow unauthorized read, update, insert or delete access to some Java SE accessible data.
Here's a list based on my personal research into Client-side Java security in general, and using the Eclipse IDE to see which methods do SecurityManager checks.
ClassLoaders define classes (=arbitrary java code execution):
java.lang.ClassLoader.defineClass java.net.URLClassLoader
= code execution
Java Beans Introspection may divert ClassLoaders into loading classes from an untrusted source (example vuln - cve-2010-1622)
java.beans.Instrospector.getBeanInfo
= code execution
File access
java.io.File (constructor) java.io.File.delete java.io.File.renameTo java.io.File.listFiles java.io.File.list
= deleting/renaming files, directory listing
File stream/reader classes
java.io.FileInputStream java.io.FileOutputStream java.io.FileReader java.io.FileWriter java.io.RandomAccessFile
=File read/write access
Java System Properties
System.setProperty System.getProperties System.getProperty
=Some system properties might contain some information that's almost sensitive, and some system properties might alter the execution of critical stuff, I don't have examples, though
Loading native libraries
System.load System.loadLibrary
= Arbitrary code execution
Executing operating system executables
Runtime.exec ProcessBuilder (constructor)
Generating native system input events
java.awt.Robot.keyPress/keyRelease java.awt.Robot.mouseMove/mousePress/mouseRelease
(Maybe far-fetched since a server might not even have a graphical environment)
Java reflection - accessing arbitrary (even private) fields and methods
java.lang.Class.getDeclaredMethod java.lang.Class.getDeclaredField java.lang.reflection.Method.invoke java.lang.reflection.Field.set java.lang.reflection.Field.get
= From disclosing sensitive information to eventual code execution, depending on the circumstances
Java scripting engine
javax.script.ScriptEngine.eval
=arbitrary code execution
Code execution vulnerabilities:
(This is about .net, but I expect Java to be very similar)
Data injection
Then there is the injection family of functions which typically can be prevented by not operating on strings but using specialized library functions. Those typically don't lead to arbitrary code injection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With