GHSA-mcr4-qmvw-px4g: Maven/org.lz4:lz4-java vulnerability

Published Oct 7, 2026
·
Updated

Summary

When no system-installed liblz4-java is found, net.jpountz.util.Native.load() extracts the bundled native library to java.io.tmpdir and loads it with System.load. The path of the extracted library can be predicted before it is created, and the library file is opened without exclusive creation. Another local user who can write to the same temporary directory can therefore create the file first and control the code that is loaded.

Details

java tempLibLock = File.createTempFile("liblz4-java-", "." + os().libExtension + ".lck"); tempLib = new File(tempLibLock.getAbsolutePath().replaceFirst(".lck$", "")); // copy to tempLib try (FileOutputStream out = new FileOutputStream(tempLib)) { ... } ... System.load(tempLib.getAbsolutePath());

Only the .lck file is created safely, with a random name and exclusive creation. The library path is the .lck name without the .lck suffix, and nothing reserves it. new FileOutputStream(tempLib) opens it with OCREAT|OTRUNC and follows symlinks.

In a shared, world-writable temporary directory, another user can watch for the .lck file and create the corresponding library file before it is opened. If they win that race, they own the file. The victim then writes into the attacker-owned file, and the attacker can overwrite it again before System.load.

Whether this can be exploited depends on the host:

- With fs.protectedregular = 0, the attacker can pre-create a world-writable file, and their code is then loaded into the victim's JVM. - With fs.protectedregular >= 1 (the default on many systemd-based distributions), the victim's open fails. The library then fails to load and the library falls back to the Java implementations, so the attacker can only cause a denial of service. - A symlink variant is blocked by fs.protectedsymlinks = 1. - Temporary directories without the sticky bit, or shared across users in containers, are exploitable whatever these settings are.

This behaviour was introduced upstream in commit c3ddae5 (lz4-java 1.7.0), which swapped which of the two files is created with createTempFile.

Impact

A local user who can write to the same temporary directory as a victim process that uses the bundled JNI library may be able to execute code as the victim. Exploitation requires a shared temporary directory, host settings that permit it, and winning a race.

The issue does not apply if liblz4-java is found on java.library.path, if java.io.tmpdir is private to the user (for example systemd PrivateTmp, or a per-user temporary directory), or if only the Java implementations are used.

Patch

Fixed in lz4-java 1.11.4. The native library is now extracted directly into a file created by File.createTempFile, which has a random name and is created exclusively, so a file or symlink planted in advance cannot be reused. The .lck lock files are no longer used. Instead, the startup cleanup removes stale liblz4-java- temporary files (including .lck files left by older versions) only once they are more than one hour old.

For older versions, the workaround is to set java.io.tmpdir to a directory writable only by the application user, or install liblz4-java on java.library.path.

Affected Software

2 affected componentsFixes available
maven/org.lz4:lz4-java>=1.7.0<=1.8.1
maven/at.yawk.lz4:lz4-java<=1.11.3
1.11.4

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade maven/at.yawk.lz4:lz4-java to a version that resolves this vulnerability.

    Fixed in 1.11.4
  2. Upgrade

    Upgrade lz4-java to a version that resolves this vulnerability.

    Fixed in 1.11.4
  3. Configuration

    For older versions, set java.io.tmpdir to a directory writable only by the application user, such as a systemd PrivateTmp or per-user temporary directory.

    lz4-java java.io.tmpdir = A directory writable only by the application user
  4. Configuration

    For older versions, install liblz4-java on java.library.path so the system-installed native library is used instead of extracting the bundled library to java.io.tmpdir.

    lz4-java java.library.path = Directory containing liblz4-java

Event History

Oct 7, 2026
Advisory Published
via GitHub·08:35 PM
Data Sourced
via GitHub·08:35 PM
DescriptionWeaknessAffected Software

Frequently Asked Questions

1

Who is realistically exposed to this issue?

Systems that do not have a system-installed liblz4-java and use a shared, world-writable java.io.tmpdir are exposed to local attacks by another user who can write to that same temporary directory.

2

What does an attacker need to do to exploit it?

The attacker needs local write access to the temporary directory and must watch for creation of the liblz4-java lock file. They can then create the corresponding native-library path before the application opens it, causing the application to load attacker-controlled native code.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203