From 13020a92436ce96b9164ff08001fe243d6f07670 Mon Sep 17 00:00:00 2001 From: Syafa Hadyan Rasendriya Date: Wed, 11 Nov 2026 17:21:17 +0700 Subject: [PATCH 1/2] ci(zap): call the schedule delete and the gateway delete in the active scan seed --- .zap/seed.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.zap/seed.py b/.zap/seed.py index 33366c6..74986c8 100644 --- a/.zap/seed.py +++ b/.zap/seed.py @@ -125,7 +125,7 @@ def verification_link(): enroll = need("enroll", call("POST", "/device/v1/enroll", { "hardwareId": f"ZAP-{RUN}", "firmware": "zap", "keyHash": hashlib.sha256(key.encode()).hexdigest(), }, app=False), 201) -need("claim", call("POST", "/v1/gateways", {"claimCode": enroll["claimCode"], "name": "Hub ZAP"}, cookie=cookie), 201) +gateway = need("claim", call("POST", "/v1/gateways", {"claimCode": enroll["claimCode"], "name": "Hub ZAP"}, cookie=cookie), 201)["id"] node = f"PLUG-{RUN}" pairing = need("start a pairing", call("POST", "/v1/pairings", {"kind": "plug", "name": "Mesin ZAP", "roomId": room}, cookie=cookie), 201)["id"] @@ -184,6 +184,10 @@ def owner(method, path, body=None): owner("POST", f"/v1/devices/{device}/energy-reset"), {"method": "GET", "path": "/device/v1/enroll/" + enroll["pollId"]}, {"method": "POST", "path": "/v1/auth/forgot-password", "app": True, "body": {"email": EMAIL}}, + owner("DELETE", f"/v1/devices/{device}/schedule"), + # These last requests remove the schedule and then the hub with all that it holds, so keep them at the end. + owner("DELETE", f"/v1/gateways/{gateway}", {"password": PASSWORD + "-wrong"}), + owner("DELETE", f"/v1/gateways/{gateway}", {"password": PASSWORD}), ] with open(OUT, "w", encoding="utf-8") as handle: From a39dd4b1d483eb408457573d78495f0260cc9a20 Mon Sep 17 00:00:00 2001 From: Syafa Hadyan Rasendriya Date: Wed, 11 Nov 2026 17:22:59 +0700 Subject: [PATCH 2/2] ci(zap): delete a spare hub so the attack still has a live hub --- .zap/seed.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.zap/seed.py b/.zap/seed.py index 74986c8..55fa239 100644 --- a/.zap/seed.py +++ b/.zap/seed.py @@ -125,7 +125,15 @@ def verification_link(): enroll = need("enroll", call("POST", "/device/v1/enroll", { "hardwareId": f"ZAP-{RUN}", "firmware": "zap", "keyHash": hashlib.sha256(key.encode()).hexdigest(), }, app=False), 201) -gateway = need("claim", call("POST", "/v1/gateways", {"claimCode": enroll["claimCode"], "name": "Hub ZAP"}, cookie=cookie), 201)["id"] +need("claim", call("POST", "/v1/gateways", {"claimCode": enroll["claimCode"], "name": "Hub ZAP"}, cookie=cookie), 201) + +# A second hub that only the delete requests use. The replay runs before the attack, so the hub that gets deleted is gone when the +# attack starts, and the plug above has to stay alive for the rest of the list. +spare_key = secrets.token_urlsafe(32) +spare = need("enroll the spare hub", call("POST", "/device/v1/enroll", { + "hardwareId": f"ZAP-{RUN}-spare", "firmware": "zap", "keyHash": hashlib.sha256(spare_key.encode()).hexdigest(), +}, app=False), 201) +spare_gateway = need("claim the spare hub", call("POST", "/v1/gateways", {"claimCode": spare["claimCode"], "name": "Hub ZAP spare"}, cookie=cookie), 201)["id"] node = f"PLUG-{RUN}" pairing = need("start a pairing", call("POST", "/v1/pairings", {"kind": "plug", "name": "Mesin ZAP", "roomId": room}, cookie=cookie), 201)["id"] @@ -185,9 +193,10 @@ def owner(method, path, body=None): {"method": "GET", "path": "/device/v1/enroll/" + enroll["pollId"]}, {"method": "POST", "path": "/v1/auth/forgot-password", "app": True, "body": {"email": EMAIL}}, owner("DELETE", f"/v1/devices/{device}/schedule"), - # These last requests remove the schedule and then the hub with all that it holds, so keep them at the end. - owner("DELETE", f"/v1/gateways/{gateway}", {"password": PASSWORD + "-wrong"}), - owner("DELETE", f"/v1/gateways/{gateway}", {"password": PASSWORD}), + # The attack only reaches the password check of this route, because the spare hub is gone after the replay and the wrong + # passwords of the attack use up the shared budget of five tries + owner("DELETE", f"/v1/gateways/{spare_gateway}", {"password": PASSWORD + "-wrong"}), + owner("DELETE", f"/v1/gateways/{spare_gateway}", {"password": PASSWORD}), ] with open(OUT, "w", encoding="utf-8") as handle: