Exploit databaseDownload repository ZIP
GH-8f3f66aa36383c2a3a7f550ff9a824a1
googlesky/cve-2026-118383
Sources for CVE-2026-118383
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files12
googlesky/cve-2026-118383Revision 471804de2a27
- containers/
- evidence/
- exploit/
- tools/
- .gitignore
- CITATION.cff
- LICENSE
- README.md
- SECURITY.md
- mongo_wire.py
- poc.py
- run.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
run.sh
Shell · 8,969 bytes#!/usr/bin/env bash
# CVE-2026-118383 reproduction harness: three-node replica set + attacker client.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NET="${NET:-cve-2026-118383-net}"
PREFIX="${PREFIX:-cve118383}"
IMAGE="${MONGO_IMAGE:-docker.io/library/mongo:8.0.34}"
ATTACKER_IMAGE="${ATTACKER_IMAGE:-localhost/${PREFIX}-attacker:latest}"
CPUS="${CPUS:-2}"
N2_CPUS="${N2_CPUS:-$CPUS}"
MEM="${MEM:-2g}"
HB_MS="${HB_MS:-300}"
# AUTH=1 enables keyFile authentication on every node. This is required to
# observe SERVER-138119: with authorization disabled the ActionType::internal
# check is bypassed, so even fixed builds accept readConcern.afterOpTime.
AUTH="${AUTH:-0}"
KEYFILE_VOL="${PREFIX}-keyfile"
ADMIN_USER="${ADMIN_USER:-cveadmin}"
ADMIN_PASS="${ADMIN_PASS:-cvepass}"
log() { printf '\033[1;34m[cve]\033[0m %s\n' "$*"; }
die() { printf '\033[1;31m[cve]\033[0m %s\n' "$*" >&2; exit 1; }
port_for() { case "$1" in n1) echo 27017;; n2) echo 27018;; n3) echo 27019;; *) die "bad node $1";; esac; }
cname() { echo "${PREFIX}-$1"; }
ensure_network() {
podman network exists "$NET" 2>/dev/null || podman network create --subnet 10.113.83.0/24 "$NET" >/dev/null
}
keyfile_uid() {
# Resolve the uid mongod runs as for this image. mongo:8.0.34 uses the
# `mongodb` user (999), the official UBI9 images run as uid 1000.
podman run --rm --entrypoint /bin/sh "$IMAGE" \
-c 'id -u mongodb 2>/dev/null || id -u'
}
ensure_keyfile() {
local uid
uid="$(keyfile_uid)"
log "creating keyFile (owner uid $uid)"
podman volume rm -f "$KEYFILE_VOL" >/dev/null 2>&1 || true
podman volume create "$KEYFILE_VOL" >/dev/null
podman run --rm --user 0 --entrypoint /bin/sh -v "${KEYFILE_VOL}:/k" "$IMAGE" \
-c "openssl rand -base64 756 > /k/keyfile && chown ${uid}:${uid} /k/keyfile && chmod 400 /k/keyfile" \
>/dev/null
}
start_node() {
local short="$1" image="$2" port cpus="$CPUS"
port="$(port_for "$short")"
[ "$short" = "n2" ] && cpus="$N2_CPUS"
local -a envargs=() keymount=() keyopts=() extra=()
if [ "$short" = "n2" ] && [ -n "${N2_ENV:-}" ]; then
for kv in $N2_ENV; do envargs+=(-e "$kv"); done
fi
if [ -n "${EXTRA_ARGS:-}" ]; then
read -r -a extra <<< "$EXTRA_ARGS"
fi
if [ "$short" = "n2" ] && [ -n "${N2_EXTRA_ARGS:-}" ]; then
read -r -a n2extra <<< "$N2_EXTRA_ARGS"
extra+=("${n2extra[@]}")
fi
if [ "$AUTH" = "1" ]; then
keymount=(-v "${KEYFILE_VOL}:/keyfile:ro")
keyopts=(--keyFile /keyfile/keyfile)
fi
podman rm -f "$(cname "$short")" >/dev/null 2>&1 || true
if [ -n "${envargs[*]:-}" ]; then
log "starting $short ($image) with ${N2_ENV}"
else
log "starting $short ($image)"
fi
podman run -d --name "$(cname "$short")" --hostname "$short" \
--network "$NET" --network-alias "$short" \
--cpus "$cpus" --memory "$MEM" --memory-swap "$MEM" \
"${envargs[@]}" \
-v "${PREFIX}-${short}-db:/data/db" \
"${keymount[@]}" \
"$image" mongod --replSet rs0 --bind_ip_all --port "$port" \
"${keyopts[@]}" \
"${extra[@]}" \
--setParameter enableTestCommands=1 \
--wiredTigerCacheSizeGB 0.25 \
>/dev/null
}
wait_port() {
local short="$1" port
port="$(port_for "$short")"
for _ in $(seq 1 120); do
if podman exec "$(cname "$short")" mongosh --quiet --port "$port" --eval 'db.runCommand({ping:1}).ok' 2>/dev/null | grep -q 1; then
return 0
fi
sleep 0.5
done
podman logs --tail 50 "$(cname "$short")" || true
die "$short did not become ready"
}
init_replset() {
log "initiating replica set (heartbeat ${HB_MS}ms, catchUpTimeout 120s, auth=${AUTH})"
podman exec "$(cname n1)" mongosh --quiet --port 27017 --eval "
rs.initiate({
_id: 'rs0',
members: [
{_id: 0, host: 'n1:27017', priority: 5},
{_id: 1, host: 'n2:27018', priority: 1},
{_id: 2, host: 'n3:27019', priority: 1}
],
settings: {
heartbeatIntervalMillis: ${HB_MS},
electionTimeoutMillis: 10000,
catchUpTimeoutMillis: 120000
}
});
" >/dev/null
# Find the first elected primary (n1 with priority 5 in the normal case).
local primary=""
for _ in $(seq 1 120); do
for n in n1 n2 n3; do
state=$(podman exec "$(cname "$n")" mongosh --quiet --port "$(port_for "$n")" \
--eval 'db.hello().isWritablePrimary' 2>/dev/null || true)
if [ "$state" = "true" ]; then primary="$n"; break 2; fi
done
sleep 0.5
done
[ -n "$primary" ] || die "replica set did not elect a primary"
# With a keyFile, auth is enabled from the first start. The localhost
# exception is active until the first user exists, so create it now on the
# primary. Subsequent admin commands use these credentials.
if [ "$AUTH" = "1" ]; then
log "creating admin user via localhost exception on $primary"
podman exec "$(cname "$primary")" mongosh --quiet --port "$(port_for "$primary")" --eval "
db.getSiblingDB('admin').runCommand({
createUser: '${ADMIN_USER}', pwd: '${ADMIN_PASS}', roles: ['root'],
writeConcern: {w: 'majority', wtimeout: 15000}
});
" >/dev/null
for _ in $(seq 1 60); do
if podman exec "$(cname "$primary")" mongosh --quiet --port "$(port_for "$primary")" \
-u "$ADMIN_USER" -p "$ADMIN_PASS" --authenticationDatabase admin \
--eval 'db.runCommand({ping:1}).ok' 2>/dev/null | grep -q 1; then
break
fi
sleep 0.5
done
fi
if [ "$primary" = "n1" ]; then
log "n1 is primary"
return 0
fi
log "current primary is $primary; forcing n1 to step up"
local -a authargs=()
if [ "$AUTH" = "1" ]; then
authargs=(-u "$ADMIN_USER" -p "$ADMIN_PASS" --authenticationDatabase admin)
fi
for _ in $(seq 1 40); do
podman exec "$(cname n1)" mongosh --quiet --port 27017 "${authargs[@]}" \
--eval 'db.adminCommand({replSetStepUp: 1, maxTimeMS: 10000})' >/dev/null 2>&1 || true
state=$(podman exec "$(cname n1)" mongosh --quiet --port 27017 \
--eval 'db.hello().isWritablePrimary' 2>/dev/null || true)
if [ "$state" = "true" ]; then
log "n1 is primary"
return 0
fi
sleep 0.5
done
die "replica set did not elect n1 as primary"
}
build_attacker() {
# Always rebuild: the image is just the PoC sources and stale copies hide fixes.
log "building attacker image"
podman build -q -t "$ATTACKER_IMAGE" -f "$ROOT/containers/Attacker.containerfile" "$ROOT" >/dev/null
}
up() {
ensure_network
if [ "$AUTH" = "1" ]; then ensure_keyfile; fi
start_node n1 "$IMAGE"
start_node n2 "$IMAGE"
start_node n3 "$IMAGE"
wait_port n1
wait_port n2
wait_port n3
init_replset
build_attacker
log "environment is up"
}
down() {
for n in n1 n2 n3; do
podman rm -f "$(cname "$n")" >/dev/null 2>&1 || true
podman volume rm -f "${PREFIX}-${n}-db" >/dev/null 2>&1 || true
done
podman volume rm -f "$KEYFILE_VOL" >/dev/null 2>&1 || true
podman network rm "$NET" >/dev/null 2>&1 || true
log "environment torn down (volumes removed)"
}
status() {
podman ps -a --filter "name=${PREFIX}-" --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'
for n in n1 n2 n3; do
printf '%s: ' "$(cname "$n")"
podman exec "$(cname "$n")" mongosh --quiet --port "$(port_for "$n")" \
--eval 'const h=db.hello(); print(JSON.stringify({primary:h.isWritablePrimary, secondary:h.secondary, lastWrite:h.lastWrite}))' 2>/dev/null || echo down
done
}
capture_evidence() {
mkdir -p "$ROOT/results"
: > "$ROOT/results/container-states.txt"
for n in n1 n2 n3; do
podman logs "$(cname "$n")" > "$ROOT/results/logs-$n.txt" 2>&1 || true
podman inspect -f '{{.Name}} {{.State.Status}} exit={{.State.ExitCode}} started={{.State.StartedAt}} finished={{.State.FinishedAt}}' \
"$(cname "$n")" >> "$ROOT/results/container-states.txt" 2>/dev/null || true
done
}
run_poc() {
local mode="${1:-assisted}"
shift || true
if [ "$AUTH" = "1" ] && [ "$mode" != "control" ]; then
die "AUTH=1 supports only 'control'; assisted/natural need auth disabled (test commands are not available to unauthenticated clients)"
fi
build_attacker
mkdir -p "$ROOT/results"
log "running PoC (mode=$mode)"
set +e
podman run --rm --name "${PREFIX}-attacker" --network "$NET" \
--cpus "$CPUS" --memory "$MEM" \
-v "$ROOT/results:/results:Z" \
-e MONGO_HOSTS="n1:27017,n2:27018,n3:27019" \
"$ATTACKER_IMAGE" /poc/poc.py --mode "$mode" --results /results "$@"
local rc=$?
set -e
capture_evidence
return $rc
}
case "${1:-}" in
up) up ;;
down) down ;;
status) status ;;
assisted|natural|control)
mode="$1"; shift
down; up
rc=0; run_poc "$mode" "$@" || rc=$?
down; exit "$rc" ;;
run) shift; down; up; rc=0; run_poc "$@" || rc=$?; down; exit "$rc" ;;
poc) shift; run_poc "$@" ;;
restart) down; up ;;
*) echo "usage: $0 {up|down|status|assisted|natural|control|poc <mode>|run <mode>}" >&2; exit 2 ;;
esac