fix(towercore): block reads during pending handover
- stop the active prepare-then-export attack sequence - preserve reads after handover commit or abort
This commit is contained in:
1 parent
a9d6b64637
commit
bd73021ac4
2 files changed
+45
-1
No files matched your search
@@ -54,6 +54,29 @@ class GuardTests(unittest.TestCase):
|
||||
request = frame(0x40, [(0x0B, bytes.fromhex("87481bd9") + b"\0" * 4)])
|
||||
self.assertFalse(module.should_block(request))
|
||||
|
||||
def test_blocks_inventory_during_uncommitted_handover(self) -> None:
|
||||
module = importlib.import_module("guard")
|
||||
guard = module.ConnectionGuard()
|
||||
selector = bytes.fromhex("87481bd9") + b"\0" * 4
|
||||
self.assertFalse(guard.should_block(frame(0x40, [(0x0B, selector), (0x0C, b"\xe9\x03\0\0")])))
|
||||
self.assertTrue(guard.should_block(frame(0x23, [(0x0B, selector)])))
|
||||
|
||||
def test_allows_inventory_after_handover_abort(self) -> None:
|
||||
module = importlib.import_module("guard")
|
||||
guard = module.ConnectionGuard()
|
||||
selector = bytes.fromhex("87481bd9") + b"\0" * 4
|
||||
self.assertFalse(guard.should_block(frame(0x40, [(0x0B, selector), (0x0C, b"\xe9\x03\0\0")])))
|
||||
self.assertFalse(guard.should_block(frame(0x42, [(0x15, b"\x01\0\0\0")])))
|
||||
self.assertFalse(guard.should_block(frame(0x23, [(0x0B, selector)])))
|
||||
|
||||
def test_allows_inventory_after_handover_commit(self) -> None:
|
||||
module = importlib.import_module("guard")
|
||||
guard = module.ConnectionGuard()
|
||||
selector = bytes.fromhex("87481bd9") + b"\0" * 4
|
||||
self.assertFalse(guard.should_block(frame(0x40, [(0x0B, selector), (0x0C, b"\xea\x03\0\0")])))
|
||||
self.assertFalse(guard.should_block(frame(0x41, [(0x15, b"\x01\0\0\0")])))
|
||||
self.assertFalse(guard.should_block(frame(0x23, [(0x0B, selector)])))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user