Exploit database

GH-7305bbcdbf17252673788d6a2b2328c0

fortbridge/cve-2026-111497-wordpress-pingback-brotli

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-111497

61 sources

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

Repository files12

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

lab.py

Python · 7,956 bytes
#!/usr/bin/env python3
"""Prepare/stop a fresh local Podman lab with an independent exact-lab cutoff."""
import argparse
import importlib.util
import json
import os
from pathlib import Path
import re
import secrets
import subprocess
import time

ROOT = Path(__file__).resolve().parent
SPEC = importlib.util.spec_from_file_location('local_pingback_setup', ROOT / 'setup-lab.py')
if SPEC is None or SPEC.loader is None:
    raise RuntimeError('local lab setup source unavailable')
setup_lab = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(setup_lab)


DURATION = 600  # Timer is armed BEFORE the first Podman build or container.
UNIT_PREFIX = 'fb-pingback-cutoff-'


def nonce_ok(nonce):
    if not re.fullmatch(r'[0-9a-f]{24}', nonce):
        raise RuntimeError('invalid local nonce')
    return nonce


def timer_name(nonce):
    return UNIT_PREFIX + nonce_ok(nonce)


def timer_state(nonce):
    name = timer_name(nonce)
    result = subprocess.run(['systemctl', '--user', 'show', name + '.timer',
                             '-p', 'LoadState', '-p', 'ActiveState', '-p',
                             'NextElapseUSecMonotonic', '-p', 'Unit'],
                            capture_output=True, text=True, timeout=10, check=True)
    fields = dict(line.split('=', 1) for line in result.stdout.splitlines() if '=' in line)
    return fields


def require_cutoff(nonce):
    name = timer_name(nonce)
    t = timer_state(nonce)
    if (t.get('LoadState') != 'loaded' or t.get('ActiveState') != 'active' or
            not t.get('NextElapseUSecMonotonic') or
            t['NextElapseUSecMonotonic'] == 'infinity' or
            t.get('Unit') != name + '.service'):
        raise RuntimeError('independent local cutoff timer inactive')
    service = subprocess.run(['systemctl', '--user', 'show', name + '.service',
                              '-p', 'ExecStart'], capture_output=True,
                             text=True, timeout=10, check=True).stdout
    expected = str(ROOT / 'lab.py') + ' --cutoff ' + nonce
    if expected not in service:
        raise RuntimeError('local cutoff service target mismatch')


def exact_cleanup(nonce):
    """Idempotent label-and-name-bound cleanup, including interrupted setup."""
    nonce_ok(nonce)
    name = 'fb-pingback-' + nonce
    current = setup_lab.CURRENT
    if current.is_symlink():
        raise RuntimeError('unsafe current lab state')
    state = json.loads(current.read_text()) if current.is_file() else None
    if state is not None and state.get('nonce') != nonce:
        raise RuntimeError('another lab owns current state; cleanup refused')
    for kind, resource in (('pod', name), ('volume', name + '-wp'),
                           ('volume', name + '-db'), ('network', name + '-net')):
        setup_lab.checked_remove(kind, resource, nonce)
    image = 'localhost/' + name + ':local'
    if setup_lab.exists('image', image):
        row = json.loads(setup_lab.podman('image', 'inspect', image, timeout=10))
        if isinstance(row, list):
            if len(row) != 1: raise RuntimeError('ambiguous local image')
            row = row[0]
        if (row.get('Config') or {}).get('Labels', {}).get(setup_lab.LABEL) != nonce:
            raise RuntimeError('local image label mismatch; cleanup refused')
        setup_lab.podman('image', 'rm', image, timeout=30)
    for kind, resource in (('pod', name), ('volume', name + '-wp'),
                           ('volume', name + '-db'), ('network', name + '-net'),
                           ('image', image)):
        if setup_lab.exists(kind, resource):
            raise RuntimeError('scoped local resource remains: ' + kind)
    if state is not None:
        current.unlink()
    return True


