Exploit databaseDownload repository ZIP
GH-768a04484e12b2d5fd121afa19f4201c
shellharbor/php-8.1-cve-2026-docker
Sources for CVE-2026-109618
413 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files22
shellharbor/php-8.1-cve-2026-dockerRevision 11e9aeb57664
- ↑..Parent directory
- .gitkeep
- apply-history.py
- augment-sbom.php
- build-native.py
- build-php.sh
- build.ps1
- build.sh
- entrypoint.sh
- healthcheck.sh
- lock-dependencies.sh
- lock-native-dependencies.sh
- lock-test-dependencies.sh
- make-rootfs.py
- package-php.sh
- prepare-source.sh
- refresh-upstream-certs.py
- release-gate.php
- run-upstream.py
- scan.sh
- test.sh
- verify-source.sh
- verify.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scripts/run-upstream.py
Python · 12,153 bytes"""Run the complete configured upstream PHPT tree; preserve failures instead of blessing them."""
from __future__ import annotations
import argparse
from collections import Counter
import hashlib
import importlib.util
import json
import os
from pathlib import Path
import shutil
import shlex
import signal
import re
import subprocess
import time
SOURCE = Path('/usr/src/php')
PHP = Path('/runtime/usr/local/bin/php')
def digest(file: Path) -> str:
value = hashlib.sha256()
with file.open('rb') as stream:
for chunk in iter(lambda: stream.read(1024 * 1024), b''):
value.update(chunk)
return value.hexdigest()
def prepare_fixtures(version: str) -> tuple[list[dict], dict, str]:
manifest_path = Path('/audit/adjustments.json')
manifest = json.loads(manifest_path.read_text())
if manifest['schema'] != 1 or manifest['php_version'] != version:
raise ValueError('Unexpected test fixture manifest')
records = []
expected = re.compile(r'^--(EXPECT|EXPECTF|EXPECTREGEX)--\r?\n(.*?)(?=^--[A-Z_]+--|\Z)', re.M | re.S)
for item in manifest['adjustments']:
file = SOURCE / item['file']
if not file.resolve().is_relative_to(SOURCE) or file.suffix != '.phpt' or digest(file) != item['before_sha256']:
raise ValueError('Unexpected test fixture bytes/path: ' + item['file'])
original = file.read_bytes().decode('utf-8')
changed = original
for replacement in item['replacements']:
if changed.count(replacement['before']) != replacement['count']:
raise ValueError('Unexpected test fixture context: ' + item['file'])
changed = changed.replace(replacement['before'], replacement['after'])
if expected.findall(original) != expected.findall(changed):
raise ValueError('Test repair must not rewrite PHPT expected output')
if hashlib.sha256(changed.encode('utf-8')).hexdigest() != item['after_sha256']:
raise ValueError('Unexpected repaired test hash')
file.write_bytes(changed.encode('utf-8'))
records.append({key: item[key] for key in ('file', 'category', 'reason', 'before_sha256', 'after_sha256')})
spec = importlib.util.spec_from_file_location('owned_tls_fixtures', '/audit/refresh-upstream-certs.py')
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
certificates = module.refresh(SOURCE, manifest['tls_fixtures'])
return records, certificates, digest(manifest_path)
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--output', required=True)
parser.add_argument('--jobs', type=int, choices=range(1, 5), default=1)
parser.add_argument('--stdio', choices=('pty', 'pipes'), default='pty')
parser.add_argument('--prepare-only', action='store_true', help='Validate/prepare fixtures without running or claiming a complete suite')
args = parser.parse_args()
output = Path(args.output).resolve()
if not output.is_relative_to(Path('/reports')) or output == Path('/reports'):
raise ValueError('Output must be a dedicated directory below /reports')
output.mkdir(parents=True, exist_ok=True)
if (output / 'summary.json').exists() or (output / 'preparation.json').exists():
raise RuntimeError('Refusing to overwrite an earlier upstream run')
extensions = sorted(Path('/runtime/usr/local/lib/php/extensions').glob('*/opcache.so'))
if len(extensions) != 1:
raise RuntimeError('Expected exactly one packaged OPcache module')
if args.stdio == 'pty' and args.jobs != 1:
raise ValueError('PTY mode requires one worker so uncaptured descriptors remain terminal descriptors')
version = subprocess.check_output([str(PHP), '-n', '-r', 'echo PHP_VERSION;'], text=True)
fixture_records, certificates, fixture_manifest_hash = prepare_fixtures(version)
tests = [{'path': str(file.relative_to(SOURCE)), 'sha256': digest(file)}
for file in sorted(SOURCE.rglob('*.phpt'))]
(output / 'discovered-tests.json').write_text(json.dumps(tests, indent=2) + '\n')
environment = dict(os.environ)
for name in ('HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY', 'http_proxy', 'https_proxy', 'all_proxy'):
environment.pop(name, None)
environment.update(NO_INTERACTION='1', REPORT_EXIT_STATUS='1', SKIP_ONLINE_TESTS='1',
TEST_PHP_EXECUTABLE=str(PHP),
TEST_PHP_FPM_EXECUTABLE='/runtime/usr/local/sbin/php-fpm',
TEST_PHP_JUNIT=str(output / 'junit.xml'), NO_COLOR='1', TZ='UTC')
runner = SOURCE / 'run-tests.php'
original_runner_sha256 = digest(runner)
adjustments = []
if version.startswith('7.4.'):
runner_text = runner.read_text()
extension_needle = 'if (!in_array($req_ext, $loaded)) {'
if runner_text.count(extension_needle) != 1:
raise RuntimeError('Unexpected upstream extension-loader context')
runner = SOURCE / 'run-tests.audit.php'
runner.write_text(runner_text.replace(extension_needle,
"if (!in_array(strtolower($req_ext), array_map('strtolower', $loaded), true)) {"))
adjustments.append('Audit-only runner compares required and built-in extension names case-insensitively; avoids attempting to load absent phar.so when built-in Phar is already loaded. No PHPT selection or expected output changed.')
helper = SOURCE / 'ext/mysqli/tests/fake_server.inc'
text = helper.read_text()
needle = 'public function __set(string $name, $value)'
if text.count(needle) != 1:
raise RuntimeError('Unexpected imported mysqli test-helper context')
before = digest(helper)
helper.write_text(text.replace('<?php', '<?php\nmysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);', 1))
subprocess.run([str(PHP), '-n', '-l', str(helper)], check=True, stdout=subprocess.DEVNULL)
adjustments.append('Audit-only mysqli helper explicitly selects the PHP 8.1 strict reporting mode assumed by imported tests; packet data, PHPT bodies, expected output and runtime defaults unchanged; before=' + before + '; after=' + digest(helper))
if version.startswith('8.1.'):
text = runner.read_text()
needle = 'function run_test(string $php, $file, array $env): string\n{\n'
if text.count(needle) != 1:
raise RuntimeError('Unexpected upstream test-runner context')
runner = SOURCE / 'run-tests.audit.php'
runner.write_text(text.replace(needle, needle + ' global $php_cgi, $phpdbg;\n'))
adjustments.append('Audit-only copy restores missing CGI/phpdbg globals in PHP 8.1 run_test; no PHPT selection, expectations or target PHP code changed')
command = [str(PHP), '-n', str(runner), '-p', str(PHP), '-n',
'-d', 'extension_dir=' + str(extensions[0].parent),
'-d', 'zend_extension=' + str(extensions[0]), '-q', '-j' + str(args.jobs),
'--offline', '--set-timeout', '60', '-W', str(output / 'results.tsv'),
'-w', str(output / 'failed.txt'), '-g', 'FAIL,BORK,WARN,LEAK,XFAIL']
launch = command
terminal = {'mode': args.stdio}
if args.stdio == 'pty':
terminal['tool'] = subprocess.check_output(['/usr/bin/script', '--version'], text=True).strip()
launch = ['/usr/bin/script', '--quiet', '--return', '--command', shlex.join(command), '/dev/null']
preparation = {'php_version': version, 'test_fixture_manifest_sha256': fixture_manifest_hash,
'test_fixture_adjustments': fixture_records, 'certificate_fixtures': certificates,
'terminal': terminal, 'launch_command': launch, 'harness_adjustments': adjustments}
(output / 'preparation.json').write_text(json.dumps(preparation, indent=2) + '\n')
if args.prepare_only:
print(json.dumps({'prepared': True, 'complete_suite_run': False, 'php_version': version}), flush=True)
return
start = time.time()
timed_out = False
with (output / 'run-tests.txt').open('wb') as stream:
process = subprocess.Popen(launch, cwd=SOURCE, env=environment, stdin=subprocess.DEVNULL, stdout=stream,
stderr=subprocess.STDOUT, start_new_session=True)
try:
code = process.wait(timeout=7200)
except subprocess.TimeoutExpired:
timed_out = True
os.killpg(process.pid, signal.SIGTERM)
try:
process.wait(timeout=10)
except subprocess.TimeoutExpired:
os.killpg(process.pid, signal.SIGKILL)
process.wait()
code = 124
results = []
result_file = output / 'results.tsv'
if result_file.exists():
for line in result_file.read_text(errors='replace').splitlines():
fields = line.split(None, 1)
if len(fields) == 2:
results.append({'status': fields[0], 'test': fields[1]})
diagnostics = []
used = 0
failed = output / 'failed.txt'
if failed.exists():
for line in failed.read_text().splitlines():
if not line.strip() or line.startswith('#'):
diagnostics.append({'entry': line, 'copied': False,
'reason': 'Upstream redirect/comment record retained verbatim in failed.txt'})
continue
file = Path(line)
if not file.is_absolute():
file = SOURCE / file
if not file.resolve().is_relative_to(SOURCE):
raise ValueError('Unexpected failed test path')
for suffix in ('.diff', '.out', '.exp', '.log', '.php', '.sh'):
artifact = file.with_suffix(suffix)
if not artifact.is_file() or not artifact.resolve().is_relative_to(SOURCE):
continue
relative = artifact.relative_to(SOURCE)
size = artifact.stat().st_size
copied = size <= 1024 * 1024 and used + size <= 64 * 1024 * 1024
diagnostics.append({'path': str(relative), 'size': size,
'sha256': digest(artifact), 'copied': copied})
if copied:
target = output / 'failures' / relative
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(artifact, target)
used += size
(output / 'diagnostics.json').write_text(json.dumps(diagnostics, indent=2) + '\n')
log = (output / 'run-tests.txt').read_text(errors='replace')
summary = {'schema': 1, 'php_version': version,
'command': command, 'selection': 'Entire upstream source tree; no path selection or skip list',
'network': 'none; upstream --offline; loopback fixtures only',
'unavailable': 'Unbuilt extensions, CGI/phpdbg, external services and other platforms may be skipped by upstream SKIPIF',
'php_binary_sha256': digest(PHP), 'fpm_binary_sha256': digest(Path('/runtime/usr/local/sbin/php-fpm')),
'opcache_sha256': digest(extensions[0]), 'original_run_tests_sha256': original_runner_sha256,
'effective_run_tests_sha256': digest(runner), 'harness_adjustments': adjustments,
'test_fixture_manifest_sha256': fixture_manifest_hash, 'test_fixture_adjustments': fixture_records,
'certificate_fixtures': certificates, 'terminal': terminal, 'launch_command': launch,
'discovered_phpt_files': len(tests), 'result_counts': dict(Counter(item['status'] for item in results)),
'result_records': len(results), 'exit_code': code, 'timed_out': timed_out,
'elapsed_seconds': round(time.time() - start, 2), 'production_ready': False,
'log_sha256': digest(output / 'run-tests.txt'), 'diagnostic_bytes': used,
'log_tail': log[-12000:]}
(output / 'summary.json').write_text(json.dumps(summary, indent=2) + '\n')
print(json.dumps({key: value for key, value in summary.items() if key != 'log_tail'}), flush=True)
raise SystemExit(code)
if __name__ == '__main__':
main()