Exploit database

GH-95141bda52efa1fd3be09d9993f29779

theori-io/java4shell-runtime-patch-cve-2026-114938

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 files9

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

apply.sh

Suggested starting fileShell · 5,335 bytes
#!/bin/bash
# Apply CVE-2026-114938.jar to running JVMs on this host / in this container.
#   ./apply.sh                    all JVMs found
#   ./apply.sh 1234 5678          only these PIDs
#   ./apply.sh --dry-run [PID..]  report only, change nothing
#   ./apply.sh --force   [PID..]  apply even if a JVM looks "not exposed"
#   ./apply.sh --yes     [PID..]  do not ask for confirmation (automation)
# Needs: jcmd (JDK) on PATH. Run as root, or as the same user as the target JVMs.
# Works for JVMs in other containers too when run as root on the host (jar is copied via /proc/PID/root/tmp).
set -u
JAR="$(cd "$(dirname "$0")" && pwd)/CVE-2026-114938.jar"
MODE=""; PIDS=(); YES=0
for a in "$@"; do
  case "$a" in
    --dry-run) MODE="dry-run" ;;
    --force)   MODE="force" ;;
    -y|--yes)  YES=1 ;;
    ''|*[!0-9]*) echo "usage: $0 [--dry-run|--force] [--yes] [PID ...]"; exit 2 ;;
    *) PIDS+=("$a") ;;
  esac
done
cat <<'BANNER'
==============================================================================
  CVE-2026-114938 Runtime Patch
  OpenJDK x86_64 AVX-512 Base64 decode intrinsic - heap out-of-bounds write
  Patch Provided by Xint
==============================================================================
 CAUTION
  * Attaches a Java agent to running JVM(s) and changes JIT compilation in
    memory. No JVM memory is written directly; only supported interfaces
    (compiler directives + class retransformation) are used.
  * All JIT-compiled code is deoptimized once. Expect a short CPU spike and
    higher latency while the JIT re-warms. Apply during low traffic.
  * Not persistent: after a restart the JVM is vulnerable again unless
    -XX:-UseBASE64Intrinsics is in its startup options.
  * JVMs that are not exposed (JDK < 17.0.6, non-x86, no AVX-512 VBMI,
    intrinsic already disabled) are left untouched.
  * Provided as is. Validate on a staging JVM with the same JDK build first.
==============================================================================
BANNER
command -v jcmd >/dev/null || { echo "jcmd not found: run where a JDK is installed"; exit 1; }
[ -f "$JAR" ] || { echo "missing $JAR"; exit 1; }

if [ ${#PIDS[@]} -eq 0 ]; then   # every process whose executable is a java launcher (excluding jcmd itself)
  for p in /proc/[0-9]*; do
    p=${p#/proc/}
    # argv[0] from cmdline (world-readable; /proc/PID/exe needs ptrace rights for other users)
    a0=$(tr '\0' '\n' < "/proc/$p/cmdline" 2>/dev/null | head -1)
    case "$a0" in java|*/java) ;; *) continue ;; esac
    tr '\0' ' ' < "/proc/$p/cmdline" 2>/dev/null | grep -q 'sun.tools.jcmd' && continue
    PIDS+=("$p")
  done
fi
[ ${#PIDS[@]} -eq 0 ] && { echo "no JVM found"; exit 0; }

echo "Target JVM(s):"
for pid in "${PIDS[@]}"; do echo "  PID $pid  $(tr '\0' ' ' < /proc/$pid/cmdline 2>/dev/null | cut -c1-100)"; done
if [ "$MODE" != "dry-run" ] && [ "$YES" != 1 ]; then
  printf "Apply the runtime patch to %d JVM(s)? Type 'yes' to continue: " "${#PIDS[@]}"
  read -r ans || ans=""
  [ "$ans" = "yes" ] || { echo; echo "Aborted. Nothing was changed. (use --yes for non-interactive runs)"; exit 1; }
fi
echo

rc=0
for pid in "${PIDS[@]}"; do
  [ -d "/proc/$pid" ] || { echo "== $pid: no such process"; rc=1; continue; }
  uid=$(stat -c %u "/proc/$pid"); nspid=$(awk '/^NSpid:/{print $NF}' "/proc/$pid/status")
  echo "== PID $pid (uid $uid) $(tr '\0' ' ' < /proc/$pid/cmdline | cut -c1-110)"
  # Put the jar where the target JVM can read it.
  #  - same mount namespace (e.g. kubectl exec into the app container): write to /tmp (or /dev/shm, /var/tmp)
  #    directly; no /proc/PID/root access needed (root in a container usually lacks CAP_SYS_PTRACE).
  #  - other namespace (run on the host for a containerized JVM): write through /proc/PID/root/<dir>.
  mine=$(readlink /proc/self/ns/mnt); theirs=$(readlink "/proc/$pid/ns/mnt" 2>/dev/null)
  prefix=""; [ -n "$theirs" ] && [ "$theirs" != "$mine" ] && prefix="/proc/$pid/root"
  tjar=""; errs=""
  for d in /tmp /dev/shm /var/tmp; do
    if e=$(cp "$JAR" "$prefix$d/CVE-2026-114938.jar" 2>&1); then chmod 644 "$prefix$d/CVE-2026-114938.jar"; tjar="$d/CVE-2026-114938.jar"; break
    else errs="$errs; $e"; fi
  done
  if [ -z "$tjar" ]; then
    echo "   cannot place jar where PID $pid can read it${prefix:+ (via $prefix)}${errs}"
    [ -z "$theirs" ] && echo "   (cannot inspect /proc/$pid: different user and no CAP_SYS_PTRACE? run inside the target container or as host root)"
    rc=1; continue
  fi
  tdir="$prefix$(dirname "$tjar")"; rm -f "$tdir/CVE-2026-114938-$nspid.log"
  SUDO=""; if [ "$(id -u)" != 0 ] && [ "$(id -u)" != "$uid" ]; then
    command -v sudo >/dev/null && SUDO="sudo -n -u #$uid" || { echo "   not root and not the JVM owner (uid $uid)"; rc=1; continue; }
  fi
  out=$($SUDO jcmd "$pid" JVMTI.agent_load "$tjar" $MODE 2>&1)
  if ! echo "$out" | grep -q 'return code: 0'; then echo "   jcmd failed: $(echo "$out" | tr '\n' ' ' | cut -c1-300)"; rc=1; continue; fi
  if [ -f "$tdir/CVE-2026-114938-$nspid.log" ]; then sed 's/^/   /' "$tdir/CVE-2026-114938-$nspid.log"
  else echo "   (agent output is in the target JVM's stderr)"; fi
  if $SUDO jcmd "$pid" Compiler.directives_print 2>/dev/null | grep -q 'Base64\$Decoder.decode0'; then
    echo "   STATUS: patched (directive present)"
  else
    echo "   STATUS: not patched"
  fi
done
exit $rc