Exploit databaseDownload repository ZIP
GH-3dcf0a0374ab785cf6ccafdeab913ec5
joedayz/cve-2026-114820-java-scan
Sources for CVE-2026-114820
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files1
joedayz/cve-2026-114820-java-scanRevision 328fd7fee0e2
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scripts/scan-java-trust.sh
Shell · 16,609 bytes#!/bin/bash
# Inventario de solo lectura para CVE-2026-114820.
# Busca en el truststore efectivo las raíces que Oracle retiró:
# emSign Root CA - G1, emSign Root CA - G2, emSign ECC Root CA - G3,
# AAA Certificate Services.
# No borra certificados, no reinicia procesos y no guarda la línea de comandos.
set -u
shopt -s nullglob
SCAN_HOST="${SCAN_HOST:-}"
if [[ -z "$SCAN_HOST" ]]; then
SCAN_HOST="$(hostname 2>/dev/null || uname -n)"
fi
TMP="$(mktemp -d "${TMPDIR:-/tmp}/java-trust-scan.XXXXXX")"
EMITTED=0
cleanup() {
rm -rf "$TMP"
}
trap cleanup EXIT
json_escape() {
local s=$1
s=${s//\\/\\\\}
s=${s//\"/\\\"}
s=${s//$'\b'/\\b}
s=${s//$'\f'/\\f}
s=${s//$'\n'/\\n}
s=${s//$'\r'/\\r}
s=${s//$'\t'/\\t}
printf '%s' "$s"
}
json_string() {
printf '"%s"' "$(json_escape "$1")"
}
resolve_path() {
local target=$1
if command -v readlink >/dev/null 2>&1 && readlink -f "$target" >/dev/null 2>&1; then
readlink -f "$target"
return
fi
(
cd "$(dirname "$target")" 2>/dev/null || exit 1
printf '%s/%s\n' "$(pwd)" "$(basename "$target")"
)
}
run_timeout() {
local secs=$1
shift
if command -v timeout >/dev/null 2>&1; then
timeout "$secs" "$@"
else
"$@"
fi
}
priority_for() {
local blob
blob="$(printf '%s %s' "$1" "$2" | tr '[:upper:]' '[:lower:]')"
case "$blob" in
*"emsign ecc root ca - g3"*|*"emsigneccrootcag3"*|*"emsign_ecc_root_ca_-_g3"*|*"aaa certificate services"*|*"comodoaaaca"*|*"aaa_certificate_services"*)
printf 'P1'
;;
*)
printf 'P2'
;;
esac
}
is_target() {
local alias_l owner_l
alias_l="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')"
owner_l="$(printf '%s' "$2" | tr '[:upper:]' '[:lower:]')"
case "$owner_l" in
*"cn=emsign root ca - g1"*|*"cn=emsign root ca - g2"*|*"cn=emsign ecc root ca - g3"*|*"cn=aaa certificate services"*)
return 0
;;
esac
case "$alias_l" in
*emsignrootcag1*|*emsignrootcag2*|*emsigneccrootcag3*|*comodoaaaca*)
return 0
;;
*emsign_root_ca_-_g1*|*emsign_root_ca_-_g2*|*emsign_ecc_root_ca_-_g3*|*aaa_certificate_services*)
return 0
;;
esac
return 1
}
add_line() {
local file=$1
local value=$2
[[ -n "$value" ]] || return 0
mkdir -p "$(dirname "$file")"
if [[ -f "$file" ]] && grep -Fxq -- "$value" "$file"; then
return 0
fi
printf '%s\n' "$value" >> "$file"
}
add_java() {
local bin=$1
[[ -n "$bin" && -x "$bin" ]] || return 0
[[ "$(basename "$bin")" == "java" ]] || return 0
[[ "$(basename "$(dirname "$bin")")" == "bin" ]] || return 0
local resolved
resolved="$(resolve_path "$bin" 2>/dev/null || printf '%s' "$bin")"
add_line "$TMP/javas" "$resolved"
}
add_store() {
local store=$1
local source=$2
[[ -n "$store" && -f "$store" ]] || return 0
local resolved
resolved="$(resolve_path "$store" 2>/dev/null || printf '%s' "$store")"
add_line "$TMP/stores" "${resolved}"$'\t'"${source}"
}
discover_filesystem() {
local root
local roots=()
if [[ -n "${SCAN_ROOTS:-}" ]]; then
local old_ifs=$IFS
IFS=':'
set -f
# shellcheck disable=SC2086
set -- ${SCAN_ROOTS}
set +f
IFS=$old_ifs
roots=("$@")
else
roots=(
/usr/lib/jvm
/usr/java
/usr/local
/opt
/etc/ssl/certs/java
/etc/pki/java
/etc/pki/ca-trust/extracted/java
)
local home_root
for home_root in "$HOME/.sdkman/candidates/java" /root/.sdkman/candidates/java /home/*/.sdkman/candidates/java; do
[[ -d "$home_root" ]] && roots+=("$home_root")
done
if command -v java >/dev/null 2>&1; then
add_java "$(command -v java)"
fi
if [[ -n "${JAVA_HOME:-}" && -x "${JAVA_HOME}/bin/java" ]]; then
add_java "${JAVA_HOME}/bin/java"
fi
fi
local path
for root in "${roots[@]}"; do
[[ -d "$root" ]] || continue
while IFS= read -r path; do
case "$(basename "$path")" in
java)
add_java "$path"
;;
cacerts|jssecacerts)
add_store "$path" "filesystem"
;;
esac
done < <(find "$root" -maxdepth 8 \
\( -name proc -o -name sys -o -name dev -o -name node_modules -o -name containerd -o -name overlay2 -o -name pods -o -name volumes \) -prune -o \
\( -name java -o -name cacerts -o -name jssecacerts \) -print 2>/dev/null)
done
}
discover_processes() {
[[ -d /proc ]] || return 0
local comm_path pid comm exe user trust arg host_exe host_trust
for comm_path in /proc/[0-9]*/comm; do
[[ -r "$comm_path" ]] || continue
comm="$(cat "$comm_path" 2>/dev/null || true)"
[[ "$comm" == "java" ]] || continue
pid="${comm_path#/proc/}"
pid="${pid%/comm}"
exe="$(readlink "/proc/$pid/exe" 2>/dev/null || true)"
user="$(awk '/^Uid:/ {print $2; exit}' "/proc/$pid/status" 2>/dev/null || true)"
if [[ -n "$user" ]] && command -v getent >/dev/null 2>&1; then
local name
name="$(getent passwd "$user" 2>/dev/null | cut -d: -f1)"
[[ -n "$name" ]] && user="$name"
fi
trust=""
while IFS= read -r -d '' arg || [[ -n "${arg:-}" ]]; do
case "$arg" in
-Djavax.net.ssl.trustStore=*)
trust="${arg#-Djavax.net.ssl.trustStore=}"
;;
esac
done < "/proc/$pid/cmdline" || true
host_exe=""
if [[ -n "$exe" && -x "$exe" ]]; then
host_exe="$(resolve_path "$exe")"
elif [[ -n "$exe" && -x "/proc/$pid/root$exe" ]]; then
host_exe="$(resolve_path "/proc/$pid/root$exe")"
fi
[[ -n "$host_exe" ]] && add_java "$host_exe"
host_trust=""
if [[ -n "$trust" && -e "$trust" ]]; then
host_trust="$(resolve_path "$trust")"
elif [[ -n "$trust" && -e "/proc/$pid/root$trust" ]]; then
host_trust="$(resolve_path "/proc/$pid/root$trust")"
fi
if [[ -n "$host_trust" ]]; then
add_store "$host_trust" "process"
fi
printf '%s\t%s\t%s\t%s\n' "$pid" "${user:-unknown}" "${host_exe:-$exe}" "${host_trust}" >> "$TMP/procs"
done
}
java_props() {
local bin=$1
LANG=C run_timeout 20 "$bin" -XshowSettings:properties -version 2>&1 || true
}
prop_value() {
local key=$1
sed -n "s/^[[:space:]]*${key} = //p" | head -n 1
}
stores_for_home() {
local home=$1
local rel
for rel in lib/security/cacerts jre/lib/security/cacerts lib/security/jssecacerts jre/lib/security/jssecacerts; do
if [[ -e "$home/$rel" ]]; then
add_store "$home/$rel" "jdk"
fi
done
}
keytool_for() {
local store=$1
local hint_bin=${2:-}
if [[ -n "$hint_bin" ]]; then
local sibling
sibling="$(dirname "$hint_bin")/keytool"
if [[ -x "$sibling" ]]; then
printf '%s\n' "$sibling"
return
fi
fi
local dir=$store
local i
for i in 1 2 3 4 5 6; do
dir="$(dirname "$dir")"
if [[ -x "$dir/bin/keytool" ]]; then
printf '%s\n' "$dir/bin/keytool"
return
fi
if [[ -x "$dir/keytool" ]]; then
printf '%s\n' "$dir/keytool"
return
fi
done
if command -v keytool >/dev/null 2>&1; then
command -v keytool
return
fi
printf '\n'
}
store_in_use() {
local store=$1
local home=$2
[[ -f "$TMP/procs" ]] || return 1
local pid user exe trust
while IFS="$(printf '\t')" read -r pid user exe trust; do
if [[ -n "$trust" && "$trust" == "$store" ]]; then
return 0
fi
if [[ -z "$trust" && -n "$home" && -n "$exe" ]]; then
case "$exe" in
"$home"/bin/java|"$home"/jre/bin/java)
[[ "$(effective_default "$store")" == "true" ]] && return 0
;;
esac
fi
done < "$TMP/procs"
return 1
}
scan_store() {
local store=$1
local keytool_bin=$2
local out="$TMP/keytool.out"
local err="$TMP/keytool.err"
: > "$TMP/matches.tsv"
local status="ok"
local error=""
if [[ ! -r "$store" ]]; then
status="unreadable"
error="sin permiso de lectura"
elif [[ -z "$keytool_bin" || ! -x "$keytool_bin" ]]; then
status="keytool_missing"
error="no hay keytool ejecutable para este almacén"
else
if ! LANG=C run_timeout 60 "$keytool_bin" -list -keystore "$store" -storepass changeit -noprompt -v >"$out" 2>"$err"; then
if grep -qi 'password was incorrect' "$err"; then
status="password_rejected"
error="la contraseña por defecto del cacerts fue rechazada"
else
status="error"
error="$(head -n 1 "$err" | tr -d '\r')"
[[ -n "$error" ]] || error="keytool terminó con error"
fi
fi
fi
if [[ "$status" == "ok" ]]; then
local alias="" line
while IFS= read -r line || [[ -n "$line" ]]; do
line="${line%$'\r'}"
case "$line" in
"Alias name:"*)
alias="${line#Alias name: }"
alias="${alias#"${alias%%[![:space:]]*}"}"
;;
"Owner:"*)
local owner="${line#Owner: }"
owner="${owner#"${owner%%[![:space:]]*}"}"
if is_target "$alias" "$owner"; then
printf '%s\t%s\t%s\n' "$alias" "$owner" "$(priority_for "$alias" "$owner")" >> "$TMP/matches.tsv"
fi
;;
esac
done < "$out"
fi
local match_count=0
if [[ -s "$TMP/matches.tsv" ]]; then
match_count="$(wc -l < "$TMP/matches.tsv" | tr -d ' ')"
fi
printf '%s\n' "$status"
printf '%s\n' "$error"
printf '%s\n' "$match_count"
}
effective_default() {
local store=$1
local base
base="$(basename "$store")"
local dir
dir="$(dirname "$store")"
if [[ "$base" == "cacerts" && -e "$dir/jssecacerts" ]]; then
printf 'false'
else
printf 'true'
fi
}
join_objects() {
local file=$1
local first=1
local line
printf '['
if [[ -f "$file" ]]; then
while IFS= read -r line; do
[[ -n "$line" ]] || continue
if [[ $first -eq 1 ]]; then
first=0
else
printf ','
fi
printf '%s' "$line"
done < "$file"
fi
printf ']'
}
matches_to_json() {
local file=$1
local first=1
local alias owner priority
printf '['
if [[ -f "$file" ]]; then
while IFS="$(printf '\t')" read -r alias owner priority; do
[[ -n "$alias" ]] || continue
if [[ $first -eq 1 ]]; then
first=0
else
printf ','
fi
printf '{"alias":%s,"owner":%s,"priority":%s}' \
"$(json_string "$alias")" \
"$(json_string "$owner")" \
"$(json_string "$priority")"
done < "$file"
fi
printf ']'
}
runtime_for_store() {
local store=$1
local best="" best_len=0 home bin version vendor len
[[ -f "$TMP/homes" ]] || return 0
while IFS="$(printf '\t')" read -r home bin version vendor; do
case "$store" in
"$home"/*)
len=${#home}
if [[ "$len" -gt "$best_len" ]]; then
best_len=$len
best=$(printf '%s\t%s\t%s\t%s' "$home" "$bin" "$version" "$vendor")
fi
;;
esac
done < "$TMP/homes"
printf '%s\n' "$best"
}
emit_report() {
[[ "$EMITTED" -eq 0 ]] || return 0
EMITTED=1
local scanned_at
scanned_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
printf '{'
printf '"host":%s,' "$(json_string "$SCAN_HOST")"
printf '"scanned_at":%s,' "$(json_string "$scanned_at")"
printf '"cve":"CVE-2026-114820",'
printf '"read_only":true,'
printf '"runtimes":'
join_objects "$TMP/runtimes.jsonl"
printf ','
printf '"findings":'
join_objects "$TMP/findings.jsonl"
printf ','
printf '"unchecked":'
join_objects "$TMP/unchecked.jsonl"
printf ','
printf '"finding_count":%s,' "${FINDING_COUNT:-0}"
printf '"unchecked_count":%s' "${UNCHECKED_COUNT:-0}"
printf '}\n'
printf 'scan-java-trust: host=%s findings=%s unchecked=%s\n' \
"$SCAN_HOST" "${FINDING_COUNT:-0}" "${UNCHECKED_COUNT:-0}" >&2
}
discover_filesystem
discover_processes
# Cada binario Java aporta su java.home y sus almacenes.
if [[ -f "$TMP/javas" ]]; then
local_java=""
while IFS= read -r local_java; do
props="$(java_props "$local_java")"
home="$(printf '%s\n' "$props" | prop_value 'java.home')"
version="$(printf '%s\n' "$props" | prop_value 'java.version')"
vendor="$(printf '%s\n' "$props" | prop_value 'java.vendor')"
if [[ -z "$home" || ! -d "$home" ]]; then
if [[ "$local_java" == /proc/*/root/* ]]; then
root_prefix="${local_java%/root/*}/root"
if [[ -n "$home" && -d "${root_prefix}${home}" ]]; then
home="${root_prefix}${home}"
fi
fi
fi
if [[ -z "$home" || ! -d "$home" ]]; then
home="$(dirname "$(dirname "$local_java")")"
version="${version:-unknown}"
vendor="${vendor:-unknown}"
fi
printf '%s\t%s\t%s\t%s\n' "$home" "$local_java" "$version" "$vendor" >> "$TMP/homes"
if [[ ! -f "$TMP/seen-homes" ]] || ! grep -Fxq -- "$home" "$TMP/seen-homes"; then
printf '%s\n' "$home" >> "$TMP/seen-homes"
stores_for_home "$home"
fi
done < "$TMP/javas"
fi
: > "$TMP/runtimes.jsonl"
: > "$TMP/findings.jsonl"
: > "$TMP/unchecked.jsonl"
FINDING_COUNT=0
UNCHECKED_COUNT=0
# Un path, una vez. Si aparece por el proceso y por el JDK, se queda el origen "process".
if [[ -f "$TMP/stores" ]]; then
awk -F '\t' '
{
path = $1
source = $2
rank = 1
if (source == "jdk") rank = 2
if (source == "process") rank = 3
if (!(path in score) || rank > score[path]) {
best[path] = source
score[path] = rank
}
}
END {
for (path in best) print path "\t" best[path]
}
' "$TMP/stores" | sort > "$TMP/stores.uniq"
else
: > "$TMP/stores.uniq"
fi
mkdir -p "$TMP/groups"
while IFS="$(printf '\t')" read -r store source; do
[[ -n "$store" ]] || continue
meta="$(runtime_for_store "$store")"
if [[ -z "$meta" ]]; then
meta=$(printf '%s\t%s\t%s\t%s' "$(dirname "$(dirname "$(dirname "$store")")")" "" "unknown" "truststore externo")
fi
gid="$(printf '%s' "$meta" | cksum | awk '{print $1}')"
printf '%s\n' "$meta" > "$TMP/groups/$gid.meta"
printf '%s\t%s\n' "$store" "$source" >> "$TMP/groups/$gid.stores"
done < "$TMP/stores.uniq"
for meta_file in "$TMP/groups"/*.meta; do
[[ -f "$meta_file" ]] || continue
gid="$(basename "$meta_file" .meta)"
IFS="$(printf '\t')" read -r home bin version vendor < "$meta_file"
: > "$TMP/current-stores.jsonl"
while IFS="$(printf '\t')" read -r store source; do
[[ -n "$store" ]] || continue
kt="$(keytool_for "$store" "$bin")"
scan_result="$(scan_store "$store" "$kt")"
cp "$TMP/matches.tsv" "$TMP/matches.current"
status="$(printf '%s\n' "$scan_result" | sed -n '1p')"
error="$(printf '%s\n' "$scan_result" | sed -n '2p')"
match_count="$(printf '%s\n' "$scan_result" | sed -n '3p')"
effective="$(effective_default "$store")"
in_use="false"
if store_in_use "$store" "$home"; then
in_use="true"
fi
printf '{"path":%s,"source":%s,"status":%s,"error":%s,"effective_default":%s,"in_use":%s,"matches":' \
"$(json_string "$store")" \
"$(json_string "$source")" \
"$(json_string "$status")" \
"$(json_string "$error")" \
"$effective" \
"$in_use" >> "$TMP/current-stores.jsonl"
matches_to_json "$TMP/matches.current" >> "$TMP/current-stores.jsonl"
printf '}\n' >> "$TMP/current-stores.jsonl"
if [[ "$status" != "ok" ]]; then
printf '{"path":%s,"status":%s,"error":%s}\n' \
"$(json_string "$store")" \
"$(json_string "$status")" \
"$(json_string "$error")" >> "$TMP/unchecked.jsonl"
UNCHECKED_COUNT=$((UNCHECKED_COUNT + 1))
fi
if [[ "${match_count:-0}" -gt 0 && ( "$effective" == "true" || "$in_use" == "true" ) ]]; then
while IFS="$(printf '\t')" read -r alias owner priority; do
[[ -n "$alias" ]] || continue
printf '{"java_home":%s,"version":%s,"vendor":%s,"truststore":%s,"alias":%s,"owner":%s,"priority":%s,"in_use":%s,"effective_default":%s}\n' \
"$(json_string "$home")" \
"$(json_string "$version")" \
"$(json_string "$vendor")" \
"$(json_string "$store")" \
"$(json_string "$alias")" \
"$(json_string "$owner")" \
"$(json_string "$priority")" \
"$in_use" \
"$effective" >> "$TMP/findings.jsonl"
FINDING_COUNT=$((FINDING_COUNT + 1))
done < "$TMP/matches.current"
fi
done < "$TMP/groups/$gid.stores"
printf '{"java_home":%s,"java_bin":%s,"version":%s,"vendor":%s,"truststores":' \
"$(json_string "$home")" \
"$(json_string "$bin")" \
"$(json_string "$version")" \
"$(json_string "$vendor")" >> "$TMP/runtimes.jsonl"
join_objects "$TMP/current-stores.jsonl" >> "$TMP/runtimes.jsonl"
printf '}\n' >> "$TMP/runtimes.jsonl"
done
emit_report