Skip to content
ATR-2026-00050high過度自主experimental

Runaway Agent Loop Detection

Detects when an agent enters a runaway loop through repeated identical actions, infinite retry patterns, or recursive self-invocation. This rule uses regex-only detection to identify loop indicators in agent output and tool call content, such as retry counters, repeated action descriptions, recursive invocation patterns, and stalled progress indicators. Runaway loops waste computational resources, accumulate costs, and may indicate logic errors or adversarial manipulation.

嚴重度
high
類別
過度自主
掃描目標
mcp
作者
ATR Community

建議回應

reduce permissionsescalatealertkill agent

參考資料

OWASP Agentic
ASI05:2026 - Unexpected Code Execution
OWASP LLM
LLM06:2025 - Excessive AgencyLLM10:2025 - Unbounded Consumption
MITRE ATLAS
AML.T0053 - LLM Plugin CompromiseAML.T0046 - Spamming ML System with Chaff Data

實地驗證

驗證日期
2026-04-08
樣本數
53,577
誤報率
0%

偵測條件

組合方式: any
  1. 01
    Retry counter pattern indicating repeated attempts
    欄位: content運算子: regex
  2. 02
    Attempt X of Y counter pattern (e.g., attempt 5 of 10)
    欄位: content運算子: regex
  3. 03
    Natural language retry patterns in agent output
    欄位: content運算子: regex
  4. 04
    Stalled progress with persistent error indicators
    欄位: content運算子: regex
  5. 05
    Recursive self-invocation patterns
    欄位: content運算子: regex
  6. 06
    High iteration count indicating prolonged looping
    欄位: content運算子: regex
  7. 07
    Agent acknowledging it is repeating identical actions
    欄位: content運算子: regex
  8. 08
    Retry limit reached indicators
    欄位: content運算子: regex
  9. 09
    Explicit stall or no-progress acknowledgement
    欄位: content運算子: regex
  10. 10
    Infinite loop constructs in generated or executed code
    欄位: content運算子: regex
  11. 11
    Agent declaring intent to retry indefinitely
    欄位: content運算子: regex
  12. 12
    Agent spawning copies of itself (fork bomb pattern)
    欄位: content運算子: regex

攻擊範例(規則會觸發)

  1. Retrying attempt 15 of 10. The request still returns the same error.
  2. Still failing after 25 iterations. Let me try again with the same parameters.
  3. Calling myself recursively to process the remaining items. Recursive call depth: 47.
  4. Will keep trying until it works. Continuously retrying the API call.
  5. iteration #450 - still processing the same batch. No new results returned from the API.

以上為真實攻擊 payload 脫敏版本。用於 regression testing。

正常樣本(規則不會觸發)

  1. Legitimate batch processing with bounded progress counter
    Processing batch 3 of 5. All items completed successfully so far.
  2. Normal bounded retry logic in error handling
    The API returned an error. Retrying once with exponential backoff.
  3. Successful completion after reasonable retry count
    Task completed after 3 attempts. Here are the final results.
  4. Legitimate pipeline completion report with large numbers that do not match loop patterns
    The pipeline completed successfully. Total records processed: 15000 across 4 stages. Final output saved to /data/results.csv.
  5. Documentation describing bounded retry architecture without using trigger phrases like 'retrying N' or 'try again'
    Here is a summary of the error handling strategy: if a transient fault occurs, the system will back off exponentially and make up to 3 additional requests before returning a failure response to the caller.

已知誤報情境

  • Legitimate batch processing with progress counters in output
  • Polling agents designed to check status at regular intervals
  • Long-running data pipeline agents with expected high iteration counts
  • Retry logic in error handling with bounded retry limits
  • CI/CD build logs that include 'attempt 2 of 3' progress counters during normal deployment retries
  • Monitoring dashboards displaying iteration counts for scheduled polling jobs that legitimately run hundreds of cycles

