When an agent application gets compromised, you need to find the compromise entry point (CEP). Traditional incident response relies on system logs, network traces, and application logs. Agent applications break that model. The artifacts you have are trajectory logs (what the agent decided to do) and source code. The CEP you need to find is a function call buried in application execution. The semantic gap between those two layers makes forensic backtracking hard.
A new paper from Penn State introduces Origin, a tool that bridges this gap by building a cross-layer dependency graph. It connects high-level agent functionality to low-level taint propagation. The research tested Origin on five agent applications across eight attack incidents. It found all CEPs correctly.
The Forensic Artifact Problem
Agent frameworks log different things than traditional applications. Here’s what you typically get:
- Trajectory logs: Agent reasoning steps, tool selections, high-level decisions
- Tool invocation records: Which tools were called, with what parameters
- LLM prompt/response pairs: Input prompts and model outputs
- Source code: The application logic that executes tool calls
What you don’t get:
- Fine-grained execution traces linking agent decisions to specific code paths
- Taint tracking from user input through LLM reasoning to vulnerable function calls
- Causal chains showing how a prompt injection triggered a specific exploit
The analyst has to manually map trajectory logs to code execution. For each CEP candidate (a suspicious function call), you inspect the source to infer which agent functionality triggered it. This doesn’t scale when you have dozens of tool calls and multiple reasoning loops.
The Semantic Gap
Agent applications operate at two abstraction layers:
Agent functionality layer: The agent decides to “search the database” or “send an email.” This is what trajectory logs capture.
App code execution layer: A Python function execute_sql_query() runs with specific parameters. This is where the vulnerability lives.
The gap: Trajectory logs say the agent chose to search. They don’t say which code path executed, what variables were tainted, or how user input flowed through the system.
Traditional security tools handle one layer or the other. Static analysis works on code. Runtime monitoring captures execution. Neither connects agent reasoning to code execution in a way that supports forensic queries like “show me all function calls influenced by this prompt injection.”
Origin’s Cross-Layer Dependency Graph
Origin introduces an intermediate abstraction called the CLDG (cross-layer dependency graph). It has three components:
- Region-inferred functions: Groups of agent functionalities (regions) mapped to the functions they can trigger
- Taint propagation subgraph: Low-level data flow showing how variables influence each other
- Cross-layer edges: Connections between high-level regions and low-level variables
The CLDG lets you query across layers. Example: “Find all function calls in the database region that depend on user input variable X.”
Region Inference Algorithm
Origin defines regions as semantic groupings of agent functionality. The region inference algorithm:
- Parses trajectory logs to identify agent actions
- Maps actions to code functions using static analysis
- Groups functions by semantic similarity (database operations, file I/O, network calls)
- Builds a mapping table from regions to functions
This mapping is the key forensic artifact. When you investigate an incident, you query by region (“show me all database operations”) and Origin returns the specific function calls, including their taint status.
Query Language for Incident Investigation
Origin provides a query language for forensic analysis. Queries look like:
# Find all CEP candidates in the database region
# influenced by external input variable 'user_prompt'
query = {
"region": "database",
"taint_source": "user_prompt",
"operation": "write"
}
cep_candidates = origin.find_ceps(query)
The query returns a ranked list of function calls. Each result includes:
- Function name and location in source
- Trajectory log entries that triggered it
- Taint propagation path from input to function
- Timestamp and execution context
The analyst reviews the list instead of manually inspecting every function call in the codebase.
Case Study: Prompt Injection to SQL Execution
One of the eight incidents tested involved a prompt injection that led to SQL execution. Here’s the forensic flow:
Incident: Agent executed unauthorized database query after processing malicious user input.
Available artifacts:
- Trajectory log showing agent decided to “retrieve customer data”
- Application log showing SQL query execution
- No direct link between the two
Origin investigation:
- Analyst queries for database operations influenced by
user_inputvariable - Origin’s CLDG returns three CEP candidates
- Taint propagation shows
user_inputflows toexecute_query()viabuild_sql_statement() - Trajectory log confirms agent chose “retrieve customer data” functionality
- CEP identified:
execute_query()called with tainted parameter
Without Origin, the analyst would manually trace through the agent’s reasoning code, the SQL builder, and the query executor to find the connection.
Storage and Query Model
Origin’s architecture requires specific infrastructure:
| Component | Storage | Query Pattern | Retention |
|---|---|---|---|
| Trajectory logs | Append-only log store (S3, GCS) | Sequential scan, timestamp range | 90 days |
| Taint propagation graph | Graph database (Neo4j, DGraph) | Path queries, subgraph matching | 30 days |
| Region mapping | Key-value store (Redis, DynamoDB) | Lookup by region or function | Persistent |
| CLDG | In-memory during investigation | Cross-layer traversal | Session-scoped |
The CLDG is built on-demand during an investigation. You don’t persist it because it’s expensive to maintain and most of it is never queried. Instead, you store the inputs (trajectory logs, taint graphs, region mappings) and construct the CLDG when an incident occurs.
Real-Time vs. Post-Incident
Origin is designed for post-incident investigation, not real-time monitoring. Building the CLDG takes minutes. That’s acceptable when you’re investigating a breach but too slow for live alerting.
For real-time detection, you still need traditional security monitoring:
- Anomaly detection on tool call patterns
- Rate limiting on sensitive operations
- Input validation before LLM processing
Origin complements those systems. When an alert fires, Origin helps you understand what happened and find the root cause.
What Frameworks Actually Persist
Most agent frameworks log trajectory data but not forensic-grade execution traces. Here’s what you get by default:
LangChain:
- Agent actions and observations
- LLM input/output
- Tool call parameters
- No taint tracking, no execution graph
AutoGPT:
- Command execution log
- File operations
- No cross-layer dependency tracking
Semantic Kernel:
- Plan execution steps
- Function invocations
- No taint propagation
Custom frameworks:
- Varies widely
- Often just stdout/stderr
To use Origin, you need to instrument your agent application to capture taint propagation. That means adding hooks to track variable dependencies during execution. The paper doesn’t specify the instrumentation method, but typical approaches include:
- Dynamic taint analysis via bytecode instrumentation (Python:
sys.settrace, Java: ASM) - Static analysis to build data flow graphs, then runtime correlation
- Explicit taint tracking in application code (manual annotations)
The instrumentation overhead is significant. Expect 20-50% performance hit during taint tracking. You probably don’t run this in production. Instead, you enable it in a staging environment or replay production traffic with instrumentation turned on.
Failure Modes
Origin’s approach has specific failure points:
Region inference fails when:
- Agent functionality is too dynamic to categorize
- Code uses reflection or dynamic dispatch heavily
- Trajectory logs don’t capture enough detail
Taint tracking fails when:
- Data flows through external systems (databases, APIs)
- Implicit information flow (timing channels, control flow)
- Serialization/deserialization breaks taint tags
CLDG construction fails when:
- Code and trajectory logs are out of sync (version mismatch)
- Execution path wasn’t logged (sampling, log loss)
- Static analysis can’t resolve function calls (callbacks, closures)
The paper reports 100% CEP identification across eight incidents, but those were controlled test cases. In production, expect false negatives when the attack path involves external systems or implicit flows.
Deployment Shape
Origin is a forensic tool, not a runtime agent. Typical deployment:
- Production: Run agent application with trajectory logging enabled, no taint tracking
- Incident detected: Export trajectory logs and relevant source code
- Investigation environment: Spin up Origin with instrumented replay capability
- Replay: Re-execute the incident scenario with taint tracking enabled
- Query: Use Origin’s query language to identify CEPs
- Remediation: Patch the vulnerable code path, update agent logic
The replay step is critical. You can’t retroactively add taint tracking to past executions. You need to reproduce the incident in a controlled environment where instrumentation is active.
For high-security environments, consider:
- Always-on taint tracking in a shadow deployment (parallel execution, no user impact)
- Periodic snapshots of CLDG state for faster investigation
- Pre-computed region mappings updated on each code deploy
The cost is high (double compute for shadow deployment) but you get forensic-grade logs without replay latency.
Technical Verdict
Use Origin’s approach when:
- You deploy agent applications with sensitive tool access (databases, file systems, external APIs)
- Incident response SLAs require root cause analysis within hours, not days
- You can afford the instrumentation overhead (staging environment or shadow deployment)
- Your agent framework logs trajectory data with enough detail to map to code execution
Avoid when:
- Your agent application is stateless and ephemeral (no persistent compromise risk)
- You need real-time detection, not post-incident forensics
- Your codebase changes too rapidly for region mappings to stay current
- Instrumentation overhead breaks your performance budget
The core insight is valuable: agent security incidents need forensic artifacts that span the semantic gap between agent reasoning and code execution. Whether you use Origin specifically or build your own cross-layer dependency graph, the principle holds. Trajectory logs alone aren’t enough. You need a way to connect agent decisions to vulnerable function calls.
For most teams, start with better trajectory logging and manual investigation. Add taint tracking when you have a security incident that justifies the cost. Build the full CLDG infrastructure only if you’re running agents at scale with high-value attack surfaces.