Repository navigation
fix(verify/nv_certify): enforce strict JSON, exact int version, validated base64, and lowercase hex in verify_gateway_measurement (#810) - #815
Conversation
|
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check. |
noah-ing
left a comment
There was a problem hiding this comment.
Thanks for tightening the NV envelope. I reviewed head b687f7d: 74 focused tests and the full unit suite (2,538 passed, 20 skipped) passed, and independent signed controls confirm the main malformed-input cases fail closed. Two narrow parts of #810 remain:
gateway_digestis checked for lowercase, nonempty, even-length hex, but not the issue's required 64-character length. A fully signed 62- or 66-character value passes envelope validation and fails only at the later digest comparison. Please require exactly 64 characters and add negative tests.parse_constantcatches literalNaN/Infinity, but JSON exponent overflow such as1e1000is parsed as Python infinity. Adding that value in an ignored field to an otherwise valid signed envelope still returnsverified=True. Please reject non-finite floats throughout the parsed envelope and add a regression, including a nested field.
Neither case bypasses signature or NV policy. They do leave the strict envelope contract incomplete, so I am requesting these focused changes before #810 closes.
carloshvp
left a comment
There was a problem hiding this comment.
Reviewed exact head b687f7d011e3d9ac6a0c0e16361aad30256eca52 in an isolated checkout.
I independently confirmed the two remaining envelope-contract gaps identified in the current-head review:
- A valid signed positive control still returns verified=True after adding an ignored top-level or nested JSON field with the numeric token 1e1000. parse_constant rejects literal NaN, but exponent overflow becomes a non-finite float without invoking that hook. Please reject non-finite decoded numbers recursively, with top-level and nested regression cases.
- gateway_digest accepts 62- and 66-character strings at the envelope-validation stage. Both are later refused by the digest comparison, but the required fixed 64-character SHA-256 envelope check is missing. Please enforce that length before decoding and test both sides of the boundary.
The intact signed control passes, and literal NaN is rejected as malformed_envelope. These observations establish the strict-input contract gaps; they do not establish a signature or NV-policy bypass. The ordinary exact-head suite passes (2,538 passed, 20 skipped), as do pip check, Ruff, mypy, configured Bandit, sign-offs and diff whitespace checks. Requesting the focused changes above before approval.
Reviewed with OpenAI Codex.
|
Thank you @noah-ing and @carloshvp! Addressed both points in
|
b687f7d to
7992792
Compare
noah-ing
left a comment
There was a problem hiding this comment.
Thanks for the focused follow-up at head 799279204fe258c553db0763426993146139a369. The two source gaps in my earlier review are addressed: the envelope now requires a 64-character lowercase gateway_digest, and exponent-overflow numbers, including nested ones, are rejected. Signed positive and malformed controls passed; I found no signature or NV-policy bypass.
One committed test still needs to follow the corrected contract. test_non_sha256_length_claimed_gateway_digest_is_rejected expects gateway_digest_mismatch for a 31-byte claimed digest. The new envelope check correctly returns malformed_envelope before that value can be verified. On this exact head, the focused suite had 77 passed and 1 failed; the full unit suite had 2,550 passed, 20 skipped, and this same 1 failure. The 10 NV reference integration tests passed.
Please update that assertion to malformed_envelope, assert that "envelope" is absent from verified_fields, and rerun the suite. A local test-only correction of those lines made the unit and NV reference suites pass (2,561 passed, 20 skipped); it is not part of this head. Please also refresh the PR description's older 74 passed test claim after the rerun. The fork's substantive hosted workflows are awaiting authorization, so I am not claiming a hosted CI pass.
…ated base64, and 64-char hex in verify_gateway_measurement (agentrust-io#810) Reject duplicate JSON keys, literal and overflow non-finite numbers (via parse_constant and parse_float), non-int envelope version, invalid base64 strings, and non-64-character or non-lowercase gateway_digest hex at the envelope boundary in cmcp_verify.nv_certify, and validate types in measurement_nv_public_bytes. Closes agentrust-io#810 Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
7992792 to
48c3721
Compare
|
@noah-ing Updated |
What
Enforce duplicate-key and non-finite JSON rejection, exact
intversion (type(version) is int),base64.b64decode(..., validate=True), and lowercase hexgateway_digestinverify_gateway_measurement, and validatetype(index) is intandisinstance(written, bool)inmeasurement_nv_public_bytes.Why
Closes #810.
Security impact
Prevents duplicate-key JSON smuggling, boolean/float version coercion (
"v": trueor1.9), non-base64 character injection in NV certify envelopes, and non-canonical uppercase/whitespace hex ingateway_digest.Test plan
pytestpasses (pytest tests/unit/test_nv_certify.py tests/unit/test_nv_policy.py -q:78 passed)ruff checkpasses (All checks passed!)mypypassesDCO sign-off
Developer Certificate of Origin (https://developercertificate.org).