Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider Java v3.0 (sch jp)

...

APIs

java.lang.Class.forName

java.lang.Package.getPackage(s)

java.lang.Runtime.load

java.lang.Runtime.loadLibrary

java.lang.System.load

java.lang.System.loadLibrary

java.sql.DriverManager.getConnection

java.sql.DriverManager.getDriver(s)

java.sql.DriverManager.deregisterDriver

java.util.ResourceBundle.getBundle

...

Noncompliant Code Example

The untrustedCode method invokes loadLibrary method in this non-compliant noncompliant example. This is dangerous as the library gets loaded on behalf of the untrusted code. The acceptance of tainted inputs from the untrusted code further exacerbates this issue. In essence, untrusted code's class loader may be able to load the intended library even if it does not have sufficient permissions.

Code Block
bgColor#FFcccc
public static void untrustedCode() {
  loadLibrary("/com/foo/MyLib.so");
}  

public static void loadLibrary() {
  System.loadLibrary(lib);
}

Compliant Solution

Ensure that untrusted code cannot invoke the affected APIs directly or indirectly (that is, via a call to an invoking method). Do not operate on tainted inputs and make sure that internal objects are not returned to untrusted code.

Code Block
bgColor#ccccff
public static void loadLibrary() {
  System.loadLibrary("/com/foo/HardcodedLib.so");
}

Risk Assessment

TODO

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

SEC03-J

??

??

??

P??

L??

Automated Detection

TODO

References

Sun Secure Coding Guidelines