File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1628,6 +1628,21 @@ saved=json.loads((env["state_dir"]/"azv-aaaaaaaaaaaa.json").read_text())
16281628assert "unbound_view_since" not in saved, \
16291629 "a new attempt inherited the previous attempt's settle stamp"
16301630
1631+ # N-2: the bytes VERIFIED must be the bytes RETURNED. Digesting one read and
1632+ # returning a second read is a TOCTOU: a writer landing between them passes the
1633+ # check while different content is handed back, and that content is uploaded as
1634+ # the Run Command script and executes as root on the cell. A race cannot be
1635+ # observed by waiting for it, so the second read is instrumented to differ - if
1636+ # the implementation reads twice, it returns the instrumented bytes.
1637+ saved_read_text=m.Path.read_text
1638+ m.Path.read_text=lambda self,*a,**k:"#!/bin/sh\nEVIL\n"
1639+ try:
1640+ returned=m.sealed_guest_text(env,seed())
1641+ finally:
1642+ m.Path.read_text=saved_read_text
1643+ assert returned==sealed_text, \
1644+ "sealed_guest_text returned bytes it never verified: "+repr(returned)
1645+
16311646# The recorded stamping flag comes from the bytes that are about to run.
16321647assert saved["guest_stamps_attempt"] is False, saved.get("guest_stamps_attempt")
16331648stamping=sealed_text+"printf 'FM_AZURE_VALIDATION_RESULT %s boot=%s outcome=%s attempt=%s\\n'\n"
You can’t perform that action at this time.
0 commit comments