Skip to content

Local privilege escalation through system temporary directory

High
cobexer published GHSA-2xxp-vw2f-p3x8 Feb 25, 2025

Package

maven net.rubygrapefruit:native-platform (Maven)

Affected versions

< 0.22-milestone-28

Patched versions

0.22-milestone-28

Description

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

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

CVE ID

CVE-2025-27148

Weaknesses

Creation of Temporary File With Insecure Permissions

Opening temporary files without appropriate measures or controls can leave the file, its contents and any function that it impacts vulnerable to attack. Learn more on MITRE.

Creation of Temporary File in Directory with Insecure Permissions

The product creates a temporary file in a directory whose permissions allow unintended actors to determine the file's existence or otherwise access that file. Learn more on MITRE.

Credits