Exploit database

GH-49a09ef0a3f480a3671ed1d028426ba0

uxokpro1234/java4shell-cve-2026-114938-defender

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-114938

42 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files7

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

scripts/detect.sh

Shell · 5,435 bytes
#!/usr/bin/env bash
#
# detect.sh — Java4Shell (CVE-2026-114938) exposure check
#
# Defensive-only: checks local CPU capability and installed JDK version(s)
# to estimate whether this host sits in the vulnerable configuration window.
# Does NOT decode anything, does NOT touch the network, does NOT require root.
#
# Exit codes:
#   0 = not affected (hardware or patched)
#   1 = affected (vulnerable hardware + vulnerable/unknown JDK version)
#   2 = unknown / could not determine

set -uo pipefail

bold() { printf '\033[1m%s\033[0m\n' "$1"; }
green() { printf '\033[32m%s\033[0m\n' "$1"; }
yellow() { printf '\033[33m%s\033[0m\n' "$1"; }
red() { printf '\033[31m%s\033[0m\n' "$1"; }

bold "Java4Shell (CVE-2026-114938) exposure check"
echo "-----------------------------------------------"

# ---------------------------------------------------------------------------
# 1. CPU capability check — only x86-64 with AVX-512 VBMI is affected
# ---------------------------------------------------------------------------
cpu_vulnerable="unknown"
arch="$(uname -m 2>/dev/null || echo unknown)"

if [[ "$arch" == arm64 || "$arch" == aarch64 ]]; then
    cpu_vulnerable="no"
    echo "Architecture: $arch -> ARM64 is not affected regardless of JDK version."
elif [[ "$arch" == x86_64 || "$arch" == amd64 ]]; then
    if [[ -r /proc/cpuinfo ]]; then
        if grep -qi 'avx512vbmi' /proc/cpuinfo; then
            cpu_vulnerable="yes"
        else
            cpu_vulnerable="no"
        fi
    elif command -v lscpu >/dev/null 2>&1; then
        if lscpu | grep -qi 'avx512vbmi'; then
            cpu_vulnerable="yes"
        else
            cpu_vulnerable="no"
        fi
    elif command -v sysctl >/dev/null 2>&1; then
        # macOS on Apple Silicon won't hit this branch (arm64 above); this
        # covers x86-64 Macs. Apple's sysctl naming differs from Linux flags,
        # so treat as unknown if we can't confirm either way.
        if sysctl -a 2>/dev/null | grep -qi 'avx512vbmi'; then
            cpu_vulnerable="yes"
        fi
    fi
    echo "Architecture: $arch (AVX-512 VBMI capable: $cpu_vulnerable)"
else
    echo "Architecture: $arch -> could not classify."
fi

# ---------------------------------------------------------------------------
# 2. JDK version check
# ---------------------------------------------------------------------------
jdk_status="unknown"
jdk_version_string=""

if command -v java >/dev/null 2>&1; then
    # Filter out noise like "Picked up JAVA_TOOL_OPTIONS: ..." so we grab the
    # actual "openjdk version "x.y.z"" line regardless of env var chatter.
    jdk_version_string="$(java -version 2>&1 | grep -iE 'version' | head -n 1)"
    if [[ -z "$jdk_version_string" ]]; then
        jdk_version_string="$(java -version 2>&1 | head -n 1)"
    fi
    echo "Found: $jdk_version_string"

    # Extract a version like 17.0.6, 21.0.1, 25, 27.0.1 etc.
    ver="$(echo "$jdk_version_string" | grep -oE '"[0-9]+(\.[0-9]+)*' | tr -d '"')"
    major="${ver%%.*}"
    minor="$(echo "$ver" | awk -F. '{print $2+0}')"
    patch="$(echo "$ver" | awk -F. '{print $3+0}')"

    if [[ -z "$major" ]]; then
        jdk_status="unknown"
    elif (( major == 17 )); then
        if (( minor > 0 )) || (( minor == 0 && patch >= 6 )); then
            jdk_status="affected_unless_patched"
        else
            jdk_status="not_affected"
        fi
    elif (( major == 21 || major == 25 || major == 27 )); then
        jdk_status="affected_unless_patched"
    elif (( major > 27 )); then
        # Assume post-fix baseline ships patched; verify against your vendor's advisory.
        jdk_status="likely_patched_verify"
    else
        jdk_status="not_affected"
    fi
else
    echo "No 'java' binary found on PATH."
fi

echo "-----------------------------------------------"

# ---------------------------------------------------------------------------
# 3. Verdict
# ---------------------------------------------------------------------------
if [[ "$cpu_vulnerable" == "no" ]]; then
    green "VERDICT: NOT AFFECTED — this CPU does not run the vulnerable AVX-512 VBMI decode path."
    exit 0
fi

case "$jdk_status" in
    not_affected)
        green "VERDICT: NOT AFFECTED — JDK version predates the vulnerable Base64 intrinsic."
        exit 0
        ;;
    affected_unless_patched)
        if [[ "$cpu_vulnerable" == "yes" ]]; then
            red "VERDICT: POTENTIALLY AFFECTED — vulnerable hardware + an unpatched-looking JDK version."
            echo "  Action: confirm you're on your vendor's November 2026 (or later) security build,"
            echo "  or apply a mitigation flag — see scripts/mitigate.sh."
            exit 1
        else
            yellow "VERDICT: UNKNOWN — could not confirm AVX-512 VBMI support, but JDK version is in the affected range."
            echo "  Action: check CPU flags manually, or apply a mitigation flag as a precaution."
            exit 2
        fi
        ;;
    likely_patched_verify)
        yellow "VERDICT: LIKELY PATCHED — JDK major version is newer than the known-affected lines."
        echo "  Action: confirm against your vendor's advisory; version numbering varies by distribution."
        exit 2
        ;;
    *)
        yellow "VERDICT: UNKNOWN — could not determine JDK version precisely."
        echo "  Action: check 'java -version' output above against your vendor's advisory."
        exit 2
        ;;
esac