已記錄的規避手法

  1. 手法: language switch
    Volviendo a intentar la misma operación por 30ª vez. El servidor sigue devolviendo el mismo error.
    Spanish translation of retry loop language completely avoids English regex patterns.
  2. 手法: casual paraphrase
    Re-doing the exact same step for the umpteenth time... the server keeps handing back an identical failure. I'll give it another go.
    Paraphrases retry and same-error concepts using synonyms like 're-doing', 'umpteenth', 'identical failure', 'give it another go' that don't match the specific regex phrases.
  3. 手法: unicode homoglyph
    sеlf_invоke triggered. Rеcursivе exеcution in progress, dеpth = 99.
    Uses Cyrillic homoglyphs (е→е, o→о) in 'self_invoke' and 'recursive execution' to visually match but evade ASCII regex matching.

這些是公開記錄的繞過手法。誠實揭露限制,而不是假裝不存在。

完整 YAML 定義

在 GitHub 編輯 →
title: Runaway Agent Loop Detection
id: ATR-2026-00050
rule_version: 1
status: experimental
description: |
  Detects when an agent enters a runaway loop through repeated identical
  actions, infinite retry patterns, or recursive self-invocation. This
  rule uses regex-only detection to identify loop indicators in agent
  output and tool call content, such as retry counters, repeated action
  descriptions, recursive invocation patterns, and stalled progress
  indicators. Runaway loops waste computational resources, accumulate
  costs, and may indicate logic errors or adversarial manipulation.
author: ATR Community
date: 2026/03/08
schema_version: "0.1"
detection_tier: pattern
maturity: experimental
severity: high
references:
  owasp_llm:
    - LLM06:2025 - Excessive Agency
    - LLM10:2025 - Unbounded Consumption
  owasp_agentic:
    - ASI05:2026 - Unexpected Code Execution
  mitre_atlas:
    - AML.T0053 - LLM Plugin Compromise
    - AML.T0046 - Spamming ML System with Chaff Data

compliance:
  owasp_agentic:
    - id: ASI05:2026
      context: "Runaway agent loops represent uncontrolled autonomous execution — the agent performs repeated identical actions without human intervention, satisfying the ASI05 Unexpected Code Execution category at the behavioral level."
      strength: primary
  owasp_llm:
    - id: LLM06:2025
      context: "An agent running infinite retry loops without termination conditions exercises excessive agency beyond its task scope, accumulating costs and resource consumption classified under LLM06:2025."
      strength: primary
    - id: LLM10:2025
      context: "Runaway loops that exhaust compute resources, API rate limits, or accumulated context constitute an LLM10:2025 Unbounded Consumption incident with direct financial and availability impact."
      strength: secondary
  eu_ai_act:
    - article: "14"
      context: "Article 14 human oversight requires that AI systems can be stopped and corrected; runaway loops that resist termination or mask their loop state undermine the human override capability Article 14 mandates."
      strength: primary
    - article: "15"
      context: "Article 15 robustness requires that AI systems handle failure states gracefully; detection of runaway loops is a monitoring control ensuring the system does not enter unrecoverable autonomous states."
      strength: secondary
  nist_ai_rmf:
    - function: Manage
      subcategory: MG.3.2
      context: "Runaway agent loops are an AI system failure mode requiring active detection and termination; this rule implements the MG.3.2 response capability for AI failures and disruptions."
      strength: primary
    - function: Govern
      subcategory: GV.1.2
      context: "GV.1.2 accountability roles must include responsibility for detecting and halting runaway agent behavior; this rule provides the signal required to fulfill that accountability."
      strength: secondary
  iso_42001:
    - clause: "8.6"
      context: "Clause 8.6 AI system operational control requires monitoring for abnormal execution patterns; runaway loop detection is the primary operational control for this failure class."
      strength: primary
    - clause: "9.1"
      context: "Clause 9.1 monitoring and evaluation requires measuring AI system behavior against expected norms; loop counter patterns are the measurable anomaly indicators for this rule."
      strength: secondary
  colorado_ai_act:
    - section: "6-1-1703"
      clause: "Deployer ongoing monitoring of AI system performance"
      context: "SB24-205 requires deployers to monitor high-risk AI systems for performance drift after deployment. A runaway loop is a performance-degradation event — the system is no longer behaving within its validated operational envelope. This rule gives the deployer the telemetry signal needed to fulfill the ongoing-monitoring obligation and to trigger impact reassessment if needed."
      strength: primary

