Repository navigation
Description
What is wrong
At main (a8e3559), prototype/azure_execution_binding.py has four security and input-validation bugs:
-
authenticate_akchecks only the RSA modulusnofHCLAkPuband ignoreskty,e, and key size (GHSA-vwq2exponent-mismatch class):- In
prototype/azure_execution_binding.py:466-492,authenticate_akreadskeys[0]["n"]fromHCLAkPub, comparesif modulus != ak.public_numbers().n: raise ExecutionDenied("ak_not_hcl_bound"), and returnsak(loaded from attacker-suppliedpacket["ak_pem"]). - It never checks
keys[0].get("kty") == "RSA", never decodes or validateskeys[0]["e"]as a canonicalBase64urlUInt, never requiresexponent == 65537andmodulus.bit_length() >= 2048, and never checksak.public_numbers().e == exponent. - Supplying an
ak_pemwith the same modulusnasHCLAkPuband a different public exponente(e.g.,e=3), or anHCLAkPubwith a non-RSAkty, weak exponent, or< 2048-bit modulus, passesauthenticate_ak.
- In
-
authenticate_akand_runtime_claimsaccept duplicate JSON object keys in HCL runtime JSON:authenticate_ak(line 467) and_runtime_claims(line 512) calljson.loads(...)without anobject_pairs_hookto reject duplicate keys, unlikeexecution_appraisal.py,tdx_collateral.py, andverifier_token.py.
-
_secure_boot_stateleaksstruct.error/UnicodeDecodeErrorand accepts truncated variable payloads:- In
prototype/azure_execution_binding.py:207-218,_secure_boot_statecallsname_len, data_len = struct.unpack_from("<QQ", event.data, 16)andevent.data[32 : 32 + 2 * name_len].decode("utf-16-le")without checkinglen(event.data) >= 32or32 + 2 * name_len + data_len <= len(event.data)and without catching(struct.error, UnicodeDecodeError)asExecutionDenied. Whendata_lenexceeds the remaining bytes and 1 byte\x01followsSecureBoot, Python's sliceevent.data[32 + 2 * name_len : 32 + 2 * name_len + data_len]silently truncates tob"\x01"and returnsTrue.
- In
-
authenticode_sha256leaksstruct.error/TypeErroron non-bytesor truncated PE images instead of raisingValueError.
Reproduction on a8e3559:
import hashlib, struct
from prototype import azure_execution_binding as aeb
# 1. Truncated SecureBoot UEFI variable event with data_len=9999 and 1 trailing byte b'\x01' passes:
name_utf16 = "SecureBoot".encode("utf-16-le")
data = b"\x00" * 16 + struct.pack("<QQ", len("SecureBoot"), 9999) + name_utf16 + b"\x01"
ev = aeb.UefiEvent(pcr=7, event_type=aeb.EV_EFI_VARIABLE_DRIVER_CONFIG, sha256=hashlib.sha256(data).digest(), data=data)
assert aeb._secure_boot_state([ev]) is True
# 2. Short event data (< 32 bytes) raises raw struct.error instead of ExecutionDenied:
bad_data = b"\x00" * 20
bad_ev = aeb.UefiEvent(pcr=7, event_type=aeb.EV_EFI_VARIABLE_DRIVER_CONFIG, sha256=hashlib.sha256(bad_data).digest(), data=bad_data)
aeb._secure_boot_state([bad_ev]) # raises struct.errorSpec section or file
prototype/azure_execution_binding.py(authenticate_ak,_runtime_claims,_secure_boot_state,authenticode_sha256)
Expected behavior
authenticate_akrequireskeys[0].get("kty") == "RSA", decodeskeys[0]["e"]as a canonicalBase64urlUInt, requiresexponent == 65537andmodulus.bit_length() >= 2048, and verifies(ak.public_numbers().n, ak.public_numbers().e) == (modulus, exponent).authenticate_akand_runtime_claimsreject duplicate JSON object keys in HCL runtime JSON withExecutionDenied._secure_boot_statevalidateslen(event.data) >= 32and32 + 2 * name_len + data_len <= len(event.data)(requiring exactdata_lenbytes) and catches(struct.error, UnicodeDecodeError)asExecutionDenied("secure_boot_state").authenticode_sha256validatesisinstance(image, bytes)and PE header/section bounds, raisingValueErroron malformed inputs.
Impact
An attacker-supplied ak_pem with a mismatched public exponent e (or a truncated PCR 7 SecureBoot variable event) is accepted by azure_execution_binding.
Activity
github-actions commentedon Oct 23, 2026
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check.
prototype(azure_execution_binding): bind HCLAkPub exponent e and key …
prototype(azure_execution_binding): bind HCLAkPub exponent e and key …
prototype(azure_execution_binding): bind HCLAkPub exponent e and key …