You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(capture-core): reject duplicate JSON keys and non-finite numbers in load_state/sha_mapping and check seal.alg in check_seal #366
Three state-integrity boundary gaps exist in packages/agentrust-capture-core/src/agentrust_capture_core/:
Duplicate JSON keys and non-finite constants accepted in load_state (packages/agentrust-capture-core/src/agentrust_capture_core/state.py lines 65-80):
load_state(path) calls bare json.loads(path.read_text(encoding="utf-8")) without object_pairs_hook or parse_constant, accepting state/baseline files with duplicate JSON keys or NaN/Infinity constants instead of returning None (corrupt state).
allow_nan=True default in sha_mapping (packages/agentrust-capture-core/src/agentrust_capture_core/hashing.py lines 76-80):
sha_mapping(value) calls json.dumps(value, sort_keys=True, separators=(",", ":")) without allow_nan=False, allowing NaN and Infinity to serialize into non-standard JSON before hashing.
Unchecked seal["alg"] in check_seal (packages/agentrust-capture-core/src/agentrust_capture_core/seal.py lines 61-71):
attach_seal writes {"alg": "SHA-256", "digest": state_digest(snapshot), "sealed_at": ...}, but check_seal only checks isinstance(seal.get("digest"), str) and seal["digest"] == state_digest(snapshot), returning INTEGRITY_OK even when seal.get("alg") != "SHA-256".
Proposed Fix
Reject duplicate JSON keys and NaN/Infinity constants in load_state (returning None).
Pass allow_nan=False to json.dumps in sha_mapping.
Check seal.get("alg") == "SHA-256" in check_seal, returning INTEGRITY_BROKEN when "alg" is present and not "SHA-256".
Activity
github-actions commentedon Oct 23, 2026
🟡 Contributor Check: MEDIUM
Automated check by AgenTrust Contributor Check.
fix(capture-core): reject duplicate JSON keys and non-finite numbers …