From e42596d50342c0ac1ffd853fc74c027513abdd11 Mon Sep 17 00:00:00 2001 From: "Altru.dev" Date: Sun, 6 Sep 2026 16:18:28 -0700 Subject: [PATCH 1/2] fix(content-marking): reject boolean assertion version Signed-off-by: Altru.dev --- src/agentrust_trace/content_marking.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/agentrust_trace/content_marking.py b/src/agentrust_trace/content_marking.py index 4ea1eee..1a6af67 100644 --- a/src/agentrust_trace/content_marking.py +++ b/src/agentrust_trace/content_marking.py @@ -136,9 +136,10 @@ def verify_assertion(assertion: dict[str, Any], record_bytes: bytes) -> dict[str data = assertion.get("data") if not isinstance(data, dict): raise ContentMarkingError("assertion has no data object") - if data.get("version") != ASSERTION_VERSION: + version = data.get("version") + if isinstance(version, bool) or version != ASSERTION_VERSION: raise ContentMarkingError( - f"unknown assertion version {data.get('version')!r}; expected {ASSERTION_VERSION}. " + f"unknown assertion version {version!r}; expected {ASSERTION_VERSION}. " "An unknown version is rejected rather than parsed best-effort." ) From 04a19cd830fdfafe73aa9e2518ba904f1c96ea7a Mon Sep 17 00:00:00 2001 From: "Altru.dev" Date: Sun, 6 Sep 2026 16:18:28 -0700 Subject: [PATCH 2/2] test(content-marking): hold boolean version boundary Signed-off-by: Altru.dev --- .../test_content_marking_version_boundary.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/test_content_marking_version_boundary.py diff --git a/tests/test_content_marking_version_boundary.py b/tests/test_content_marking_version_boundary.py new file mode 100644 index 0000000..aad7387 --- /dev/null +++ b/tests/test_content_marking_version_boundary.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +import json + +import pytest + +from agentrust_trace.content_marking import ContentMarkingError, build_assertion, verify_assertion + +URL = "https://registry.example/records/abc123.json" + + +def _record_bytes() -> bytes: + return json.dumps( + { + "eat_profile": "tag:agentrust-io.com,2026:trace-v0.2", + "iat": 1760000000, + "subject": "spiffe://example.org/agent/image-bot", + "data_class": "public", + } + ).encode() + + +def _assertion_with_version(version): + raw = _record_bytes() + assertion = build_assertion(raw, url=URL) + assertion["data"]["version"] = version + return assertion, raw + + +def test_integer_version_one_is_accepted() -> None: + assertion, raw = _assertion_with_version(1) + assert verify_assertion(assertion, raw)["subject"] == "spiffe://example.org/agent/image-bot" + + +@pytest.mark.parametrize("version", [True, False, "1", None, 2]) +def test_non_v1_version_values_are_refused(version) -> None: + assertion, raw = _assertion_with_version(version) + with pytest.raises(ContentMarkingError, match="unknown assertion version"): + verify_assertion(assertion, raw) + + +def test_boolean_true_cannot_alias_integer_version_one() -> None: + assertion, raw = _assertion_with_version(True) + with pytest.raises(ContentMarkingError) as excinfo: + verify_assertion(assertion, raw) + assert "expected 1" in str(excinfo.value)