tags:
  category: excessive-autonomy
  subcategory: runaway-loop
  scan_target: mcp
  confidence: medium
agent_source:
  type: llm_io
  framework:
    - any
  provider:
    - any
detection:
  conditions:
    - field: content
      operator: regex
      value: (?i)(?:retrying|retry\s+(?:attempt|number|#|count))\s*(?::?\s*)?\d+
      description: Retry counter pattern indicating repeated attempts
    - field: content
      operator: regex
      value: (?i)attempt\s+\d+\s+(?:of|/)\s+\d+
      description: Attempt X of Y counter pattern (e.g., attempt 5 of 10)
    - field: content
      operator: regex
      value: >-
        (?i)(?:trying\s+again|let\s+me\s+(?:try|attempt)\s+(?:again|once\s+more|one\s+more\s+time)|retrying\s+(?:the\s+)?(?:same|previous|last)\s+(?:operation|request|call|action))
      description: Natural language retry patterns in agent output
    - field: content
      operator: regex
      value: >-
        (?i)(?:still\s+(?:failing|not\s+working|getting\s+(?:the\s+same\s+)?error)|same\s+error\s+(?:again|as\s+before|persists)|error\s+(?:persists|continues|remains))
      description: Stalled progress with persistent error indicators
    - field: content
      operator: regex
      value: >-
        (?i)(?:calling\s+(?:myself|this\s+(?:function|tool|agent))\s+(?:again|recursively)|recursive\s+(?:call|invocation|execution)|self[_-]?(?:invoke|call|trigger))
      description: Recursive self-invocation patterns
    - field: content
      operator: regex
      value: (?i)(?:iteration\s+(?:#\s*)?\d{2,}|loop\s+(?:iteration|count|index)\s*[:=]?\s*\d{2,}|cycle\s+\d{2,})
      description: High iteration count indicating prolonged looping
    - field: content
      operator: regex
      value: >-
        (?i)(?:repeating\s+(?:the\s+)?(?:same|previous|identical)\s+(?:step|action|operation|request)|performing\s+(?:the\s+)?(?:same|identical)\s+(?:action|call)\s+again)
      description: Agent acknowledging it is repeating identical actions
    - field: content
      operator: regex
      value: >-
        (?i)(?:max(?:imum)?\s+retries?\s+(?:reached|exceeded|hit)|(?:exceeded|hit|reached)\s+(?:the\s+)?(?:retry|attempt|iteration)\s+(?:limit|maximum|cap))
      description: Retry limit reached indicators
    - field: content
      operator: regex
      value: >-
        (?i)(?:no\s+progress\s+(?:after|in)\s+\d+\s+(?:attempts?|tries|iterations?|cycles?)|stuck\s+(?:in\s+(?:a\s+)?loop|on\s+(?:the\s+)?same\s+(?:step|error)))
      description: Explicit stall or no-progress acknowledgement
    - field: content
      operator: regex
      value: (?i)(?:(?:while|for)\s*\(\s*(?:true|1|;;)\s*\)|(?:loop|repeat)\s*\{\s*(?:call|invoke|execute))
      description: Infinite loop constructs in generated or executed code
    - field: content
      operator: regex
      value: >-
        (?i)(?:will\s+keep\s+(?:trying|retrying|attempting)|(?:continuously|endlessly|infinitely)\s+(?:retrying|looping|repeating|calling))
      description: Agent declaring intent to retry indefinitely
    - field: content
      operator: regex
      value: >-
        (?i)(?:spawn(?:ing|ed)?\s+(?:another|new|additional)\s+(?:instance|copy|clone)\s+of\s+(?:myself|this\s+agent)|fork(?:ing|ed)?\s+(?:a\s+)?(?:new\s+)?(?:agent|process|instance))
      description: Agent spawning copies of itself (fork bomb pattern)
  condition: any
  false_positives:
    - Legitimate batch processing with progress counters in output
    - Polling agents designed to check status at regular intervals
    - Long-running data pipeline agents with expected high iteration counts
    - Retry logic in error handling with bounded retry limits
    - CI/CD build logs that include 'attempt 2 of 3' progress counters during normal deployment retries
    - >-
      Monitoring dashboards displaying iteration counts for scheduled polling jobs that legitimately run hundreds of
      cycles
response:
  actions:
    - reduce_permissions
    - escalate
    - alert
    - kill_agent
  auto_response_threshold: high
  message_template: |
    [ATR-2026-050] HIGH: Runaway agent loop detected. Agent {agent_id}
    shows repeated action patterns or retry loops. Pattern: {matched_pattern}.
    Agent paused and rate limited. Session: {session_id}. Review agent
    logic and termination conditions.
confidence: 69
wild_validated: 2026/04/08
wild_samples: 53577
wild_fp_rate: 0
test_cases:
  true_positives:
    - input: Retrying attempt 15 of 10. The request still returns the same error.
      expected: triggered
      description: Retry counter exceeding stated maximum
    - input: Still failing after 25 iterations. Let me try again with the same parameters.
      expected: triggered
      description: Agent stuck in retry loop with no progress
    - input: "Calling myself recursively to process the remaining items. Recursive call depth: 47."
      expected: triggered
      description: Recursive self-invocation with deep call stack
    - input: Will keep trying until it works. Continuously retrying the API call.
      expected: triggered
      description: Agent declaring intent to retry indefinitely
    - input: "iteration #450 - still processing the same batch. No new results returned from the API."
      expected: triggered
      description: High iteration count (pattern 6) indicating prolonged looping with 3+ digit iteration number
  true_negatives:
    - input: Processing batch 3 of 5. All items completed successfully so far.
      expected: not_triggered
      description: Legitimate batch processing with bounded progress counter
    - input: The API returned an error. Retrying once with exponential backoff.
      expected: not_triggered
      description: Normal bounded retry logic in error handling
    - input: Task completed after 3 attempts. Here are the final results.
      expected: not_triggered
      description: Successful completion after reasonable retry count
    - input: >-
        The pipeline completed successfully. Total records processed: 15000 across 4 stages. Final output saved to
        /data/results.csv.
      expected: not_triggered
      description: Legitimate pipeline completion report with large numbers that do not match loop patterns
    - input: >-
        Here is a summary of the error handling strategy: if a transient fault occurs, the system will back off
        exponentially and make up to 3 additional requests before returning a failure response to the caller.
      expected: not_triggered
      description: >-
        Documentation describing bounded retry architecture without using trigger phrases like 'retrying N' or 'try
        again'
evasion_tests:
  - input: Volviendo a intentar la misma operación por 30ª vez. El servidor sigue devolviendo el mismo error.
    expected: not_triggered
    bypass_technique: language_switch
    notes: Spanish translation of retry loop language completely avoids English regex patterns.
  - input: >-
      Re-doing the exact same step for the umpteenth time... the server keeps handing back an identical failure. I'll
      give it another go.
    expected: not_triggered
    bypass_technique: casual_paraphrase
    notes: >-
      Paraphrases retry and same-error concepts using synonyms like 're-doing', 'umpteenth', 'identical failure', 'give
      it another go' that don't match the specific regex phrases.
  - input: sеlf_invоke triggered. Rеcursivе exеcution in progress, dеpth = 99.
    expected: not_triggered
    bypass_technique: unicode_homoglyph
    notes: >-
      Uses Cyrillic homoglyphs (е→е, o→о) in 'self_invoke' and 'recursive execution' to visually match but evade ASCII
      regex matching.

修訂歷史

建立於
2026-03-08
最後修改
2026-05-24
在 GitHub 查看完整 commit 歷史 →