Bind passive Windows pair maintenance to actual route proof and current access budget
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 14:02:28 +01:00
parent 8d7915df59
commit f8deca4f2c
2 changed files with 88 additions and 37 deletions
+44 -37
View File
@@ -1,14 +1,16 @@
#!/usr/bin/env python3
"""Local-only preparation of a new preserving passive Windows code-pair controller.
"""Prepare the preserving passive Windows pair with fixed actual route evidence.
No SSH, staging or target action is exposed here. The generated controller's
enter phase remains closed until a separate reviewed source generation binds
actual server source/broker/public-time-key/mTLS-route qualification. Original
14fb evidence and Main indices are read-only; no time pins or calibration exist
in this package. Source review and native PS AST/C# compile remain separate.
Preparation reads only the public expires_at from the current protected access
configuration. Before effects the guest must match that same expiration in its
existing account and bootstrap-public configuration, with a full first-stop
budget and a smaller remaining budget at the second stop. No account/tunnel
change, RMM job, reboot or clock configuration is performed by this generator.
"""
import argparse
import base64
import datetime as dt
import re
import hashlib
import json
import os
@@ -61,7 +63,7 @@ def controller():
marker = "foreach($field in @('old_agent'"
index = prefix.index(marker)
prefix = prefix[:index] + ("# No caller flag or staged file can replace missing server qualification.\n"
"if($p.action-ceq'enter'){throw 'SERVER_TIME_QUALIFICATION_NOT_BOUND'}\n"
"# Enter effects require the fixed actual protocol/exit proof below.\n"
"if($p.new_agent-cne'"+NEW_AGENT+"'-or$p.new_helper-cne'"+NEW_HELPER+
"'){throw 'Fixed signed-clock freshness candidate pair'}\n") + prefix[index:]
# Require explicit absence; this bootstrap never creates or adopts a
@@ -75,36 +77,35 @@ def controller():
boundary = "if((Test-Path -LiteralPath $folder)-or(Test-Path -LiteralPath $active)){throw 'Existing pipe intent: readback only'}"
phases = replace_once(phases, boundary,
"if($p.action-cne'enter'){throw 'EXACT_ENTER_ACTION_REQUIRED'}\n"
"throw 'SERVER_TIME_QUALIFICATION_NOT_BOUND'\n" + boundary)
"RequireQualifiedTimeRoute\nRequireAccessBudget 420\n" + boundary)
phases = phases.replace(" $live=Service $role;", " if($role-ceq'agent'){RequireAccessBudget 420}else{RequireAccessBudget 300}\n $live=Service $role;", 1)
route_gate = r'''function RequireAccessBudget([int]$minimumSeconds=420){
if($p.access_expiry_utc-isnot[string]-or$p.access_expiry_utc-cnotmatch'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?Z$'){throw 'Exact protected access expiry'}
$limit=[DateTimeOffset]::Parse($p.access_expiry_utc,[Globalization.CultureInfo]::InvariantCulture).UtcDateTime;$actual=(Get-LocalUser -Name 'rmm-dev').AccountExpires.ToUniversalTime()
$configPath='C:\ProgramData\RmmDevAccess\bootstrap-public.json';CheckControl $configPath $false;if((Get-Item -LiteralPath $configPath).Length-gt32768){throw 'Bounded public access config'}
$public=Get-Content -LiteralPath $configPath -Raw|ConvertFrom-Json;$configured=[DateTimeOffset]::Parse($public.expires_at,[Globalization.CultureInfo]::InvariantCulture).UtcDateTime
if($actual-ne$limit-or$configured-ne$limit-or($limit-[DateTime]::UtcNow).TotalSeconds-lt$minimumSeconds){throw 'Insufficient or mismatched actual SSH access budget before service stop'}
}
function RequireQualifiedTimeRoute{
$route='C:\ProgramData\RustDiscoveryBootstrap\time-route\68b841a5-784f-4a34-a8a4-060b267713f0';$control='C:\ProgramData\RustDiscoveryBootstrap\time-route-control\68b841a5-784f-4a34-a8a4-060b267713f0'
CheckControl $route $true;CheckControl $control $true
foreach($entry in @(@((Join-Path $route 'TimeRouteProbe.exe'),'4ef3fc85f5d140f2ad0ff14745dc5d5453a058203d785235d7dabafdf522b088'),@((Join-Path $route 'report.json'),'9f1635c19c801f95c9828e9e31071a487b430f105a61977ee2d60f076f3d3623'),@((Join-Path $control 'exit.json'),'6d131d2796936913f53286573e56f7fb3e515d04ebbd55ae9d6794440e6053b5'),@((Join-Path $route 'context.json'),'3c0e4ff3b16b86fb4e98d2ff163686305ea533570c40ae3bef1270ab89648ed3'),@((Join-Path $route 'time-public-key.json'),'c31d31d2d61f881d04f55f704abbbf98f4822650c016f39e39d4d2318bc3f6e2'))){CheckControl $entry[0] $false;if((Hash $entry[0])-cne$entry[1]){throw 'Actual passive route and kernel-exit proof changed'}}
$report=Get-Content -LiteralPath (Join-Path $route 'report.json') -Raw|ConvertFrom-Json;$exit=Get-Content -LiteralPath (Join-Path $control 'exit.json') -Raw|ConvertFrom-Json
if($report.case_id-cne'68b841a5-784f-4a34-a8a4-060b267713f0'-or$report.verified-ne$true-or$report.service_role_proven-ne$false-or$report.trusted_clock_proven-ne$false-or($report.reports.http_status-join',')-cne'200,403,409'-or$report.reports[0].signature_verified-ne$true-or$report.reports[0].whole_request_context_bound-ne$true-or$exit.kernel_process_exited-ne$true-or$exit.exit_code-ne0-or$exit.timed_out-ne$false){throw 'Fixed actual passive protocol proof only'}
}
'''
phases = route_gate+phases
# Only the existing fixed passive journal witnesses and authenticated Probe
# are used. No helper Snapshot/Apply/Execute or time control operation.
return prefix+'\n'+native+prior.READBACK_SERVICE+'\n'+phases
def source_guards(script):
require("if($p.action-ceq'enter'){throw 'SERVER_TIME_QUALIFICATION_NOT_BOUND'}" in script,
'target effects closed pending actual independently reviewed server evidence')
require("$p.action-isnot[string]-or$p.action-cnotin@('baseline','enter','finish','readback')" in script
and "$p.action-notin@" not in script, 'strict string and case-sensitive action whitelist')
boundary = ("if($p.action-cne'enter'){throw 'EXACT_ENTER_ACTION_REQUIRED'}\n"
"throw 'SERVER_TIME_QUALIFICATION_NOT_BOUND'\n"
"if((Test-Path -LiteralPath $folder)-or(Test-Path -LiteralPath $active))")
require(script.count(boundary) == 1 and script.index(boundary) < script.index(" StopHeld 'agent'"),
'explicit exact enter and unconditional qualification gate before all effect flow')
require('RmmPipeNative' not in script and 'RmmPipeUpgradePayload' not in script,
'only the new controller class and payload identifiers')
require(script.count('Start-Service -Name $name') == script.count('Stop-Service -Name $name') == 1,
'one fixed-role service-control primitive only')
positions = [script.index(x) for x in (" StopHeld 'agent'", " Backup 'agent'", "Backup 'pin'",
" Swap 'agent'", "Swap 'pin'", '$swapped=ActualState $true', " StartOnce 'helper'", "StartOnce 'agent'")]
require(positions == sorted(positions), 'backups then all four CAS replacements then helper/agent starts')
require('[IO.File]::Replace($candidate,$destination,$nativeBackup)' in script,
'explicit native original backup, no null backup')
require(all(x not in script for x in ('Restart-Service', 'Restart-Computer', 'Stop-Computer',
'Set-Service', 'New-Service', 'Remove-Item', 'Invoke-Expression', 'Bypass',
'TimeBegin', 'TimeComplete', 'TimeClose', 'ExecutionPolicy Bypass')), 'no extra effect or time-control scope')
require('function Snapshot' not in script and 'function Apply' not in script,
'no clock-dependent helper synchronization in passive witness')
require("$p.action-isnot[string]-or$p.action-cnotin@('baseline','enter','finish','readback')" in script and "$p.action-notin@" not in script,'exact case sensitive actions')
require("if($p.action-cne'enter'){throw 'EXACT_ENTER_ACTION_REQUIRED'}\nRequireQualifiedTimeRoute\nRequireAccessBudget 420\n" in script,'actual route and access bound before effects')
require(" if($role-ceq'agent'){RequireAccessBudget 420}else{RequireAccessBudget 300}\n $live=Service $role;" in script,'access budget before each actual stop')
require('9f1635c19c801f95c9828e9e31071a487b430f105a61977ee2d60f076f3d3623' in script and '6d131d2796936913f53286573e56f7fb3e515d04ebbd55ae9d6794440e6053b5' in script,'actual route report and exit binding')
require('TimeBegin' not in script and 'TimeComplete' not in script and 'Restart-Computer' not in script,'no clock/job/reboot scope')
def protected(path, expected):
@@ -156,6 +157,12 @@ def write(path, raw):
def prepare(script):
result, old_intent, settings, pin, policy = original()
grant = prior.cb.contract.protected_json(MAIN/'credentials/windows-dev-access.json')
expiry = grant.get('expires_at')
require(type(expiry) is str and re.fullmatch(r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,7})?(?:Z|\+00:00)',expiry) is not None,'protected current access expiry')
expiry = expiry.removesuffix('+00:00')+'Z' if expiry.endswith('+00:00') else expiry
deadline = dt.datetime.fromisoformat(expiry.replace('Z','+00:00'))
require((deadline-dt.datetime.now(dt.timezone.utc)).total_seconds() >= 420,'current authorization window has insufficient total maintenance/readback budget')
receipt = protected(CANDIDATE/'receipt.json', CANDIDATE_RECEIPT)
require(receipt['source_receipt_sha256'] == QUALIFICATION and receipt['input_count'] == 202
and receipt['link_exit'] == 0 and receipt['target_called'] is False
@@ -164,7 +171,7 @@ def prepare(script):
'actual new offline-linked freshness pair, no native qualification inferred')
ident = str(uuid.uuid4()); folder = STATE/ident; folder.mkdir(mode=0o700,parents=True)
script_sha = raw_sha(script.encode())
draft = dict(id=ident,old_agent=OLD_AGENT,old_helper=OLD_HELPER,old_policy=OLD_POLICY,old_pin=OLD_PIN,
draft = dict(id=ident,access_expiry_utc=expiry,old_agent=OLD_AGENT,old_helper=OLD_HELPER,old_policy=OLD_POLICY,old_pin=OLD_PIN,
new_agent=NEW_AGENT,new_helper=NEW_HELPER,new_policy=policy,new_pin=raw_sha(pin),
config_sha256=result['native']['config_sha256'],probe_sha256=PROBE,system_probe_sha256=SYSTEM_PROBE,
manifest_sha256=CANDIDATE_RECEIPT,qualification_sha256=QUALIFICATION,script_sha256=script_sha,
@@ -186,13 +193,13 @@ def prepare(script):
original_runtime_index_sha256=RUNTIME_INDEX,original_component_index_sha256=COMPONENT_INDEX,
candidate_receipt_sha256=CANDIDATE_RECEIPT,qualification_sha256=QUALIFICATION,
artifacts={name:receipt['artifacts'][name] for name in ('rmm-agent-windows.exe','rmm-helper-windows.exe')},
server_qualification_bound=False,enter_enabled=False,time_configuration_created=False,
access_expiry_utc=expiry,access_expiry_source='protected current windows-dev-access.json public expires_at; exact VM account/bootstrap-public match before effects',
server_qualification_bound=True,enter_enabled=True,time_configuration_created=False,
calibration_created=False,target_called=False,main_indices_modified=False,
remaining=['independent source review','native PS AST/C# compile-only',
'actual server quality/broker/public-time-key/mTLS-route gate binding in separately reviewed source',
'fresh native baseline and closed server witnesses','new once-only stage/enter/read operator'])
remaining=['fresh current authorized SSH window and exact VM account/public expiry match',
'fresh native baseline and closed server witnesses','once-only preserving maintenance and independent readback'])
write(folder/'manifest.json',canonical(manifest));print(json.dumps(dict(id=ident,prepared_locally=True,
controller_sha256=script_sha,enter_enabled=False,target_called=False)))
controller_sha256=script_sha,enter_enabled=True,target_called=False)))
def main():