Preserve native timestamp precision in passive time closeout
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 16:09:21 +01:00
parent 44f65c205b
commit cdcdb36c13
4 changed files with 52 additions and 12 deletions
+17 -9
View File
@@ -22,6 +22,7 @@ FIELDS = {'schema_version', 'agent_pid', 'observed_at', 'role', 'windows_boot_id
'connection_generation', 'verifier_incarnation', 'request_sha256', 'response_sha256'}
FILES = {'agent': 'agent-time-sample.json', 'system_helper': 'helper-time-sample.json'}
HEX = re.compile(r'[0-9a-f]{64}')
SECOND_NS = 1_000_000_000
# No report is requested from a service. The only content reads on the guest
# are these two public JSONs and public executable hashes. CIM/process queries
@@ -106,9 +107,16 @@ def strict(pairs):
def stamp(value):
need(type(value) is str and value.endswith('Z'), 'UTC_TIMESTAMP_REQUIRED')
result = dt.datetime.fromisoformat(value[:-1] + '+00:00')
return result
need(type(value) is str, 'UTC_TIMESTAMP_REQUIRED')
match = re.fullmatch(r'(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d{1,9}))?Z', value)
need(match is not None, 'UTC_TIMESTAMP_REQUIRED')
base = dt.datetime.strptime(match[1], '%Y-%m-%dT%H:%M:%S').replace(tzinfo=dt.timezone.utc)
elapsed = base - dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
return (elapsed.days * 86400 + elapsed.seconds) * SECOND_NS + int((match[2] or '').ljust(9, '0'))
def utc_ns(value):
return stamp(value.astimezone(dt.timezone.utc).isoformat().replace('+00:00', 'Z'))
def canonical_uuid(value):
@@ -138,7 +146,7 @@ def windows_boot(ticks):
def filetime(value):
need(type(value) is str and value.isascii() and value.isdigit(), 'FILETIME_REQUIRED')
return dt.datetime(1601, 1, 1, tzinfo=dt.timezone.utc) + dt.timedelta(microseconds=int(value) // 10)
return (int(value) - 116444736000000000) * 100
def validate(native, server, since, observed_now):
@@ -151,7 +159,7 @@ def validate(native, server, since, observed_now):
generation = current['connection_generation']
need(type(generation) is int and generation > 0, 'CURRENT_POSITIVE_GENERATION')
now = stamp(native['observed_at'])
need(abs((now - observed_now).total_seconds()) <= 10, 'CURRENT_WINDOWS_UTC')
need(abs(now - utc_ns(observed_now)) <= 10 * SECOND_NS, 'CURRENT_WINDOWS_UTC')
records = []
for role, filename in FILES.items():
wrapped = native['reports'][filename]
@@ -168,9 +176,9 @@ def validate(native, server, since, observed_now):
observed = stamp(record['observed_at'])
modified = filetime(wrapped['metadata']['last_write_filetime'])
birth = filetime(native['runtime']['agent']['birth_filetime'])
need(since <= observed <= now + dt.timedelta(seconds=2) and birth <= observed, 'SAMPLE_CURRENT_INSTALL_WINDOW')
need(0 <= (now - modified).total_seconds() <= 180 and 0 <= (now - observed).total_seconds() <= 180, 'SAMPLE_FILE_AGE')
need(-2 <= (modified - observed).total_seconds() <= 90, 'SAMPLE_PUBLICATION_DELAY')
need(since <= observed <= now + 2 * SECOND_NS and birth <= observed, 'SAMPLE_CURRENT_INSTALL_WINDOW')
need(0 <= now - modified <= 180 * SECOND_NS and 0 <= now - observed <= 180 * SECOND_NS, 'SAMPLE_FILE_AGE')
need(-2 * SECOND_NS <= modified - observed <= 90 * SECOND_NS, 'SAMPLE_PUBLICATION_DELAY')
need(wrapped['metadata']['dacl_checked'] is True, 'SAMPLE_PROTECTED_METADATA')
records.append(record)
for field in ('verifier_incarnation', 'request_sha256', 'response_sha256'):
@@ -181,7 +189,7 @@ def validate(native, server, since, observed_now):
def collect(args):
need(HEX.fullmatch(args.agent_sha256) and HEX.fullmatch(args.helper_sha256), 'QUALIFIED_RUNTIME_HASHES_REQUIRED')
since = stamp(args.profile_after)
need(0 <= (dt.datetime.now(dt.timezone.utc) - since).total_seconds() <= 600, 'RECENT_PROFILE_INSTALL_WINDOW')
need(0 <= utc_ns(dt.datetime.now(dt.timezone.utc)) - since <= 600 * SECOND_NS, 'RECENT_PROFILE_INSTALL_WINDOW')
STATE.mkdir(parents=True, mode=0o700, exist_ok=True)
ident = str(uuid.uuid4())
folder = STATE / ident
+11 -1
View File
@@ -10,7 +10,7 @@ import passive_time_closeout as c
class Binding(unittest.TestCase):
def setUp(self):
self.now = dt.datetime(2026,11,15,14,0,tzinfo=dt.timezone.utc)
self.since = self.now - dt.timedelta(seconds=50)
self.since = c.utc_ns(self.now - dt.timedelta(seconds=50))
ticks='638987472000000000'
boot=c.windows_boot(ticks)
epoch=dt.datetime(1601,1,1,tzinfo=dt.timezone.utc)
@@ -50,5 +50,15 @@ class Binding(unittest.TestCase):
def test_missing_sample_is_explicit(self):
self.native['reports']['helper-time-sample.json']=None
with self.assertRaisesRegex(ValueError,'PUBLIC_SERVICE_SAMPLE_MISSING'):c.validate(self.native,self.server,self.since,self.now)
def test_native_seven_and_chrono_nine_digits_keep_exact_install_boundary(self):
native='2026-11-15T13:59:40.1234567Z'
chrono='2026-11-15T13:59:40.123456701Z'
self.assertEqual(c.stamp(chrono)-c.stamp(native),1)
self.modify('agent-time-sample.json','observed_at',native)
self.modify('helper-time-sample.json','observed_at',chrono)
since=c.stamp(native)
self.assertEqual(len(c.validate(self.native,self.server,since,self.now)),2)
with self.assertRaisesRegex(ValueError,'SAMPLE_CURRENT_INSTALL_WINDOW'):
c.validate(self.native,self.server,since+1,self.now)
if __name__=='__main__':unittest.main()
+3 -1
View File
@@ -6,7 +6,9 @@ Ein kleiner rein lesender Collector für die beiden historischen Rollenbelege
aus cc82124 ist ausführbar vorbereitet. Er bindet öffentliche Dienstprozesse,
Boot, aktuelle Servergeneration, Rollen-/Hashtrennung und enge Datenalter;
keine Dienste, IPC, Zeitrequests oder Diagnoseprogramme werden ausgelöst.
Lokale Syntax-/Scopeguards und fünf Bindingfixtures bestanden. **Kein VM-Aufruf,
Lokale Syntax-/Scopeguards und sechs Bindingfixtures bestanden. Der konkrete
lokale .NET-/Chrono-Fraktionsparserfehler ist mit exakter Nanosekundenrechnung
und +1ns-Grenzfall korrigiert. **Kein VM-Aufruf,
keine native Collector-/Rollenabnahme** vor Roots V2-Profil-/Readbacksignal.
[Umfang und genaue Grenzen](windows-passive-time-closeout.md).
+21 -1
View File
@@ -78,12 +78,32 @@ python3 deploy/windows/passive_time_closeout.py guards
python3 -m unittest discover -s deploy/windows -p test_passive_time_closeout.py
```
Fünf lokale Fixtures prüfen aktuelle unabhängige Rollen, falsche PID/Boot/
Sechs lokale Fixtures prüfen aktuelle unabhängige Rollen, falsche PID/Boot/
Generation/Rolle/Beobachtungsfrist, gleiche Verifier-/Request-/Responsewerte,
doppelte JSONfelder, fehlende Sicherheitsprüfung und fehlenden Helperbeleg.
Der zusätzliche Grenzfall prüft die tatsächlichen sieben .NET- und neun
Chrono-Nachkommastellen. Python3.10s ursprüngliches `fromisoformat` verweigert
diese Formen; dieser konkrete lokale Fehler wurde vor jedem Zielaufruf
behoben. UTC- und FILETIME-Grenzen werden jetzt vollständig mit Ganzzahl-
Nanosekunden verglichen. Ein Sample genau an der Installationsuntergrenze wird
akzeptiert, eine um1ns spätere Untergrenze verweigert dasselbe Sample. Keine
Native- oder Testzeit wird hierfür erfunden.
PowerShell-/C#-Nativeparse und echte Rollenbelege bleiben offen; lokale
Pythonprüfungen ersetzen sie nicht.
Der konkrete Profileinsatz wurde zusätzlich unabhängig rein im Quellcode
geprüft (`time_profile_config.py`, SHA256
`36f0451a146ca8dc73d4c66b48f2e65fbaefde5c7643133993d1c136cc3318de`).
Kein konkreter Befund im geprüften Schnitt: getrennte öffentliche Source-/
Plattform-/Key-/Bindingketten, exakte neue Rollen mit PID/Geburt/Token-/Service-
SID/Image/FileID, SameLive-/Kernel-CAS vor und nach Veröffentlichung,
Intent-vor-ACL/Move, überschreibungsfreier gleichvolumiger Move und ausschließlich
ThisFolderOnly-Leserechte für die zwei Rollen. Die UTC-Untergrenze wird vor
dem ersten privaten Fallintent aufgezeichnet. Noch ungesetzte Paarbeleg-
Konstanten blockieren die Vorbereitung. Der konkrete spätere Rollen-/
Readbackbinding-Delta und die tatsächliche Veröffentlichung bleiben separat
nachzuweisen. Dieser Review ist keine Profileinrichtung oder native Abnahme.
Falls Reports fehlen, können die bereits vorhandenen passiven Dateien
`helper-probe.json` und `pipe-last-error.json` getrennt nur lesend bei der
Pipeeingrenzung helfen. Sie enthalten keinen vollständigen Timeworkerfehler;