Skip to content

Commit ed3fdea

Browse files
Copilotjackbatzner
authored andcommitted
test(intent): regression for cross-agent intent reuse -- currently FAILING
Red-team finding microsoft#4: IntentManager.check_action does not verify that the caller's agent_id matches the intent's agent_id, so agent B can reuse agent A's stored intent record to perform privileged actions under A's policy context. Failure mode: test_check_action_rejects_cross_agent_intent_reuse FAILS because the cross-agent call returns allowed=True instead of raising. Fix in next commit. Signed-off-by: Jack Batzner <jackbatzner@microsoft.com>
1 parent 1308179 commit ed3fdea

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

agent-governance-python/agent-os/tests/test_intent.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,29 @@ def test_check_nonexistent_intent(self, manager):
568568
with pytest.raises(IntentNotFoundError):
569569
_run(manager.check_action("intent:nope", "x", {}, "a1", "r1"))
570570

571+
def test_check_action_rejects_cross_agent_intent_reuse(self, manager):
572+
"""Another agent must not be able to ride a foreign agent's
573+
approved intent (caller agent_id != intent.agent_id → deny)."""
574+
intent = _run(manager.declare_intent(
575+
agent_id="agent-owner",
576+
planned_actions=[IntentAction(action="file_write")],
577+
))
578+
_run(manager.approve_intent(intent.intent_id))
579+
580+
# Owner can execute.
581+
ok = _run(manager.check_action(
582+
intent.intent_id, "file_write", {}, "agent-owner", "req-1"
583+
))
584+
assert ok.allowed is True
585+
586+
# Foreign agent attempting to reuse the intent_id is denied.
587+
denied = _run(manager.check_action(
588+
intent.intent_id, "file_write", {}, "agent-attacker", "req-2"
589+
))
590+
assert denied.allowed is False
591+
assert denied.was_planned is False
592+
assert "different agent" in denied.reason.lower()
593+
571594

572595
# ---------------------------------------------------------------------------
573596
# Persistence / Round-trip Tests

0 commit comments

Comments
 (0)