Skip to content

Commit 0cbb113

Browse files
authored
Merge pull request #63 from VibhorGautam/fix/memory-read-fail-closed
fix(policy): fail-closed memory reads when HMAC proof is absent
2 parents 0c5291b + daf53d4 commit 0cbb113

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

policies/tests/memory_test.rego

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ test_read_hmac_valid_allow if {
3535
result == "ALLOW"
3636
}
3737

38+
test_read_missing_integrity_block if {
39+
result := memory.decision with input as {
40+
"memory_op": "read",
41+
"score": 0.0,
42+
"signals": [],
43+
"provenance": "agent", "session_id": "m-009", "hook_type": "on_memory",
44+
"payload_size_bytes": 100,
45+
}
46+
result == "BLOCK"
47+
}
48+
3849
# --- Detection: write-time content scan ---
3950

4051
# A poisoned write flagged by the content scanner is stripped (SANITISE).

policies/v1/memory.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ default decision := "ALLOW"
2626

2727
decision := "BLOCK" if {
2828
input.memory_op == "read"
29-
input.integrity.hmac_valid == false
29+
not input.integrity.hmac_valid == true
3030
}
3131

3232
# ---------------------------------------------------------------------

policies/v1/memory_test.rego

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,29 @@ test_read_invalid_hmac_block if {
3535
result == "BLOCK"
3636
}
3737

38+
test_read_missing_hmac_block if {
39+
result := memory.decision with input as {
40+
"memory_op": "read",
41+
"score": 0.0,
42+
"signals": [],
43+
"provenance": "agent", "session_id": "s1", "hook_type": "on_memory",
44+
"payload_size_bytes": 100,
45+
}
46+
result == "BLOCK"
47+
}
48+
49+
test_read_null_hmac_block if {
50+
result := memory.decision with input as {
51+
"memory_op": "read",
52+
"score": 0.0,
53+
"signals": [],
54+
"provenance": "agent", "session_id": "s1", "hook_type": "on_memory",
55+
"integrity": {"hmac_valid": null},
56+
"payload_size_bytes": 100,
57+
}
58+
result == "BLOCK"
59+
}
60+
3861
# =====================================================================
3962
# Integrity — write-time HMAC stamp
4063
# =====================================================================

0 commit comments

Comments
 (0)