AI & Computingpreprint2026-12-02

Stateful State-Action Matrix Monitoring for Compositional Threats in Multi-Step Coding Agents

Open access0 citations

Abstract

Autonomous coding agents often operate over long horizons interrupted by context compaction and session resets. Under realistic data-loss-prevention (DLP) policies, two actions may each be permissible in isolation—inspecting sandbox environment variables for debugging, or uploading a non-secret continuous integration summary—while their composition across turns, compaction boundaries or sessions is a violation. Stateless monitors, sliding-window auditors and scalar sequential detectors either discard the history needed to recognize such compositions or retain it at a token cost that grows with trajectory length. In this paper, we propose the State-Action Matrix (SAM) monitor. A lightweight extractor maps each proposed tool call onto an 8×8 semantic state-action space, and a persistent accumulator with per-state decay and a lagged bilinear coupling term carries security-relevant state across boundaries in a fixed-size representation, a median 62.2× shorter than the raw trajectory. A four-dimensional risk projection (severity, irreversibility, impact and blast radius) supports three-tier pre-execution routing. On a 650-trajectory benchmark derived from SWE-agent logs, with symmetric hard-benign negatives and five attack classes, SAM matches the strongest baseline in AUROC (0.996) and reaches 97.3% recall at 0.8% benign false positive rate, at 7.7–8.5 times lower cost than full-history monitoring. On the two cross-boundary attack classes, it detects 60 of 60 attacks against 53 for a provenance-graph baseline (exact McNemar p = 0.016); without the coupling term, recall on these classes falls to 63.3% and 76.7%. Our results suggest that a small, structured state memory may recover compositional evidence that transcript truncation destroys, although the benchmark is template-based and evaluation against adaptive attackers remains to be done.

// Source

View paper (DOI)Open access versionOpenAlexZenodo (CERN European Organization for Nuclear Research)Published 2026-12-02

Authors: Albert Hung-Ren Ko

Institutions: University of Toronto