Repository navigation
prototype(azure_execution_binding): bind HCLAkPub exponent e and key size, reject duplicate JSON keys, and harden _secure_boot_state and authenticode_sha256 - #620
Open
drk-ram wants to merge 1 commit into
Conversation
Contributor
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
dinakarjs
approved these changes
Oct 23, 2026
dinakarjs
left a comment
Contributor
There was a problem hiding this comment.
Reviewed exact head 1d772c0. Checked canonical RSA integer decoding, the single RSA HCLAkPub selection, exponent/modulus and supplied-key matching, duplicate runtime JSON rejection, secure-boot decoding and PE bounds. Focused local suites: 29 passed, 14 skipped; Ruff and diff checks passed. The skipped cases need the absent pinned WCM/cloud capture snapshot; the passing mocked authentication cases are unit boundary evidence, not live vTPM or hardware-attestation evidence. Current hosted CI/conformance/review-bar checks are successful. No blocking finding in this bounded change.
…size, reject duplicate JSON keys, and harden _secure_boot_state and authenticode_sha256 Closes agentrust-io#613 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Raghuvar Durga <177662415+drk-ram@users.noreply.github.com>
drk-ram
force-pushed
the
drk-ram-fix-azure-execution-binding-613
branch
from
October 24, 2026 04:11
1d772c0 to
d33ab87
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Contributor: Raghuvar Durga (@drk-ram)
Closes #613
Hardens
prototype/azure_execution_binding.pyacross four validation boundaries while preserving acceptance of the captured Azure SEV-SNP/vTPM packettests/fixtures/azure-execution-20260929/b1-approved-packet.json:_pairs) inauthenticate_akand_runtime_claims:_pairs(pairs: list[tuple[str, Any]]) -> dict[str, Any]raisingExecutionDenied("duplicate_json_key")(aValueErrorsubclass) on duplicate JSON object keys and passesobject_pairs_hook=_pairstojson.loadsin bothauthenticate_ak(surfacing asExecutionDenied("hcl_ak")) and_runtime_claims(surfacing asExecutionDenied("hcl_vm_configuration")).HCLAkPubRSA key validation and exponent binding inauthenticate_ak:_b64url_uint(value: Any, label: str) -> intenforcingisinstance(value, str),re.fullmatch(r"[A-Za-z0-9_-]+", value),len(value) % 4 != 1, minimal big-endian byte encoding (raw and raw[0] != 0), and canonical base64url round-trip (base64.urlsafe_b64encode(raw).rstrip(b"=").decode("ascii") == value).keys[0].get("kty") == "RSA", decodesmodulus = _b64url_uint(keys[0]["n"], "n")andexponent = _b64url_uint(keys[0]["e"], "e"), requiresmodulus.bit_length() >= 2048andexponent == 65537(ExecutionDenied("hcl_ak")), and binds(modulus, exponent) == (ak.public_numbers().n, ak.public_numbers().e)(ExecutionDenied("ak_not_hcl_bound")).EV_EFI_VARIABLE_DRIVER_CONFIGbounds and UTF-16-LE decoding in_secure_boot_state:isinstance(event.data, bytes)andlen(event.data) >= 32(ExecutionDenied("secure_boot_state")), unpacksname_len, data_len = struct.unpack_from("<QQ", event.data, 16), requires exact payload framing32 + 2 * name_len + data_len == len(event.data)(verified across all 20 PCR 7EV_EFI_VARIABLE_DRIVER_CONFIGevents inb1-approved-packet.json,b2-substituted-relabel-packet.json,b4b-after-sudo-packet.json, andstock-relabel-packet.json), and catchesUnicodeDecodeErrorfrom.decode("utf-16-le")asExecutionDenied("secure_boot_state")(strictutf-16-ledecoding rejects unpaired UTF-16 surrogates0xD800..0xDFFF).authenticode_sha256:isinstance(image, bytes),len(image) >= 0x40,pe + 24 <= len(image), andimage[pe : pe + 4] == b"PE\x00\x00"(ValueError("not a PE image")), requiresmagic in (0x10B, 0x20B),cert_entry + 8 <= table,table + 40 * sections <= headers_size <= len(image), valid certificate table bounds ((cert_offset == 0 and cert_size == 0)orheaders_size <= cert_offsetandcert_offset + cert_size <= len(image)), and non-overlapping in-bounds sections (hashed <= pointerandpointer + size <= end), and catchesstruct.errorasValueError("malformed PE image").What this change leaves alone and what was measured:
spec/trace-v0.2.md), JSON schemas (schema/), andsrc/agentrust_trace/are untouched; this change is scoped toprototype/azure_execution_binding.py,tests/test_execution_appraisal_and_azure_binding_hardening.py, andCHANGELOG.md.prototype/azure_execution_binding.pyfails closed withExecutionDenied(orValueErrorin the standaloneauthenticode_sha256helper).1d772c0(1d772c0d495d5a09d10069a7c6d649c76ed67eda) on Python 3.11.9 (pytest 9.1.1):pytest tests/test_azure_execution_binding.py tests/test_execution_appraisal_and_azure_binding_hardening.py -q:29 passed, 14 skipped(0 failed,0 xfailed,0 errors). The 14 skipped tests intests/test_azure_execution_binding.pyskip when the external../cloud-20260929/wcmcheckout is absent;tests/test_execution_appraisal_and_azure_binding_hardening.pyexercisestests/fixtures/azure-execution-20260929/b1-approved-packet.jsondirectly (15 passed, 0 skipped).python tools/review_bar.py --base origin/main --head HEAD:15 fail on behaviour, 0 fail on a missing name or file, 0 pass or skipacrossa8e3559..1d772c0.Independent review findings and dispositions:
ak_pemalongside a< 2048-bitHCLAkPubJWK in the modulus-size test, which causedorigin/mainto fail atak_not_hcl_boundrather than accepting the weak key (DID NOT RAISE ExecutionDenied). We split the suite into 15 single-rejection tests and paired the 1024-bit and 2047-bitHCLAkPubJWKs with matching< 2048-bitak_pemkeys soorigin/mainaccepts them and fails withDID NOT RAISE ExecutionDenied..decode("utf-16-le")in_secure_boot_state(Python's strictutf-16-ledecoder already raisesUnicodeDecodeErroron unpaired surrogates) and a duplicate HCL truncation check in_runtime_claims. Both were removed so every branch in the diff is reachable and killed by its dedicated test when switched off.Type of change
Spec section
None (
prototype/azure_execution_binding.py,tests/test_execution_appraisal_and_azure_binding_hardening.py, andCHANGELOG.mdonly).Tests for a fix
All 15 tests in
tests/test_execution_appraisal_and_azure_binding_hardening.pypass onHEAD(1d772c0) and fail on behaviour againstorigin/main(a8e3559) and when each corresponding guard inprototype/azure_execution_binding.pyis individually switched off while keeping_pairsand_b64url_uint:test_authenticate_ak_rejects_duplicate_json_keys(fails whenobject_pairs_hook=_pairsinauthenticate_akis switched off)test_runtime_claims_rejects_duplicate_json_keys(fails whenobject_pairs_hook=_pairsin_runtime_claimsis switched off)test_authenticate_ak_rejects_non_rsa_kty(fails whenkeys[0].get("kty") != "RSA"is switched off)test_authenticate_ak_rejects_invalid_or_noncanonical_exponent_encoding(fails when_b64url_uint(keys[0]["e"], "e")/len(value) % 4 == 1is switched off)test_authenticate_ak_rejects_sub_2048_bit_modulus(fails whenmodulus.bit_length() < 2048is switched off)test_authenticate_ak_rejects_non_65537_exponent(fails whenexponent != 65537is switched off)test_authenticate_ak_rejects_mismatched_ak_pem_exponent(fails when(modulus, exponent) != (numbers.n, numbers.e)is reverted tomodulus != numbers.n)test_secure_boot_state_rejects_non_bytes_and_short_event_data(fails whennot isinstance(event.data, bytes) or len(event.data) < 32is switched off)test_secure_boot_state_rejects_mismatched_variable_payload_length(fails when32 + 2 * name_len + data_len != len(event.data)is switched off or relaxed to<=)test_secure_boot_state_rejects_invalid_utf16_variable_name(fails whenexcept UnicodeDecodeErrorin_secure_boot_stateis switched off)test_authenticode_sha256_rejects_non_bytes_and_truncated_pe_headers(fails whennot isinstance(image, bytes) or len(image) < 0x40,pe + 24 > len(image), orexcept struct.erroris switched off)test_authenticode_sha256_rejects_unknown_optional_header_magic(fails whenmagic not in (0x10B, 0x20B)is switched off)test_authenticode_sha256_rejects_out_of_bounds_header_and_section_table_sizes(fails whencert_entry + 8 > table or table + 40 * sections > headers_size or headers_size > len(image)is switched off)test_authenticode_sha256_rejects_invalid_certificate_table_bounds(fails when thecert_offset/cert_sizebounds check is switched off)test_authenticode_sha256_rejects_overlapping_or_out_of_bounds_sections(fails whenpointer < hashed or pointer + size > endis switched off)Validation commands run on
1d772c0:pytest tests/test_azure_execution_binding.py tests/test_execution_appraisal_and_azure_binding_hardening.py -q: passed (29 passed, 14 skipped)python tools/review_bar.py --base origin/main --head HEAD: passed (15 fail on behaviour, 0 fail on a missing name or file, 0 pass or skip)python tools/sweep_public_surface.py --strict: passed (89 parameters swept, 140 accepted junk values, 0 unfiled leak(s))python tools/check_dashes.py: passed (no dashes outside examples/, spec/trace-v0.1.md)ruff check prototype/azure_execution_binding.py tests/test_execution_appraisal_and_azure_binding_hardening.py: passed (All checks passed!)mypy --strict --follow-imports=silent prototype/azure_execution_binding.py: passed (Success: no issues found in 1 source file)Checklist
git commit -s)CHANGELOG.mdupdated (for any normative change)<!-- CHANGED: #NNN: description -->in spec textChangelog entry
, reject duplicate JSON object keys in runtime claims and HCL JSON, enforce exact EV_SEPARATOR event types and non-boolean Enabled integers in _secure_boot_state, and require canonical 64-character lowercase hex �uthenticode_sha256 digests (prototype(azure_execution_binding): bind HCLAkPub exponent e and key size, reject duplicate JSON keys, and harden _secure_boot_state and authenticode_sha256 #613, @drk-ram).