def stop_cutoff(nonce):
    name = timer_name(nonce)
    t = timer_state(nonce)
    if t.get('LoadState') == 'not-found' and t.get('ActiveState') == 'inactive':
        return
    if (t.get('ActiveState') == 'inactive' and
            t.get('NextElapseUSecMonotonic') == 'infinity' and
            t.get('Unit') == name + '.service'):
        return  # The one-shot cutoff already fired; cleanup was checked first.
    require_cutoff(nonce)
    subprocess.run(['systemctl', '--user', 'stop', name + '.timer'],
                   capture_output=True, text=True, timeout=12, check=True)
    if timer_state(nonce).get('ActiveState') != 'inactive':
        raise RuntimeError('local cutoff still active')


def prepare(port):
    if not isinstance(port, int) or not 1024 <= port <= 65535:
        raise RuntimeError('invalid local loopback port')
    if setup_lab.CURRENT.exists() or setup_lab.CURRENT.is_symlink():
        raise RuntimeError('a local lab already exists; use its exact teardown first')
    setup_lab.ensure_rootless()
    nonce = secrets.token_hex(12)
    name = timer_name(nonce)
    t = timer_state(nonce)
    if t.get('LoadState') != 'not-found' or t.get('ActiveState') != 'inactive':
        raise RuntimeError('fresh cutoff unit name already occupied')
    start = time.monotonic()
    subprocess.run(['systemd-run', '--user', '--unit=' + name, '--on-active=10min',
                    '--property=Type=oneshot', '/usr/bin/python3', '-B',
                    str(ROOT / 'lab.py'), '--cutoff', nonce],
                   capture_output=True, timeout=16, check=True)
    try:
        require_cutoff(nonce)
        env = os.environ.copy(); env['FB_PINGBACK_NONCE'] = nonce
        env['FB_PINGBACK_PORT'] = str(port)
        result = subprocess.run(['/usr/bin/python3', '-B', str(ROOT / 'setup-lab.py'), 'up'],
                                cwd=ROOT, env=env, capture_output=True, text=True, timeout=460)
        if result.returncode:
            raise RuntimeError('local lab setup failed: ' + result.stderr[-300:])
        if setup_lab.CURRENT.is_symlink() or not setup_lab.CURRENT.is_file():
            raise RuntimeError('fresh lab state missing')
        state = json.loads(setup_lab.CURRENT.read_text())
        if state.get('nonce') != nonce or state.get('port') != port:
            raise RuntimeError('fresh lab identity changed')
        require_cutoff(nonce)
        if time.monotonic() - start >= DURATION - 125:
            raise RuntimeError('cutoff too near for one request and teardown')
        print('Lab ready: http://localhost:%d/' % port, flush=True)
        print('Run: python3 exploit.py http://localhost:%d/' % port, flush=True)
        print('Afterward: python3 -B lab.py down', flush=True)
    except BaseException:
        exact_cleanup(nonce)
        stop_cutoff(nonce)
        raise


def down():
    current = setup_lab.CURRENT
    if current.is_symlink() or not current.is_file():
        raise RuntimeError('no prepared local lab; do not guess a nonce')
    state = json.loads(current.read_text())
    nonce = nonce_ok(state.get('nonce'))
    exact_cleanup(nonce)
    stop_cutoff(nonce)
    print('Exact local lab removed; cutoff disarmed.', flush=True)


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('action', nargs='?', choices=('up','down'))
    parser.add_argument('--port', type=int, help='local loopback port for up, e.g. 18190')
    parser.add_argument('--cutoff', metavar='EXACT_NONCE')
    args = parser.parse_args()
    if args.cutoff:
        if args.action or args.port is not None: parser.error('cutoff does not accept up/down or port')
        exact_cleanup(args.cutoff)
        print('Exact cutoff cleanup complete', flush=True)
    elif args.action == 'up':
        if args.port is None: parser.error('up requires --port')
        prepare(args.port)
    elif args.action == 'down':
        if args.port is not None: parser.error('down does not accept --port')
        down()
    else: parser.error('choose up or down')


if __name__ == '__main__':
    try:
        main()
    except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as exc:
        raise SystemExit('Local run stopped: ' + str(exc))