diff --git a/deploy/windows_system_job_bootstrap.py b/deploy/windows_system_job_bootstrap.py index 03dd359..a4ae0c6 100644 --- a/deploy/windows_system_job_bootstrap.py +++ b/deploy/windows_system_job_bootstrap.py @@ -220,6 +220,7 @@ def main(): # by this module's CLI. Both existing daemons must already be quiescent/stopped; # starts and fresh signed-sync/native effect acceptance remain separate steps. APPLY_STOPPED = r''' +param([switch]$ResumeNoEffectEb285544) $ErrorActionPreference='Stop' $p=([Console]::In.ReadLine()|ConvertFrom-Json) if($p.operation-cne'windows_system_script_scope_stopped_v1'-or$p.phase-cnotin@('apply-stopped','readback')){throw 'Fixed bootstrap operation'} @@ -235,7 +236,7 @@ function CheckPath([string]$path,[bool]$directory){$item=Get-Item -LiteralPath $ function CheckStopped{if($null-eq$p.expected_service_processes-or@($p.expected_service_processes).Count-ne2){throw 'Two actual original process witnesses required'};foreach($old in @($p.expected_service_processes)){if([int]$old.pid-le0-or![string]$old.creation_filetime){throw 'Original kernel creation witness'};$live=Get-Process -Id ([int]$old.pid) -ErrorAction SilentlyContinue;if($null-ne$live){try{if($live.StartTime.ToUniversalTime().ToFileTimeUtc().ToString()-ceq$old.creation_filetime-and!$live.HasExited){throw 'Original service process still live'}}finally{$live.Dispose()}}};foreach($name in @('RmmDiscoveryWindows','RmmDiscoverySystemHelper')){$service=Get-CimInstance Win32_Service -Filter ("Name='"+$name+"'");if(!$service-or$service.State-cne'Stopped'){throw 'Coordinated quiescent pair stop required'}}} function PublicAcl{$acl=New-Object Security.AccessControl.FileSecurity;$acl.SetSecurityDescriptorSddlForm(('O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;'+$agentSid+')(A;;0x1200a9;;;'+$helperSid+')'));return $acl} function WritePublicOnce([string]$path,[byte[]]$bytes){ - $rights=[Security.AccessControl.FileSystemRights]::ReadWrite + $rights=[Security.AccessControl.FileSystemRights]([int][Security.AccessControl.FileSystemRights]::Read-bor[int][Security.AccessControl.FileSystemRights]::Write) $stream=New-Object IO.FileStream($path,[IO.FileMode]::CreateNew,$rights,[IO.FileShare]::Read,4096,[IO.FileOptions]::WriteThrough,(PublicAcl)) try{$stream.Write($bytes,0,$bytes.Length);$stream.Flush($true)}finally{$stream.Dispose()} $null=CheckPath $path $false @@ -285,6 +286,17 @@ function PreservedFiles { } return ($result|ConvertTo-Json -Depth 8 -Compress) } +function CheckExactNoEffectResume { + if(!$ResumeNoEffectEb285544-or$caseId-cne'eb285544-3714-43e4-872e-5e43b75b9794'){throw 'Only the reviewed no-effect case can resume'} + $null=CheckPath $case $true + $leaves=@(Get-ChildItem -LiteralPath $case -Force) + if($leaves.Count-ne1-or$leaves[0].Name-cne'intent.json'-or$leaves[0].PSIsContainer){throw 'Only untouched original intent permits resume'} + $original=Join-Path $case 'intent.json';$null=CheckPath $original $false + $expected='4c3019b04a92dd080590d4b157b7c975f26ae9874b29c6f0dcd75c36d35d9ef5' + if((HashFile $original)-cne$expected-or(HashBytes ([Text.Encoding]::UTF8.GetBytes(($p|ConvertTo-Json -Depth 20 -Compress))))-cne$expected){throw 'Exact original intent bytes required'} + if($p.old_settings_sha256-cne'3902a7d61829e6959442c9577e025e28262edbb87a0ac4ffd76565ee241ec754'-or$p.old_pin_sha256-cne'4e098eb3d18cceba81627d0d18c52f45521c9384c1412225f0628835f8fb82ca'-or$p.old_config_sha256-cne'5cd4cb9802d0dd20b961de7e3cd4e5874a1e9a72fc57b577e075e2d2918baac6'){throw 'Original no-effect control bytes required'} + if((HashFile 'C:\ProgramData\RustDiscoverySystem\time-attestation.json')-cne'04cc3b58ab233715fa0abf118b8af6a5518fe3fcee7a5b6a7c79e09b19495d28'){throw 'Original no-effect clock profile required'} +} $null=CheckPath 'C:\ProgramData\RustDiscoveryBootstrap' $true $null=CheckPath $helperRoot $true if($p.phase-ceq'readback'){ @@ -298,11 +310,12 @@ $definitions=ServiceDefinitions if($p.helper_start_transition.before-cne'Manual'-or$p.helper_start_transition.after-cne'Auto'-or$definitions.RmmDiscoverySystemHelper.start_mode-cne'Manual'-or$definitions.RmmDiscoveryWindows.start_mode-cne'Auto'){throw 'Exact Manual to Auto helper transition only'} if((HashFile 'C:\ProgramData\RustDiscovery\config.json')-cne$p.old_config_sha256){throw 'Preserved active configuration CAS'} $locks=[RmmSystemScopeLocks]::new() +$recordFailure=$false;$stage='original-preflight' try { $lockIds=($locks.LockIds()-join',');$preserved=PreservedFiles $null=CheckPath $targets.settings $false $null=CheckPath $targets.pin $false -if(Test-Path -LiteralPath $case){throw 'Existing case means readback only'} +if($ResumeNoEffectEb285544){CheckExactNoEffectResume}elseif(Test-Path -LiteralPath $case){throw 'Existing case means readback only'} foreach($name in @('native_result','qualification')){if(Test-Path -LiteralPath $targets[$name]){throw 'First script scope requires absent prior qualification files'}} if((HashFile $targets.settings)-cne$p.old_settings_sha256-or(HashFile $targets.pin)-cne$p.old_pin_sha256){throw 'Fresh original public settings and pin CAS'} if((HashFile 'C:\Program Files\RustDiscovery\rmm-agent-windows.exe')-cne$p.agent_binary_sha256-or(HashFile 'C:\Program Files\RustDiscovery\rmm-helper-windows.exe')-cne$p.helper_binary_sha256){throw 'Actual image pair required'} @@ -316,11 +329,22 @@ if($next.agent.binary_sha256-cne$p.agent_binary_sha256-or$next.helper.binary_sha $qualification=[Text.Encoding]::UTF8.GetString($payloads.qualification)|ConvertFrom-Json $native=[Text.Encoding]::UTF8.GetString($payloads.native_result)|ConvertFrom-Json if(($qualification.actions-join',')-cne'run_script'-or$qualification.policy_sha256-cne$p.policy_sha256-or$qualification.native_result_sha256-cne$p.files.native_result.sha256-or$native.scope-cne'native_prerequisites_only'-or$native.target_job_executed-ne$false-or$native.status-cne'passed'){throw 'Truthful prerequisite qualification only'} -New-Item -ItemType Directory -Path $case|Out-Null -$private=New-Object Security.AccessControl.DirectorySecurity;$private.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)');Set-Acl -LiteralPath $case -AclObject $private -WritePrivateOnce (Join-Path $case 'intent.json') ([Text.Encoding]::UTF8.GetBytes(($p|ConvertTo-Json -Depth 20 -Compress))) +$stage='create-or-resume-intent' +if($ResumeNoEffectEb285544){ + CheckExactNoEffectResume + $recordFailure=$true + WritePrivateOnce (Join-Path $case 'resume-no-effect-intent.json') ([Text.Encoding]::UTF8.GetBytes('{"schema_version":1,"case_id":"eb285544-3714-43e4-872e-5e43b75b9794","original_intent_sha256":"4c3019b04a92dd080590d4b157b7c975f26ae9874b29c6f0dcd75c36d35d9ef5","reason":"invalid_FileSystemRights_ReadWrite_enum_before_first_candidate","repeat_allowed":false}')) +}else{ + New-Item -ItemType Directory -Path $case|Out-Null + $private=New-Object Security.AccessControl.DirectorySecurity;$private.SetSecurityDescriptorSddlForm('O:BAG:BAD:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)');Set-Acl -LiteralPath $case -AclObject $private + $recordFailure=$true + WritePrivateOnce (Join-Path $case 'intent.json') ([Text.Encoding]::UTF8.GetBytes(($p|ConvertTo-Json -Depth 20 -Compress))) +} +WritePrivateOnce (Join-Path $case 'preserved-before-files.json') ([Text.Encoding]::UTF8.GetBytes($preserved)) +$stage='public-candidates' foreach($name in @('settings','pin','native_result','qualification')){WritePublicOnce (Join-Path $case ($name+'.candidate.json')) $payloads[$name]} foreach($name in @('settings','pin')){ + $stage='replace-'+$name CheckStopped $expected=if($name-ceq'settings'){$p.old_settings_sha256}else{$p.old_pin_sha256} if((HashFile $targets[$name])-cne$expected){throw 'Immediate original file CAS'} @@ -331,6 +355,7 @@ foreach($name in @('settings','pin')){ $null=CheckPath $targets[$name] $false } foreach($name in @('native_result','qualification')){ + $stage='publish-'+$name CheckStopped if(Test-Path -LiteralPath $targets[$name]){throw 'Public prerequisite target appeared'} WritePrivateOnce (Join-Path $case ($name+'-publish-intent.json')) ([Text.Encoding]::UTF8.GetBytes('{"create_once":true}')) @@ -339,16 +364,23 @@ foreach($name in @('native_result','qualification')){ $null=CheckPath $targets[$name] $false } CheckStopped +$stage='helper-autostart' $current=ServiceDefinitions if(($current|ConvertTo-Json -Depth 6 -Compress)-cne($definitions|ConvertTo-Json -Depth 6 -Compress)){throw 'SCM changed before helper Automatic transition'} WritePrivateOnce (Join-Path $case 'helper-autostart-intent.json') ([Text.Encoding]::UTF8.GetBytes('{"from":"Manual","to":"Auto","no_start":true}')) [RmmSystemScopeLocks]::SetHelperAutomatic() $automatic=ServiceDefinitions if($automatic.RmmDiscoverySystemHelper.start_mode-cne'Auto'-or$automatic.RmmDiscoveryWindows.start_mode-cne'Auto'){throw 'Actual automatic startup readback'} +$stage='final-preservation' if((PreservedFiles)-cne$preserved-or($locks.LockIds()-join',')-cne$lockIds){throw 'Original identities, journals, clock profile and locks must be preserved'} $result=@{schema_version=1;files_installed=$true;services_started=$false;target_job_executed=$false;approval_performed=$false;state_or_keys_changed=$false;helper_autostart='Auto';services=$automatic;policy_sha256=$p.policy_sha256;next='root must refresh actual SCM/role/time qualification then start pair once and verify fresh signed clock/sync; first actual SYSTEM job requires WebUI approval'} WritePrivateOnce (Join-Path $case 'completed.json') ([Text.Encoding]::UTF8.GetBytes(($result|ConvertTo-Json -Compress))) $result|ConvertTo-Json -Compress +} catch { + $failure=@{schema_version=1;error_code='SYSTEM_SCRIPT_SCOPE_BOOTSTRAP_FAILED';stage=$stage;exception_type=$_.Exception.GetType().FullName;hresult=$_.Exception.HResult;repeat_allowed=$false} + if($recordFailure){try{$errorPath=Join-Path $case 'bootstrap-error.json';if(!(Test-Path -LiteralPath $errorPath)){WritePrivateOnce $errorPath ([Text.Encoding]::UTF8.GetBytes(($failure|ConvertTo-Json -Compress)))}}catch{}} + $failure|ConvertTo-Json -Compress + throw 'SYSTEM_SCRIPT_SCOPE_BOOTSTRAP_FAILED' } finally {$locks.Dispose()} ''' diff --git a/docs/evidence/windows-system-filestream-no-effect-20261116.json b/docs/evidence/windows-system-filestream-no-effect-20261116.json new file mode 100644 index 0000000..c7ace9a --- /dev/null +++ b/docs/evidence/windows-system-filestream-no-effect-20261116.json @@ -0,0 +1,119 @@ +{ + "schema_version": 1, + "scope": "isolated_constructor_probe_and_original_case_readonly", + "product_apply_executed": false, + "existing_case_changed": false, + "source_controller_sha256": "1be22f76d2be3dab1e3c696ab5e30f1e71b1f86fa2979d8fd55d820bee87a70a", + "reports": [ + { + "name": "filestream-constructors-readonly.json", + "original_sha256": "daf3934a2ea4af06fcd7d20cf091e72ad026c60dd5cab4ec2bba03f256e4f75b", + "result": { + "read_only": true, + "constructors": [ + "System.String,System.IO.FileMode", + "System.String,System.IO.FileMode,System.IO.FileAccess", + "System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare", + "System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.Int32", + "System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.Int32,System.IO.FileOptions", + "System.String,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.Int32,System.Boolean", + "System.String,System.IO.FileMode,System.Security.AccessControl.FileSystemRights,System.IO.FileShare,System.Int32,System.IO.FileOptions,System.Security.AccessControl.FileSecurity", + "System.String,System.IO.FileMode,System.Security.AccessControl.FileSystemRights,System.IO.FileShare,System.Int32,System.IO.FileOptions", + "System.IntPtr,System.IO.FileAccess", + "System.IntPtr,System.IO.FileAccess,System.Boolean", + "System.IntPtr,System.IO.FileAccess,System.Boolean,System.Int32", + "System.IntPtr,System.IO.FileAccess,System.Boolean,System.Int32,System.Boolean", + "Microsoft.Win32.SafeHandles.SafeFileHandle,System.IO.FileAccess", + "Microsoft.Win32.SafeHandles.SafeFileHandle,System.IO.FileAccess,System.Int32", + "Microsoft.Win32.SafeHandles.SafeFileHandle,System.IO.FileAccess,System.Int32,System.Boolean" + ], + "ps_version": "5.1.26100.9818", + "framework": "v4.0.30319", + "read_write_rights": 0 + } + }, + { + "name": "filestream-constructor-native-probe.json", + "original_sha256": "0b38cb0d3ebe37b7682eaa9c103564f9f68efa9da1d6b67ca8ad38560bde1bb7", + "result": { + "isolated_private_probe_only": true, + "services_changed": false, + "schema_version": 1, + "case_id": "9aa10ac4-8378-4878-a292-85368beb7391", + "results": [ + { + "file_created": false, + "error_id": "ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand", + "rights": 0, + "exceptions": [ + { + "type": "System.Management.Automation.MethodException", + "hresult": -2146233087 + } + ], + "success": false, + "variant": "old_invalid_enum" + }, + { + "variant": "valid_read_or_write", + "rights": 131487, + "bytes": 12, + "success": true + } + ], + "product_paths_changed": false + } + }, + { + "name": "no-effect-resume-readonly.json", + "original_sha256": "30f61d045ad2d98d1aa1df5120fe6484e092ced40d7371e33a443aab6deb01e5", + "result": { + "settings_sha256": "3902a7d61829e6959442c9577e025e28262edbb87a0ac4ffd76565ee241ec754", + "time_profile_sha256": "04cc3b58ab233715fa0abf118b8af6a5518fe3fcee7a5b6a7c79e09b19495d28", + "case_id": "eb285544-3714-43e4-872e-5e43b75b9794", + "intent_sha256": "4c3019b04a92dd080590d4b157b7c975f26ae9874b29c6f0dcd75c36d35d9ef5", + "read_only": true, + "config_sha256": "5cd4cb9802d0dd20b961de7e3cd4e5874a1e9a72fc57b577e075e2d2918baac6", + "pin_sha256": "4e098eb3d18cceba81627d0d18c52f45521c9384c1412225f0628835f8fb82ca", + "leaves": [ + "intent.json" + ], + "services": [ + { + "Name": "RmmDiscoverySystemHelper", + "State": "Stopped", + "StartMode": "Manual" + }, + { + "Name": "RmmDiscoveryWindows", + "State": "Stopped", + "StartMode": "Auto" + } + ] + } + }, + { + "name": "no-effect-resume-byte-check.json", + "original_sha256": "b5d52a2f7c201476b07d6a1106df357fbe560c71199343cb7e71657b5218acc9", + "result": { + "read_only": true, + "probe_owner": "S-1-5-32-544", + "probe_bytes": 12, + "probe_sddl": "O:BAG:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;0x1200a9;;;S-1-5-80-1378800304-2783697212-3564778230-1646893514-1341434273)(A;;0x1200a9;;;S-1-5-80-2738667961-1084496008-3886777835-2738042298-1934696263)", + "serialized_original_intent_sha256": "4c3019b04a92dd080590d4b157b7c975f26ae9874b29c6f0dcd75c36d35d9ef5", + "exact_original_intent_matches": true + } + }, + { + "name": "no-effect-resume-ast.json", + "original_sha256": "a2c2dbd9a1171042c71de633db26c9a0d2aa8f8bedf33c297fc7fb5d9e22ce06", + "result": { + "schema_version": 1, + "product_changes": false, + "source_sha256": "b7fc58ff28ad02324719a0a813522531eb89a08ad6fd95f6cad67a405308d998", + "source_executed": false, + "syntax_errors": [] + } + } + ] +} diff --git a/docs/windows-system-first-job-plan.md b/docs/windows-system-first-job-plan.md index c097500..d2829c5 100644 --- a/docs/windows-system-first-job-plan.md +++ b/docs/windows-system-first-job-plan.md @@ -129,6 +129,47 @@ wirkungslose Probe lief tatsächlich. Kein SDK-/Dienst-/Policy-/Datei-Apply folgte daraus. Öffentlicher Beleg: [Prädikatsprüfung](evidence/windows-system-optional-msi-predicate-20261116.json). +Der erste spätere tatsächliche Apply-Aufruf durch den koordinierenden Rootagenten +verlor seine Textantwort wegen einer Decodierungsstörung. Er wurde nicht +wiederholt. Der anschließende tatsächliche Readback bestätigte ausschließlich +`intent.json` im Fall eb285544; Settings3902, Pin4e098, Konfiguration5cd, +Zeitprofil04cc3b58 blieben erhalten, beide Qualifikationsziele fehlten weiterhin, +Helper Manual und beide RMM-Dienste gestoppt. Es war noch kein Kandidat +publiziert oder installiert worden. + +Die enge Ursachenprüfung auf Windows ermittelte: Der siebenparametrige +FileStream-Konstruktor ist vorhanden, aber `FileSystemRights.ReadWrite` ist kein +Enumwert. PowerShell lieferte null beziehungsweise als Integer0. In einem +eigenen privaten Probeordner scheiterte exakt diese alte Konstruktion vor +Dateianlage. `FileSystemRights.Read -bor FileSystemRights.Write` lieferte131487; +derselbe Konstruktor erzeugte und flushte12 öffentliche Probebytes. Tatsächlicher +Owner/DACL entsprachen dem beabsichtigten atomaren Verfahren: BA-Owner, +geschützte DACL, SYSTEM/Administratoren FullControl und beide echten Service-SIDs +ReadAndExecute. Das atomare Anlegen mit FileSecurity bleibt erhalten; kein +alternativer ungeschützter Dateischreibpfad wurde eingeführt. + +Die neue, **noch nicht ausgeführte** Fortsetzung verlangt ausdrücklich +`-ResumeNoEffectEb285544` und ausschließlich den unveränderten Fall +`eb285544-3714-43e4-872e-5e43b75b9794`. Ohne Schalter verweigert ein bestehender +Fall weiterhin jede Anwendung. Nur ein einziges vorhandenes `intent.json`, dessen +rohe SHA256 und die identische erneute PS-Serialisierung des Originalpayloads +`4c3019b04a92dd080590d4b157b7c975f26ae9874b29c6f0dcd75c36d35d9ef5` +müssen übereinstimmen; dazu die festen ursprünglichen Dateien, Schema1/effectsfalse, +Images, Konfiguration, Zeitprofil, beide gestoppten Rollen und ursprünglichen +Lebensdauersperren. Der Bytevergleich mit der tatsächlich gestagten b9a-Datei +bestand nativ lesend. Jede zusätzliche Datei oder Zieländerung verweigert diese +Fortsetzung. Sie erhält das alte Intent unverändert und legt vor Kandidaten +einen neuen einmaligen Resumeintent und einen tatsächlichen +Preservation-Metadatenbeleg an. Es gibt keinen allgemeinen Wiederholungsmodus. + +Künftige Fehler nach Eintritt hinterlassen einen create-only ASCII-Fehlerbeleg +mit festem Code, Phase, Exceptiontyp und HResult, ohne Fehlermeldungsinhalt oder +Geheimnisse. Sie lösen weder Retry noch automatisches Zurücksetzen aus. Der +vollständige neue Quelltext bestand den tatsächlichen PS5.1-AST-Parser mit null +Fehlern; er wurde dabei ausschließlich im Speicher dekomprimiert/geparst, nicht +ausgeführt. Öffentlicher enger Nachweis: +[Konstruktorprobe und ursprünglicher wirkungsloser Fall](evidence/windows-system-filestream-no-effect-20261116.json). + ## Tatsächlich lesend geprüft Der bestehende bestätigte SSH-Entwicklungstransport wurde mit