Impact
On Unix-like systems, the system temporary directory can be created with open permissions that allow multiple users to create and delete files within it. This library initialization could be vulnerable to a local privilege escalation from an attacker quickly deleting and recreating files in the system temporary directory.
If the Native.get(Class<>)
method was called, without calling Native.init(File)
first, with a non-null
argument used as working file path, then the library would initialize itself using the system temporary directory and the following code:
|
URL resource = getClass().getClassLoader().getResource(resourceName); |
|
if (resource != null) { |
|
File libFile; |
|
File libDir = File.createTempFile("native-platform", "dir"); |
|
libDir.delete(); |
|
libDir.mkdirs(); |
|
libFile = new File(libDir, libraryDef.name); |
|
libFile.deleteOnExit(); |
|
copy(resource, libFile); |
|
return libFile; |
|
} |
Patches
Initilization is now mandatory and no longer uses the system temporary directory, unless such a path is passed for initialization.
Version 0.22-milestone-28 has been released with those changes.
Workarounds
The only workaround for affected versions is to make sure to do a proper initialization, using a location that is safe.
References
More about this type of vulnerabilities:
CWE-378: Creation of Temporary File With Insecure Permissions
CWE-379: Creation of Temporary File in Directory with Insecure Permissions
Impact
On Unix-like systems, the system temporary directory can be created with open permissions that allow multiple users to create and delete files within it. This library initialization could be vulnerable to a local privilege escalation from an attacker quickly deleting and recreating files in the system temporary directory.
If the
Native.get(Class<>)
method was called, without callingNative.init(File)
first, with a non-null
argument used as working file path, then the library would initialize itself using the system temporary directory and the following code:native-platform/native-platform/src/main/java/net/rubygrapefruit/platform/internal/NativeLibraryLocator.java
Lines 68 to 78 in 574dfe8
Patches
Initilization is now mandatory and no longer uses the system temporary directory, unless such a path is passed for initialization.
Version 0.22-milestone-28 has been released with those changes.
Workarounds
The only workaround for affected versions is to make sure to do a proper initialization, using a location that is safe.
References
More about this type of vulnerabilities:
CWE-378: Creation of Temporary File With Insecure Permissions
CWE-379: Creation of Temporary File in Directory with Insecure Permissions