Verify original server signatures for the two Windows checkpoints
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-15 22:35:29 +01:00
parent ee6a25614f
commit 9954c9ba3f
2 changed files with 131 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
#!/usr/bin/env python3
"""Read the two historical Windows sync decisions and verify their original signatures."""
import hashlib
import json
import subprocess
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
import cloud_mvp_acceptance as cloud
BOOT = 'a9ad0895-5a96-8f2c-8fb6-cfdc2d5225ea'
BINDING = '9239ee9f4142735867e77451478bf309fbf449d730a0ede6c958bc8018830dde'
HISTORY = (
(6755, '1418b4a3-8370-404d-b29a-920ba9f0f4d7', 'b6a3101f-68ad-41c8-be4e-4c7c2bc963d6', True, 'CONSISTENT'),
(6756, '9eba037c-825f-4a96-be14-cca130c1e83d', '0633a4de-7e52-4e5d-a2a1-59fb134817fe', False, 'HELPER_CHECKPOINT_REQUIRED'),
)
def read_server(_payload):
# This function is transported by the existing pinned SSH bootstrap adapter.
import subprocess
query = """
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ READ ONLY;
SET LOCAL statement_timeout='5s';
WITH device AS (
SELECT * FROM agent_installations WHERE tenant_id='11111111-1111-4111-8111-111111111111'
AND agent_id='63ea15b2-0643-403d-b5b4-cba1288dbea3'
), history AS (
SELECT c.* FROM sync_checkpoints c JOIN device USING (tenant_id,agent_id)
), target_jobs AS (
SELECT j.* FROM jobs j JOIN device USING (tenant_id,agent_id)
)
SELECT json_build_object(
'observed_at', now(),
'device', (SELECT json_build_object('asset_id',asset_id,'agent_id',agent_id,'tenant_id',tenant_id,
'enrollment_generation',enrollment_generation,'assignment_version',assignment_version,
'connection_generation',connection_generation,'boot_id',connection_boot_id,
'certificate_sha256',certificate_sha256,'capabilities',capabilities,'sync_required',sync_required,
'restore_blocked',restore_blocked,'sequence_regressed',sequence_regressed,
'sync_recovery_required',sync_recovery_required,'revoked',revoked_at IS NOT NULL)
FROM device),
'head', (SELECT row_to_json(s) FROM agent_sync_state s JOIN device d
ON s.tenant_id=d.tenant_id AND s.agent_id=d.agent_id),
'history_count', (SELECT count(*) FROM history),
'history', (SELECT json_agg(row_to_json(r) ORDER BY r.checkpoint) FROM
(SELECT request_id, decision_id, request_hash, checkpoint, journal_id, connection_generation,
encode(payload,'hex') AS payload, encode(signature,'hex') AS signature
FROM history WHERE checkpoint IN (6755,6756) AND octet_length(payload) <= 32768
AND octet_length(signature)=64 ORDER BY checkpoint LIMIT 3) r),
'jobs', (SELECT count(*) FROM target_jobs),
'outbox', (SELECT count(*) FROM outbox JOIN target_jobs USING (tenant_id,job_id,attempt_id)),
'permits', (SELECT count(*) FROM execution_permits JOIN target_jobs USING (tenant_id,job_id,attempt_id))
); COMMIT;
"""
result = subprocess.run(['docker', 'exec', '-i', 'rust-discovery-server-postgres-1', 'psql',
'-X', '-qAt', '-v', 'ON_ERROR_STOP=1', '-U', 'postgres', '-d', 'rmm'],
input=query.encode(), capture_output=True, check=True, timeout=10)
return json.loads(result.stdout)
def verify(report, binding):
require = cloud.require
binding_digest = hashlib.sha256(json.dumps(binding, sort_keys=True, separators=(',', ':')).encode()).hexdigest()
require(binding_digest == BINDING, 'existing Windows verification binding changed')
key = bytes.fromhex(binding['public_key_hex'])
public = Ed25519PublicKey.from_public_bytes(key)
key_id = hashlib.sha256(key).hexdigest()
device = report['device']
identity = {k: binding[k] for k in ('tenant_id', 'agent_id', 'asset_id', 'enrollment_generation', 'assignment_version')}
require(all(device[k] == v for k, v in identity.items()) and device['boot_id'] == BOOT
and device['connection_generation'] > 150 and device['revoked'] is False
and device['restore_blocked'] is True and device['sequence_regressed'] is False
and device['sync_recovery_required'] is False and device['sync_required'] is False
and sorted(device['capabilities']) == ['agent.update/1', 'heartbeat/1', 'windows.base/1'],
'expected passive device and active restore block')
require(device['certificate_sha256'] == 'c55aa8214cb8d60382fe453bddd56c6e46fa79b61ccefda502e001be56bb5075',
'device certificate changed')
require(report['history_count'] == 2 and len(report['history']) == 2 and
all(report[k] == 0 for k in ('jobs', 'outbox', 'permits')), 'history or execution artifacts changed')
head = report['head']
require(head['tenant_id'] == identity['tenant_id'] and head['agent_id'] == identity['agent_id']
and head['decision_id'] == HISTORY[0][2] and head['checkpoint'] == HISTORY[0][0]
and head['helper_checkpoint'] == 1 and head['helper_journal_id'], 'server head changed')
evidence = []
for row, (checkpoint, request_id, decision_id, ready, reason) in zip(report['history'], HISTORY, strict=True):
raw, signature = bytes.fromhex(row['payload']), bytes.fromhex(row['signature'])
public.verify(signature, raw)
d = json.loads(raw)
require(d['domain'] == 'rmm.reconciliation-decision' and d['schema_version'] == 1
and all(d[k] == v for k, v in identity.items()) and d['key_id'] == key_id
and d['boot_id'] == BOOT and d['connection_generation'] == row['connection_generation'] == 150
and d['checkpoint'] == row['checkpoint'] == checkpoint and d['helper_checkpoint'] == 1
and d['journal_id'] == row['journal_id'] == head['journal_id']
and d['helper_journal_id'] == head['helper_journal_id']
and d['request_id'] == row['request_id'] == request_id and d['request_hash'] == row['request_hash']
and d['decision_id'] == row['decision_id'] == decision_id and d['reason'] == reason
and d['ready'] is ready and d['helper_ready'] is ready and d['attempts'] == [],
'signed decision differs from stored Windows case')
evidence.append(dict(checkpoint=checkpoint, request_id=request_id, decision_id=decision_id,
request_sha256=d['request_hash'], payload_sha256=hashlib.sha256(raw).hexdigest(),
signature_sha256=hashlib.sha256(signature).hexdigest(), issued_at=d['issued_at'],
reason=reason, original_signature_verified=True))
return {**{k: report[k] for k in ('observed_at', 'device', 'head', 'history_count', 'jobs', 'outbox', 'permits')},
'verification_key_id': key_id, 'decisions': evidence, 'read_only': True}
if __name__ == '__main__':
binding_path = cloud.ROOT / 'devstate/windows-client/system-helper-public-binding.json'
binding = json.loads(binding_path.read_bytes())
result = verify(cloud.bootstrap.rpc('server.conf', read_server, {}), binding)
print(json.dumps(result, sort_keys=True, indent=2))
+19
View File
@@ -364,3 +364,22 @@ Helper-SHA-256
`19c7f53ef168d7128674464c721d9eaf77fce60a53682889600f13e470f45faa`.
Der installierte passive Dienst verwendet weiterhin den in der
ursprünglichen Zeitprofilprüfung nachgewiesenen Build.
### Lesende Prüfung der gespeicherten Originalsignaturen
Am 15. November um 21:35:08 UTC wurden die zwei ursprünglichen signierten
Entscheidungen auf dem Projektserver in einer einzigen lesenden
PostgreSQL-Transaktion erfasst. Der Prüfer verglich sie mit der bereits
vor dem Vorfall gebundenen öffentlichen Geräte-/Jobkonfiguration und
verifizierte beide Ed25519-Signaturen über die Originalbytes.
Schlüsselkennung `4338aabe7e7ba77428e969750a7a5323d7b7349aa52ef7e1a5f24c90be12ca7a`.
| Checkpoint | SHA-256 der Entscheidungsbytes | SHA-256 der Originalsignatur |
| --- | --- | --- |
| 6755 | `5806d49eed772c4f460ddb97388e8a51ec19df705ac2a55e54114a382aef62f3` | `f6cbfee524e287e59130220f33a4e6f3469ee1a817e69235560e7a53f4cc6d6e` |
| 6756 | `c6ad2a8016a2b2997f934ad5e2daabc1d585b45d07b94d7d4ed146a10ed303f3` | `96caf5401915ca4f8f28ee21ecb8dbfdc3d705c3b89bd40160ff15dbb75a2d08` |
Beide Entscheidungen betreffen dieselbe Geräteidentität, Boot-ID und
Verbindung 150. Beide enthalten null Jobversuche. Der mit den
Ausführungszählern erfasste Prüfbeleg hat SHA-256
`7ad17c48c74638a015bb62caae16365c6ff44a70f3b1a5a7357b28de7686b3da`.