...
Noncompliant Code Example
The untrustedCode
method of class Untrusted
invokes loadLib
method of class NativeCode
in this noncompliant example. This is dangerous as the library gets loaded on behalf of the untrusted code. Accepting tainted inputs from untrusted code can further exacerbate this issue. In essence, the untrusted code's class loader may be able to load the intended library even if it does not have sufficient permissions.
Code Block | ||
---|---|---|
| ||
class NativeCode { public native void loadLib(); static { try { System.loadLibrary("/com/foo/MyLib.so"); }catch(UnsatisfiedLinkError e) { e.getMessage(); } } } class Untrusted { public static void untrustedCode() { new NativeCode().loadLib(); } } |
...