Recursive agent without iteration cap

ID

recursive-agent-without-iteration-cap

Severity

high (catalogue Medium; platform severity model has no 'medium')

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

OWASP LLM

LLM10:2025 — Unbounded Consumption

OWASP ASI

ASI08:2026

Family

LLM10 — Unbounded Consumption

Red-team vectors

(none — LLM10 carries no red-team vector)

Tags

ai_security

Description

An agent plan-act loop has no iteration / recursion / tool-call bound, so it can run forever — runaway cost, and the only static ASI08 coverage in the catalogue.

Framework-default aware: LangChain AgentExecutor defaults max_iterations=15 and LangGraph defaults recursion_limit=25, so a framework executor is bounded by default and is not flagged — unless the default is explicitly disabled (max_iterations=None). A raw while True loop driving an agent/LLM call has no framework default, so it fires unless an explicit cap is present.

Examples

agent = create_react_agent(llm, tools)
while True:                       (1)
    response = agent.invoke(state)
1 Raw agent loop with no iteration cap — flagged. Also flagged: AgentExecutor(…​, max_iterations=None).

A framework executor with its default cap, or with an explicit max_iterations=10, produces no finding.

Mitigation / Fix

  • Set an explicit iteration / recursion cap (max_iterations, recursion_limit, max_turns).

  • Add a max-execution-time bound on the agent loop.