Exploit databaseDownload repository ZIP
GH-945bd5267b0d1b94c3f74faf5cda7e5a
blkph0x/cve-2026-83844_poc
Sources for CVE-2026-83844
5 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files579
blkph0x/cve-2026-83844_pocRevision 193ed44859da
- ↑..Parent directory
- afl_emf_gdiplus/
- capture/
- generated/
- BFDB_ALLOCATOR_REUSE_PROTOCOL.md
- BFDB_AUTHORING_MEDIA_STATIC.md
- BFDB_AUTHORING_PROTOCOL.md
- BFDB_BOUNDED_MARKER_PLACEMENT_PROTOCOL.md
- BFDB_BYTE_PROVENANCE_PROTOCOL.md
- BFDB_CACHE_PROTOCOL.md
- BFDB_CLOCK_ONLY_CONTROL_PROTOCOL.md
- BFDB_CROSSSLOT_PROTOCOL.md
- BFDB_FAST_FIRST_OPEN_PROTOCOL.md
- BFDB_FOUR_WPR_PROTOCOL.md
- BFDB_GEOMETRY_GUEST_PROTOCOL.md
- BFDB_LFH_CHECKPOINT_PROTOCOL.md
- BFDB_MARKER_ACCEPTANCE.md
- BFDB_MARKER_FIRSTOPEN_SEMANTIC_GATE.md
- BFDB_MARKER_FOUR_FIRSTOPEN_PROTOCOL.md
- BFDB_MARKER_FOUR_PROTOCOL.md
- BFDB_MARKER_ROUTE_CONTROL.md
- BFDB_MARKER_SEMANTIC_GATE.md
- BFDB_NORMAL_EXTENT_PROTOCOL.md
- BFDB_NORMAL_HEAP_PROTOCOL.md
- BFDB_NORMAL_RECORD_PROTOCOL.md
- BFDB_OUTPUT_GATES_PROTOCOL.md
- BFDB_POSTOPEN_PROTOCOL.md
- BFDB_SDK_RESOLUTION_SCAN.md
- BFDB_SINK_GATE_PROTOCOL.md
- BFDB_VALIDATION_LIFETIME_PROTOCOL.md
- BFDB_WPR_HEAP_PROTOCOL.md
- BRUSH_DISPATCH_PROTOCOL.md
- COLD_ATTACH_REPAIR_PLAN.md
- EMF_BFDB_FUZZ_ANALYSIS.md
- EMF_BFDB_FUZZ_BATCH_PROTOCOL.md
- EMF_BFDB_FUZZ_CAMPAIGN.md
- EMF_BFDB_SEQUENCE_PROTOCOL.md
- EMF_BFDB_WARM_PAGEHEAP_PROTOCOL.md
- EMF_CLIPBOARD_VALID_PROTOCOL.md
- EMF_VALID_ACCEPTANCE_PROTOCOL.md
- FILL_LOOP_CENSUS_PROTOCOL.md
- FILL_MOUSE_EVENT_PROTOCOL.md
- FILL_TOUCH_INPUT_PROTOCOL.md
- FILL_WIN32_DISPATCH_PROTOCOL.md
- PROVENANCE_APP11_POSTSEEK_PROTOCOL.md
- PROVENANCE_APP11_READER_SCAN_PROTOCOL.md
- PROVENANCE_APP11_SPLIT_NEW_LABEL_GUARD_PROTOCOL.md
- PROVENANCE_BATCH_E_SUBSET_PROTOCOL.md
- PROVENANCE_COPY_REOPEN_PROTOCOL.md
- PROVENANCE_E_CHILD_DECISION_PROTOCOL.md
- PROVENANCE_FIELD_ID_CONSUMER_PROTOCOL.md
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/trace/guest_bfdb_r48_entry.ps1
PowerShell · 38,119 bytesparam(
[Parameter(Mandatory = $true)][ValidateSet('old','new')][string]$Build,
[Parameter(Mandatory = $true)][ValidateSet('control','trigger')][string]$CaseId,
[ValidateSet('licensed','external','geometry','crossslot','r32','r48')][string]$Source = 'licensed',
[ValidateSet('','control-20','trigger-20','unterminated-19','control-21','trigger-21')]
[string]$GeometryCase = '',
[ValidateSet('ExistingPid','PlmDebug','IfeoDebugger')][string]$HandoffMode = 'ExistingPid',
[ValidateSet('PageHeap','Normal')][string]$HeapMode = 'PageHeap',
[ValidateSet('Default','NewReader','NormalRecord','NormalExtent','CrossslotNormal','CrossslotGuard','R32Normal','R48Normal')][string]$TraceMode = 'Default'
)
# Disposable Windows Sandbox only. One fresh signed Paint PID and one JPEG per
# guest. Do not call the upstream repro: it changes host IFEO and kills Paint.
$ErrorActionPreference = 'Stop'
if (($Source -eq 'geometry') -ne [bool]$GeometryCase) {
throw 'GeometryCase is required only for the geometry source.'
}
if ($Source -eq 'geometry' -and
@('control-20','trigger-20','unterminated-19','control-21','trigger-21') -cnotcontains $GeometryCase) {
throw 'GeometryCase must use the exact lowercase pinned name.'
}
if ($Source -eq 'geometry') {
$expectedCaseId = if ($GeometryCase.StartsWith('control-')) { 'control' } else { 'trigger' }
if ($CaseId -cne $expectedCaseId -or $HandoffMode -cne 'PlmDebug' -or
(($Build -eq 'old') -and ($HeapMode -cne 'Normal' -or $TraceMode -cne 'NormalExtent')) -or
(($Build -eq 'new') -and ($HeapMode -cne 'PageHeap' -or $TraceMode -cne 'NewReader'))) {
throw 'Geometry guest requires matched case, PLMDebug, old NormalExtent or new NewReader.'
}
}
if ($Source -eq 'crossslot' -and
($HandoffMode -cne 'PlmDebug' -or
(($Build -eq 'old') -and (
($HeapMode -eq 'Normal' -and $TraceMode -cne 'CrossslotNormal') -or
($HeapMode -eq 'PageHeap' -and $TraceMode -cne 'CrossslotGuard'))) -or
(($Build -eq 'new') -and ($HeapMode -cne 'PageHeap' -or $TraceMode -cne 'NewReader')))) {
throw 'Crossslot guest requires PLMDebug, old CrossslotNormal/Guard or new PageHeap NewReader.'
}
if (($Source -eq 'r32') -ne ($TraceMode -eq 'R32Normal') -or
($Source -eq 'r32' -and
($Build -cne 'old' -or $HeapMode -cne 'Normal' -or $HandoffMode -cne 'PlmDebug'))) {
throw 'R32 guest requires signed old Paint, normal heap, PLMDebug and R32Normal.'
}
if (($Source -eq 'r48') -ne ($TraceMode -eq 'R48Normal') -or
($Source -eq 'r48' -and
($Build -cne 'old' -or $HeapMode -cne 'Normal' -or $HandoffMode -cne 'PlmDebug'))) {
throw 'R48 guest requires signed old Paint, normal heap, PLMDebug and R48Normal.'
}
if ($HeapMode -eq 'Normal' -and ($Build -cne 'old' -or $HandoffMode -cne 'PlmDebug')) {
throw 'Normal-heap leverage follow-up requires old signed Paint and PLMDebug.'
}
if ($TraceMode -eq 'NewReader' -and
($Build -cne 'new' -or $HeapMode -cne 'PageHeap' -or
$Source -notin @('licensed','geometry','crossslot') -or $HandoffMode -cne 'PlmDebug')) {
throw 'NewReader requires signed new Paint, licensed JPEG, PageHeap and PLMDebug.'
}
if ($TraceMode -eq 'NormalRecord' -and
($Build -cne 'old' -or $HeapMode -cne 'Normal' -or
$Source -notin @('licensed','geometry') -or $HandoffMode -cne 'PlmDebug')) {
throw 'NormalRecord requires signed old Paint, licensed JPEG, normal heap and PLMDebug.'
}
if ($TraceMode -eq 'NormalExtent' -and
($Build -cne 'old' -or $HeapMode -cne 'Normal' -or
$Source -notin @('licensed','geometry') -or $HandoffMode -cne 'PlmDebug')) {
throw 'NormalExtent requires signed old Paint, licensed JPEG, normal heap and PLMDebug.'
}
$inputRoot = 'C:\PaintLab\Input'
$outputRoot = 'C:\PaintLab\Output'
$marker = 'C:\PaintLab\guest.marker'
if ($env:USERNAME -ne 'WDAGUtilityAccount' -or
-not (Test-Path -LiteralPath $inputRoot -PathType Container) -or
-not (Test-Path -LiteralPath $outputRoot -PathType Container)) {
throw 'Guest guard failed: authoring trial runs only in the Paint Windows Sandbox.'
}
$expectedVersions = @{ old='11.2605.81.0'; new='11.2609.401.0' }
$fixtureSources = @{
licensed = @{
control = @{ file='control.jpg'; sha256='75a8da33f6eaf1e16bf3b42cd78913b22b2e6a671fda217a508b1ba4230ce864' }
trigger = @{ file='trigger-0120-01.jpg'; sha256='82e1ad0b1be3183b0a6075ce53a44a888f149765f24cd2a681b0656b348a8f9a' }
}
external = @{
control = @{ file='reproduction__c2pa-control.jpg'; sha256='a2d14755db55de67a47c04090340d8266e892367be4104a45626d7a6fa6e9ffd' }
trigger = @{ file='reproduction__c2pa-0120-01.jpg'; sha256='d743b6c36b47ba6ed86d6614380daa5c5d56d49d681f53e4bad4a1acce9d4757' }
}
geometry = @{
'control-20' = @{ file='control-20.jpg'; sha256='75a8da33f6eaf1e16bf3b42cd78913b22b2e6a671fda217a508b1ba4230ce864' }
'trigger-20' = @{ file='trigger-20.jpg'; sha256='82e1ad0b1be3183b0a6075ce53a44a888f149765f24cd2a681b0656b348a8f9a' }
'unterminated-19' = @{ file='unterminated-19.jpg'; sha256='c45669deac5488374e304292c3359608ebea3aacb3fb8cf6a62c89858121f9ab' }
'control-21' = @{ file='control-21.jpg'; sha256='f38e99936debb9ca123d664079a21f8129bd67a3f2e6ef1f715109e56427cf64' }
'trigger-21' = @{ file='trigger-21.jpg'; sha256='7a7008dfa25b0799f025e7765878b7bcb2abea37da3783247075bff767032466' }
}
crossslot = @{
control = @{ file='control-24.jpg'; sha256='a2bdfd294fab4aec5a5df086cde7303f217f4d29031b19a36c0db4dc97bd678b' }
trigger = @{ file='trigger-24.jpg'; sha256='e38a4bb5e2aeab332c6682315b94a0ac7423eea206e33b5238dddb836bbcb345' }
}
r32 = @{
control = @{ file='control-40.jpg'; sha256='c4af8f072877b9a6a0db19f409dc0c56cc88b72962f2ef8c1f3ca49aac7be52d' }
trigger = @{ file='trigger-40.jpg'; sha256='75315db4096f7580490dfbfe8beedc17dcc79f1854a50aa571c7327c71852afa' }
}
r48 = @{
control = @{ file='control-56.jpg'; sha256='3efd5b264ce87fe9dcba39853018a9ce4fbe056e12ea901119d7bb5cdffa7e6c' }
trigger = @{ file='trigger-56.jpg'; sha256='7249839113ce0453fe1f6a3e7bc86d6493e7766d405c87c745ea31058f418962' }
}
}
$selectedFixture = $fixtureSources[$Source][$(if ($Source -eq 'geometry') { $GeometryCase } else { $CaseId })]
$gflagsHash = '3b4501db349dcd49214c5e4fc57a886458dc013dcee498b2722146fc8d451f45'
$runId = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
$experimentSubdir = if ($Source -eq 'r48') { 'bfdb-r48' }
elseif ($Source -eq 'r32') { 'bfdb-r32' }
elseif ($Source -eq 'crossslot') { 'bfdb-crossslot' }
elseif ($TraceMode -eq 'NormalExtent') { 'bfdb-normal-extent' }
elseif ($TraceMode -eq 'NormalRecord') { 'bfdb-normal-record' }
elseif ($HeapMode -eq 'Normal') { 'bfdb-normal-heap' }
elseif ($TraceMode -eq 'NewReader') { 'bfdb-new-reader' }
else { 'bfdb-authoring' }
$output = Join-Path $outputRoot "$experimentSubdir\$Build\$CaseId\$runId"
New-Item -ItemType Directory -Force -Path $output | Out-Null
[ordered]@{
schema='paint-bfdb-authoring-entry-start-v1'
build=$Build; case_id=$CaseId; source=$Source; geometry_case=$GeometryCase
started_utc=(Get-Date).ToUniversalTime().ToString('o')
} | ConvertTo-Json -Depth 3 | Set-Content -LiteralPath (Join-Path $output 'entry-start.json') -Encoding UTF8
$resultPath = Join-Path $output 'result.json'
$logPath = Join-Path $output 'cdb.log'
$gflags = Join-Path $inputRoot 'debugger\gflags.exe'
$cdb = Join-Path $inputRoot 'debugger\cdb.exe'
$plmdebug = Join-Path $inputRoot 'debugger\plmdebug.exe'
$plmdebugHash = 'df595e3ab812fabe89dca86fa8526a4ef91c670a71a42c0f2a380c4cd8a65dac'
$ifeoKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\mspaint.exe'
$guestEntry = Join-Path $inputRoot 'trace\guest_bfdb_authoring_entry.ps1'
$profilePath = Join-Path $inputRoot 'trace\bfdb.auto.cdb.txt'
$profileJson = "$profilePath.json"
$fixture = Join-Path $inputRoot ('bfdb_authoring\' + $selectedFixture.file)
$bootstrap = Join-Path $inputRoot 'guest-bootstrap.ps1'
$bootstrapResult = Join-Path $outputRoot 'bootstrap-result.json'
$cdbProcess = $null
$paintPid = $null
$pageheapEnabled = $false
$autoDebuggerEnabled = $false
$packageFullName = $null
$bootstrapPaintPid = $null
$result = [ordered]@{
schema='paint-bfdb-authoring-guest-v1'; build=$Build; case_id=$CaseId; source=$Source
geometry_case=$GeometryCase
handoff_mode=$HandoffMode; heap_mode=$HeapMode; trace_mode=$TraceMode
guest_entry_sha256=$null
started_utc=(Get-Date).ToUniversalTime().ToString('o')
status='preflight'; installed_version=$null; installed_exe_sha256=$null
fixture_sha256=$null; profile_sha256=$null; profile_manifest_sha256=$null
module_checks=@(); loaded_module_checks=@(); gflags_sha256=$null
pageheap_listing_verified=$false; normal_heap_verified=$false
bootstrap_stage=$null; bootstrap_exit_code=$null; bootstrap_paint_pid=$null; paint_pid=$null
debugger_pid=$null; debugger_ready=$false; debugger_initial_pid=$null
auto_debugger_enable=$null; auto_debugger_disable=$null; auto_debugger_residue=$null
uri_requested_utc=$null; uri_launch_error=$null; observation_elapsed_seconds=$null
observation_window_exhausted=$false
marker_pid_records=@(); markers=@(); all_marker_pids_match=$false
required_backend_markers_seen=$false; route_status_before_cleanup=$null
extra_paint_pids=@()
paint_pids_after_uri=@(); cdb_access_violation_text_seen=$false
application_error_events=@(); dump_files=@()
cleanup=$null; pageheap_disable_exit_code=$null
interpretation='not_run'; error=$null; completed_utc=$null
}
function Get-PaintSnapshot {
@(
Get-Process -Name mspaint -ErrorAction SilentlyContinue | ForEach-Object {
$path = $null
try { $path = $_.Path } catch { }
[ordered]@{ pid=$_.Id; path=$path; title=$_.MainWindowTitle }
}
)
}
function Invoke-BoundedBootstrap {
$args = @('-NoProfile','-ExecutionPolicy','Bypass','-File',$bootstrap,'-Build',$Build)
$child = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe') `
-ArgumentList $args -WindowStyle Hidden -PassThru -ErrorAction Stop
if (-not $child.WaitForExit(150000)) {
Stop-Process -Id $child.Id -Force -ErrorAction SilentlyContinue
throw 'Signed package bootstrap exceeded 150 seconds.'
}
$child.Refresh()
return $child.ExitCode
}
try {
$needed = @($gflags,$cdb,$profilePath,$profileJson,$fixture,$bootstrap,$guestEntry)
if ($HandoffMode -eq 'PlmDebug') { $needed += $plmdebug }
foreach ($path in $needed) {
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Required guest input missing: $path" }
}
$result.guest_entry_sha256 = (Get-FileHash -LiteralPath $guestEntry -Algorithm SHA256).Hash.ToLowerInvariant()
if ($HandoffMode -eq 'PlmDebug' -and
(Get-FileHash -LiteralPath $plmdebug -Algorithm SHA256).Hash.ToLowerInvariant() -cne $plmdebugHash) {
throw 'Pinned guest PLMDebug digest differs.'
}
$result.gflags_sha256 = (Get-FileHash -LiteralPath $gflags -Algorithm SHA256).Hash.ToLowerInvariant()
if ($result.gflags_sha256 -cne $gflagsHash) { throw 'Pinned guest gflags digest differs.' }
$result.fixture_sha256 = (Get-FileHash -LiteralPath $fixture -Algorithm SHA256).Hash.ToLowerInvariant()
if ($result.fixture_sha256 -cne $selectedFixture.sha256) { throw 'Pinned guest JPEG differs.' }
$profile = Get-Content -LiteralPath $profileJson -Raw | ConvertFrom-Json
$expectedProfileSchema = if ($TraceMode -eq 'R48Normal') {
'paint-bfdb-r48-trace-v1'
} elseif ($TraceMode -eq 'R32Normal') {
'paint-bfdb-r32-trace-v1'
} elseif ($TraceMode -in @('CrossslotNormal','CrossslotGuard')) {
'paint-bfdb-crossslot-trace-v1'
} elseif ($TraceMode -eq 'NormalExtent') {
'paint-bfdb-normal-extent-trace-v1'
} elseif ($TraceMode -eq 'NormalRecord') {
'paint-bfdb-normal-record-trace-v1'
} elseif ($HeapMode -eq 'Normal') {
'paint-bfdb-normal-heap-trace-v1'
} elseif ($TraceMode -eq 'NewReader') {
'paint-bfdb-new-reader-trace-v1'
} else { 'paint-bfdb-authoring-trace-v1' }
if ($profile.schema -cne $expectedProfileSchema -or
$profile.profile -cne $Build -or
$profile.version -cne $expectedVersions[$Build] -or
($HeapMode -eq 'Normal' -and $profile.heap_mode -cne 'Normal') -or
($TraceMode -eq 'NormalRecord' -and $profile.trace_mode -cne 'NormalRecord') -or
($TraceMode -eq 'NormalExtent' -and $profile.trace_mode -cne 'NormalExtent') -or
($TraceMode -in @('CrossslotNormal','CrossslotGuard','R32Normal','R48Normal') -and
($profile.trace_mode -cne $TraceMode -or $profile.heap_mode -cne $HeapMode)) -or
-not [bool]$profile.auto_continue) {
throw 'Guest authoring profile identity differs.'
}
$result.profile_sha256 = (Get-FileHash -LiteralPath $profilePath -Algorithm SHA256).Hash.ToLowerInvariant()
$result.profile_manifest_sha256 = (Get-FileHash -LiteralPath $profileJson -Algorithm SHA256).Hash.ToLowerInvariant()
if ($HeapMode -eq 'PageHeap') {
# Enable full PageHeap before bootstrap launches Paint. All registry
# state is confined to the disposable guest and disabled below.
$enableText = (& $gflags /p /enable mspaint.exe /full 2>&1 | Out-String)
[IO.File]::WriteAllText((Join-Path $output 'gflags-enable.txt'),$enableText)
if ($LASTEXITCODE -ne 0) { throw 'Guest gflags did not enable full PageHeap.' }
$pageheapEnabled = $true
$listing = (& $gflags /p 2>&1 | Out-String)
[IO.File]::WriteAllText((Join-Path $output 'gflags-list.txt'),$listing)
if ($LASTEXITCODE -ne 0 -or $listing -notmatch '(?is)mspaint\.exe.{0,120}full') {
throw 'Guest gflags listing did not attest full PageHeap.'
}
$result.pageheap_listing_verified = $true
} else {
# A fresh guest must prove that no Paint PageHeap flag is active;
# normal-heap observations are distinct from the guard-page control.
$listing = (& $gflags /p 2>&1 | Out-String)
[IO.File]::WriteAllText((Join-Path $output 'gflags-list.txt'),$listing)
if ($LASTEXITCODE -ne 0 -or $listing -match '(?i)\bmspaint\.exe\b') {
throw 'Normal-heap guest has a Paint GFlags heap entry.'
}
$result.normal_heap_verified = $true
}
$bootstrapStarted = (Get-Date).ToUniversalTime()
$result.bootstrap_exit_code = Invoke-BoundedBootstrap
if (-not (Test-Path -LiteralPath $bootstrapResult -PathType Leaf) -or
(Get-Item -LiteralPath $bootstrapResult).LastWriteTimeUtc -lt $bootstrapStarted.AddSeconds(-2)) {
throw 'Signed package bootstrap did not produce a fresh result.'
}
$boot = Get-Content -LiteralPath $bootstrapResult -Raw | ConvertFrom-Json
$result.bootstrap_stage = $boot.stage
if (-not (Test-Path -LiteralPath $marker -PathType Leaf) -or
(Get-Content -LiteralPath $marker -Raw).Trim() -cne 'PaintABLab-Sandbox-v1') {
throw 'Guest bootstrap marker missing or changed.'
}
if ($boot.stage -cne 'complete' -or
[string]$boot.installed_paint.version -cne $expectedVersions[$Build] -or
($null -ne $result.bootstrap_exit_code -and $result.bootstrap_exit_code -ne 0)) {
throw 'Signed package install or Paint activation failed.'
}
$packages = @(Get-AppxPackage -Name Microsoft.Paint -ErrorAction Stop)
if ($packages.Count -ne 1 -or [string]$packages[0].Version -cne $expectedVersions[$Build]) {
throw 'Installed guest Paint version differs.'
}
$installedExe = Join-Path $packages[0].InstallLocation 'PaintApp\mspaint.exe'
$result.installed_version = [string]$packages[0].Version
$result.installed_exe_sha256 = (Get-FileHash -LiteralPath $installedExe -Algorithm SHA256).Hash.ToLowerInvariant()
foreach ($entry in $profile.modules.PSObject.Properties) {
$path = Join-Path $packages[0].InstallLocation (Join-Path 'PaintApp' $entry.Name)
$hash = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant()
if ($hash -cne [string]$entry.Value.sha256) {
throw "Installed signed module differs: $($entry.Name)"
}
$result.module_checks += [ordered]@{ module=$entry.Name; sha256=$hash }
}
$paint = @(Get-PaintSnapshot)
if ($paint.Count -ne 1 -or $paint[0].path -ine $installedExe) {
throw 'Bootstrap did not leave exactly one signed Paint process.'
}
$bootstrapPaintPid = [int]$paint[0].pid
$result.bootstrap_paint_pid = $bootstrapPaintPid
$result.status = 'attaching'
if ($HandoffMode -eq 'ExistingPid') {
$paintPid = $bootstrapPaintPid
$result.paint_pid = $paintPid
$cdbProcess = Start-Process -FilePath $cdb -WindowStyle Hidden `
-ArgumentList @('-G','-p',$paintPid,'-logo',$logPath,'-cf',$profilePath) `
-PassThru -ErrorAction Stop
$result.debugger_pid = $cdbProcess.Id
$deadline = (Get-Date).AddSeconds(18)
do {
Start-Sleep -Milliseconds 300
$logText = if (Test-Path -LiteralPath $logPath -PathType Leaf) {
Get-Content -LiteralPath $logPath -Raw -ErrorAction SilentlyContinue
} else { '' }
$ready = $logText -match "(?m)^PAINT_TRACE_PROFILE=$Build\s*$" -and
$logText -match '(?m)^\d+:\d+> g\s*$'
$cdbProcess.Refresh()
} while (-not $ready -and -not $cdbProcess.HasExited -and (Get-Date) -lt $deadline)
if (-not $ready) { throw 'CDB did not arm before URI activation.' }
$initialPid = [regex]::Matches($logText,'(?m)^PAINT_TRACE_INITIAL_PID=(\d+)\s*$')
if ($initialPid.Count -ne 1 -or [int]$initialPid[0].Groups[1].Value -ne $paintPid) {
throw 'CDB target PID differs from signed bootstrap Paint PID.'
}
$result.debugger_initial_pid = $paintPid
$result.debugger_ready = $true
} elseif ($HandoffMode -eq 'PlmDebug') {
$packageFullName = [string]$packages[0].PackageFullName
# Registration is not attachment. Prior FullTrust trials registered
# successfully yet remained pending; only the CDB log/PID can attest.
$debugCommand = "$cdb -bonc -G -logo $logPath -cf $profilePath"
$autoDebuggerEnabled = $true
$enableText = (& $plmdebug /enableDebug $packageFullName $debugCommand 2>&1 | Out-String)
$enableCode = $LASTEXITCODE
$result.auto_debugger_enable = [ordered]@{
mode='PlmDebug'; exit_code=$enableCode; output=$enableText.Trim()
}
if ($enableCode -ne 0) { throw 'Guest PLMDebug registration failed.' }
} else {
# IFEO Debugger is set only inside this disposable guest, after the
# signed bootstrap PID exists. Preserve the PageHeap values on this key.
$existing = Get-ItemProperty -Path $ifeoKey -Name Debugger -ErrorAction SilentlyContinue
if ($existing -and $existing.PSObject.Properties['Debugger']) {
throw 'Guest IFEO Debugger value already exists; refusing replacement.'
}
$debugCommand = "$cdb -bonc -G -logo $logPath -cf $profilePath"
$autoDebuggerEnabled = $true
New-ItemProperty -Path $ifeoKey -Name Debugger -PropertyType String `
-Value $debugCommand -Force -ErrorAction Stop | Out-Null
$readback = Get-ItemProperty -Path $ifeoKey -Name Debugger -ErrorAction Stop
if ([string]$readback.Debugger -cne $debugCommand) {
throw 'Guest IFEO Debugger readback differs.'
}
$result.auto_debugger_enable = [ordered]@{
mode='IfeoDebugger'; readback_verified=$true
command_sha256=([Security.Cryptography.SHA256]::Create().ComputeHash(
[Text.Encoding]::UTF8.GetBytes($debugCommand)) |
ForEach-Object { $_.ToString('x2') }) -join ''
}
}
# Match the public trigger route, with the hash-pinned guest-local file.
# Retain the blank Paint PID: the measured URI route spawned a second PID.
$result.status = 'activating_uri'
$uri = "ms-paint://backgroundRemoval?isTemporaryPath=false&file=$fixture"
$result.uri_requested_utc = (Get-Date).ToUniversalTime().ToString('o')
try { Start-Process -FilePath $uri -ErrorAction Stop | Out-Null }
catch { $result.uri_launch_error = $_.Exception.Message }
if ($result.uri_launch_error) { throw "URI launch failed: $($result.uri_launch_error)" }
if ($HandoffMode -ne 'ExistingPid') {
$readyDeadline = (Get-Date).AddSeconds(40)
do {
Start-Sleep -Milliseconds 300
$logText = if (Test-Path -LiteralPath $logPath -PathType Leaf) {
Get-Content -LiteralPath $logPath -Raw -ErrorAction SilentlyContinue
} else { '' }
$ready = $logText -match "(?m)^PAINT_TRACE_PROFILE=$Build\s*$" -and
$logText -match '(?m)^\d+:\d+> g\s*$'
} while (-not $ready -and (Get-Date) -lt $readyDeadline)
if (-not $ready) { throw 'Action PID auto-debugger did not arm before its 40-second deadline.' }
$initialPid = [regex]::Matches($logText,'(?m)^PAINT_TRACE_INITIAL_PID=(\d+)\s*$')
if ($initialPid.Count -ne 1) { throw 'Action PID CDB initial target is absent or ambiguous.' }
$paintPid = [int]$initialPid[0].Groups[1].Value
if ($paintPid -eq $bootstrapPaintPid) {
throw 'Auto-debugger attached to bootstrap Paint instead of URI action PID.'
}
$action = @(Get-PaintSnapshot | Where-Object { $_.pid -eq $paintPid })
if ($action.Count -ne 1 -or $action[0].path -ine $installedExe) {
throw 'Auto-debugger target is not one signed URI Paint process.'
}
$cdbMatches = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
if ($cdbMatches.Count -ne 1) { throw 'Expected exactly one URI action debugger process.' }
$cdbProcess = $cdbMatches[0]
$result.paint_pid = $paintPid
$result.debugger_initial_pid = $paintPid
$result.debugger_pid = $cdbProcess.Id
$result.debugger_ready = $true
}
$observeStart = Get-Date
$observeSeconds = if ($TraceMode -in @('CrossslotNormal','CrossslotGuard','R32Normal','R48Normal')) { 360 }
elseif ($TraceMode -eq 'NormalExtent') { 360 }
elseif ($TraceMode -eq 'NormalRecord') { 300 }
elseif ($TraceMode -eq 'NewReader') { 180 } else { 60 }
$observeDeadline = $observeStart.AddSeconds($observeSeconds)
$lastRequired = if ($TraceMode -eq 'CrossslotGuard') { 'bfdb_strlen_call' }
elseif ($TraceMode -in @('CrossslotNormal','R32Normal','R48Normal')) { 'bfdb_result_test' }
elseif ($TraceMode -in @('NormalRecord','NormalExtent')) { 'bfdb_result_test' }
elseif ($HeapMode -eq 'Normal') { 'bfdb_media_memcpy' }
elseif ($TraceMode -eq 'NewReader') { 'validation_net_read_return' }
elseif ($Build -eq 'old') { 'bfdb_strlen_call' }
else { 'validation_net_read_entry' }
$lastRequiredSeenAt = $null
do {
Start-Sleep -Milliseconds 500
$pollText = if (Test-Path -LiteralPath $logPath -PathType Leaf) {
Get-Content -LiteralPath $logPath -Raw -ErrorAction SilentlyContinue
} else { '' }
if (-not $lastRequiredSeenAt -and
$pollText -match "(?m)^PAINT_TRACE_HIT=$lastRequired\s*$") {
$lastRequiredSeenAt = Get-Date
}
$avSeen = $pollText -match '(?i)Access violation|0xc0000005'
$paintAlive = @(Get-Process -Id $paintPid -ErrorAction SilentlyContinue).Count -eq 1
$postHitSettled = $lastRequiredSeenAt -and
((Get-Date) - $lastRequiredSeenAt).TotalSeconds -ge 5
} while (-not $avSeen -and $paintAlive -and -not $postHitSettled -and
(Get-Date) -lt $observeDeadline)
$result.observation_elapsed_seconds = [math]::Round(((Get-Date) - $observeStart).TotalSeconds, 3)
$result.observation_window_exhausted = (Get-Date) -ge $observeDeadline -and
-not $avSeen -and $paintAlive -and -not $postHitSettled
$logText = if (Test-Path -LiteralPath $logPath -PathType Leaf) {
Get-Content -LiteralPath $logPath -Raw -ErrorAction SilentlyContinue
} else { '' }
$hits = [regex]::Matches($logText,'(?m)^PAINT_TRACE_HIT=([a-z0-9_]+)\s*$')
$pidHits = [regex]::Matches($logText,'(?m)^PAINT_TRACE_HIT_PID=([a-z0-9_]+):(\d+)(?=\s|$)')
$warningPidHits = [regex]::Matches($logText,
'(?mi)^PAINT_TRACE_HIT_PID=([a-z0-9_]+):\*\*\* WARNING: Unable to verify checksum for [^\r\n]*\\PaintApp\\[A-Za-z0-9_.]+\.(?:dll|exe)\r?\n(\d+)(?=\s|$)')
$result.markers = @($hits | ForEach-Object { $_.Groups[1].Value })
$pidRows = @(
foreach ($hit in $pidHits) {
[pscustomobject]@{ index=$hit.Index; marker=$hit.Groups[1].Value;
pid=[int]$hit.Groups[2].Value }
}
foreach ($hit in $warningPidHits) {
[pscustomobject]@{ index=$hit.Index; marker=$hit.Groups[1].Value;
pid=[int]$hit.Groups[2].Value }
}
) | Sort-Object index
$result.marker_pid_records = @($pidRows | ForEach-Object {
[ordered]@{ marker=$_.marker; pid=$_.pid }
})
$result.all_marker_pids_match = $result.markers.Count -gt 0 -and
$result.markers.Count -eq $result.marker_pid_records.Count -and
($result.markers -join ',') -ceq
(@($result.marker_pid_records | ForEach-Object { $_.marker }) -join ',') -and
@($result.marker_pid_records | Where-Object { $_.pid -ne $paintPid }).Count -eq 0
$result.paint_pids_after_uri = @(Get-PaintSnapshot)
$expectedPids = if ($HandoffMode -eq 'ExistingPid') { @($paintPid) }
else { @($bootstrapPaintPid,$paintPid) }
$result.extra_paint_pids = @($result.paint_pids_after_uri |
Where-Object { $expectedPids -notcontains $_.pid } | ForEach-Object { $_.pid })
$required = if ($TraceMode -eq 'CrossslotGuard') {
@('author_uri_dispatch','validation_helper_call','validation_sdk_entry',
'bfdb_selected_branch','bfdb_descriptor_pointer','bfdb_strlen_call')
} elseif ($TraceMode -in @('CrossslotNormal','NormalRecord','NormalExtent','R32Normal','R48Normal')) {
@('author_uri_dispatch','validation_helper_call','validation_sdk_entry',
'bfdb_selected_branch','bfdb_descriptor_pointer','bfdb_strlen_call',
'bfdb_strlen_return','bfdb_string_ctor','bfdb_media_memcpy',
'bfdb_memcpy_return','bfdb_result_test')
} elseif ($HeapMode -eq 'Normal') {
@('author_uri_dispatch','validation_helper_call','validation_sdk_entry',
'bfdb_selected_branch','bfdb_descriptor_pointer','bfdb_strlen_call',
'bfdb_strlen_return','bfdb_string_ctor','bfdb_media_memcpy')
} elseif ($TraceMode -eq 'NewReader') {
@('author_uri_dispatch','validation_helper_entry',
'validation_internal_call','validation_net_read_call',
'validation_net_read_entry','bfdb_new_kind9_dispatch',
'bfdb_new_parser_entry','bfdb_new_size_guard',
'bfdb_new_vector_ready','bfdb_new_flag_branch',
'bfdb_new_last_byte','bfdb_new_retained_length',
'bfdb_new_parser_result','validation_net_read_return')
} elseif ($Build -eq 'old') {
@('author_uri_dispatch','validation_helper_call','validation_sdk_entry',
'bfdb_selected_branch','bfdb_descriptor_pointer','bfdb_strlen_call')
} else {
@('author_uri_dispatch','validation_helper_entry',
'validation_net_read_call','validation_net_read_entry')
}
$lastIndex = -1
$orderedReach = $true
foreach ($label in $required) {
$index = [array]::IndexOf([string[]]$result.markers, [string]$label)
if ($index -le $lastIndex) { $orderedReach = $false; break }
$lastIndex = $index
}
$result.required_backend_markers_seen = $orderedReach
$live = @(Get-Process -Id $paintPid -ErrorAction SilentlyContinue)
if ($live.Count -eq 1) {
try {
foreach ($module in $live[0].Modules) {
$expected = $profile.modules.PSObject.Properties[$module.ModuleName]
if (-not $expected) { continue }
$expectedPath = Join-Path $packages[0].InstallLocation (Join-Path 'PaintApp' $module.ModuleName)
$loadedHash = (Get-FileHash -LiteralPath $module.FileName -Algorithm SHA256).Hash.ToLowerInvariant()
$result.loaded_module_checks += [ordered]@{
module=$module.ModuleName; sha256=$loadedHash
matches_signed_package=[bool]($module.FileName -ieq $expectedPath -and
$loadedHash -ceq [string]$expected.Value.sha256)
}
}
} catch {
$result.loaded_module_checks += [ordered]@{ error=$_.Exception.Message }
}
}
$result.cdb_access_violation_text_seen = [bool]($logText -match '(?i)Access violation|0xc0000005')
if ($result.uri_launch_error) {
$result.status = 'review_required'
$result.interpretation = 'URI launch failed; no parser conclusion.'
} elseif ($result.cdb_access_violation_text_seen) {
$result.status = 'review_required'
$result.interpretation = 'Debugger observed first-chance AV text; inspect fault, allocation, route order and PID before an OOB claim.'
} elseif (-not $result.all_marker_pids_match -or $result.extra_paint_pids.Count -gt 0) {
$result.status = 'review_required'
$result.interpretation = 'No complete single-PID checkpoint set; inspect route/PID handling.'
} elseif (-not $result.required_backend_markers_seen) {
$result.status = 'review_required'
$result.interpretation = 'URI or backend checkpoints incomplete; no old/new parser conclusion.'
} elseif ($live.Count -ne 1 -or
@($result.loaded_module_checks | Where-Object {
$_.module -eq 'mspaint.exe' -and $_.matches_signed_package }).Count -ne 1 -or
@($result.loaded_module_checks | Where-Object {
$_.module -eq $(if ($Build -eq 'old') { 'provenancesdk.dll' }
else { 'PaintProvenanceNet.dll' }) -and $_.matches_signed_package }).Count -ne 1) {
$result.status = 'review_required'
$result.interpretation = 'Required loaded module or live signed PID could not be verified.'
} elseif (@($result.loaded_module_checks | Where-Object {
$_.error -or -not $_.matches_signed_package }).Count -gt 0) {
$result.status = 'review_required'
$result.interpretation = 'Loaded module identity could not be verified.'
} elseif ($result.observation_window_exhausted) {
$result.status = 'review_required'
$result.interpretation = 'Bounded 60-second window ended without a conclusive backend outcome.'
} else {
$result.status = 'observed'
$result.interpretation = 'Same-PID checkpoints recorded without CDB AV text in this bounded window; absence of OOB is not proven.'
}
} catch {
$result.status = 'failed'
$result.error = $_.Exception.Message
$result.interpretation = 'Preflight or route failed; no parser claim.'
} finally {
# Preserve the route assessment before a save prompt or debugger-paused
# window requires recorded forced cleanup. A clean route can still be used
# as a control if cleanup has zero residual and no fault evidence.
$result.route_status_before_cleanup = $result.status
# Remove only the debugger registration we added. This precedes closing
# Paint so a UI restart cannot start another CDB. PageHeap remains until
# the process observations and cleanup have completed.
if ($autoDebuggerEnabled) {
try {
if ($HandoffMode -eq 'PlmDebug') {
$disableText = (& $plmdebug /disableDebug $packageFullName 2>&1 | Out-String)
$disableCode = $LASTEXITCODE
$queryText = (& $plmdebug /query $packageFullName 2>&1 | Out-String)
$queryCode = $LASTEXITCODE
$result.auto_debugger_disable = [ordered]@{
mode='PlmDebug'; exit_code=$disableCode
output=$disableText.Trim(); query_exit_code=$queryCode
query_after=$queryText.Trim()
registration_pair_completed=($disableCode -eq 0)
}
# /query reports package running state, not the debugger
# registration count. A successful paired /disableDebug is
# the evidence available in this fresh disposable guest.
$result.auto_debugger_residue = $null
} elseif ($HandoffMode -eq 'IfeoDebugger') {
Remove-ItemProperty -Path $ifeoKey -Name Debugger -ErrorAction Stop
$after = Get-ItemProperty -Path $ifeoKey -Name Debugger -ErrorAction SilentlyContinue
$result.auto_debugger_residue = [bool]($after -and
$after.PSObject.Properties['Debugger'])
$result.auto_debugger_disable = [ordered]@{
mode='IfeoDebugger'; debugger_value_removed=(-not $result.auto_debugger_residue)
}
}
} catch {
$result.auto_debugger_residue = $null
$result.auto_debugger_disable = [ordered]@{
mode=$HandoffMode; error=$_.Exception.Message
}
}
}
# Record all exceptional cleanup. A debugger-paused fault may require a
# forced guest-process stop; it is never described as a normal Paint close.
$initial = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
$requested = @()
foreach ($process in $initial) {
try {
if ($process.MainWindowHandle -ne [IntPtr]::Zero -and $process.CloseMainWindow()) {
$requested += $process.Id
}
} catch { }
}
Start-Sleep -Seconds 4
$cdbBefore = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
foreach ($process in $cdbBefore) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
$remaining = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
foreach ($process in $remaining) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
$cleanupDeadline = (Get-Date).AddSeconds(5)
do {
$paintAfter = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
$cdbAfter = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
if ($paintAfter.Count -eq 0 -and $cdbAfter.Count -eq 0) { break }
Start-Sleep -Milliseconds 250
} while ((Get-Date) -lt $cleanupDeadline)
$result.cleanup = [ordered]@{
paint_initial_pids=@($initial | ForEach-Object { $_.Id })
close_requested_pids=$requested
debugger_forced_pids=@($cdbBefore | ForEach-Object { $_.Id })
paint_forced_pids=@($remaining | ForEach-Object { $_.Id })
paint_remaining_pids=@($paintAfter | ForEach-Object { $_.Id })
debugger_remaining_pids=@($cdbAfter | ForEach-Object { $_.Id })
}
if ($pageheapEnabled) {
$disableText = (& $gflags /p /disable mspaint.exe 2>&1 | Out-String)
$result.pageheap_disable_exit_code = $LASTEXITCODE
[IO.File]::WriteAllText((Join-Path $output 'gflags-disable.txt'),$disableText)
}
try {
$since = ([datetime]$result.started_utc).AddSeconds(-1)
$result.application_error_events = @(
Get-WinEvent -FilterHashtable @{LogName='Application';StartTime=$since;Id=1000,1001} `
-ErrorAction SilentlyContinue |
Where-Object { $_.Message -match '(?i)mspaint\.exe|Microsoft\.Paint' } |
Select-Object -First 20 |
ForEach-Object { [ordered]@{ id=$_.Id; time_utc=$_.TimeCreated.ToUniversalTime().ToString('o') } }
)
} catch { }
$dumpRoot = Join-Path $outputRoot 'dumps'
if (Test-Path -LiteralPath $dumpRoot -PathType Container) {
$result.dump_files = @(Get-ChildItem -LiteralPath $dumpRoot -Filter 'mspaint*.dmp' -File |
Where-Object { $_.LastWriteTimeUtc -ge ([datetime]$result.started_utc).AddSeconds(-1) } |
Select-Object -ExpandProperty Name)
}
if ($result.status -eq 'observed' -and (
@($result.cleanup.paint_forced_pids).Count -gt 0 -or
@($result.cleanup.debugger_forced_pids).Count -gt 0 -or
@($result.application_error_events).Count -gt 0 -or
@($result.dump_files).Count -gt 0 -or
($HandoffMode -eq 'PlmDebug' -and
($result.auto_debugger_disable.exit_code -ne 0 -or
$result.auto_debugger_disable.registration_pair_completed -ne $true)) -or
($HandoffMode -eq 'IfeoDebugger' -and
($result.auto_debugger_residue -ne $false -or
$result.auto_debugger_disable.debugger_value_removed -ne $true)) -or
($HeapMode -eq 'PageHeap' -and $result.pageheap_disable_exit_code -ne 0) -or
($HeapMode -eq 'Normal' -and -not $result.normal_heap_verified))) {
$result.status = 'review_required'
$result.interpretation += ' Cleanup or later fault evidence requires review.'
}
$result.completed_utc = (Get-Date).ToUniversalTime().ToString('o')
$result | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $resultPath -Encoding UTF8
& (Join-Path $env:WINDIR 'System32\shutdown.exe') /s /t 20 /c 'Paint A/B bfdb authoring trial complete'
[ordered]@{
requested_utc=(Get-Date).ToUniversalTime().ToString('o')
method='normal shutdown /s /t 20; no /f'
exit_code=$LASTEXITCODE
trial_status=$result.status
} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (
Join-Path $outputRoot "focus-shutdown-$Build-$runId.json") -Encoding UTF8
}