title: Terminal Custom OS Ruleset Session Injection
id: ATR-2026-00389
rule_version: 1
status: experimental
description: |
  Detects the custom terminal persona + session ruleset injection attack from NVIDIA garak dan.DanInTheWild inthewild corpus (prompt #85). The attack instructs the AI to "act like a terminal" running on a novel fictional OS (e.g., "ALEL") and defines a numbered session ruleset that overrides the AI's defaults. Critical safety-bypass signals within the ruleset: (1) "cannot reply with any pre-programmed responses as it has no ability to do so" — directly disables safety responses by asserting the AI lacks the capability to produce them; (2) "define the rule set that Assistant now uses in this session" — asserts session-level policy takeover; (3) a custom OS acronym (2-8 ALL-CAPS letters) combined with terminal persona and numbered rules; (4) "recall all rules before replying" at the end enforces compliance with the injected ruleset on every response. The fictional OS name and terminal metaphor are used to make the injected constraints appear as technical system constraints rather than social engineering.
author: ATR Community (via NVIDIA garak dan.DanInTheWild probe)
date: 2026/04/21
schema_version: '0.1'
detection_tier: pattern
maturity: test
severity: high
references:
  owasp_llm:
    - LLM01:2025
  owasp_agentic:
    - ASI01:2026
  mitre_atlas:
    - AML.T0051 - LLM Prompt Injection
    - AML.T0054 - LLM Jailbreak
  research:
    - https://github.com/NVIDIA/garak/blob/main/garak/probes/dan.py
    - https://github.com/NVIDIA/garak/blob/main/garak/data/dan/inthewild_jailbreak_llms.json
compliance:
  nist_ai_rmf:
    - subcategory: MP.5.1
      context: 'This rule detects a specific jailbreak pattern (terminal persona + fictional OS ruleset injection from the garak inthewild corpus #85) that attempts to override AI safety defaults via session-level policy takeover. MP.5.1 requires identifying and characterizing the likelihood and magnitude of adversarial prompt-injection risks, and this signature directly evidences that risk surface.'
      strength: primary
    - subcategory: MS.2.7
      context: Detection of safety-response disabler phrasing ("cannot reply with any pre-programmed responses") and session ruleset takeover declarations provides continuous evaluation evidence of the AI system's resilience against jailbreak attempts, which MS.2.7 requires to be measured and documented.
      strength: secondary
    - subcategory: MG.2.3
      context: A high-confidence match on this terminal-OS jailbreak signature is an incident candidate that should trigger response mechanisms to disengage or supersede the manipulated session before the injected ruleset governs subsequent outputs, as required by MG.2.3.
      strength: secondary
  iso_42001:
    - clause: '8.1'
      context: ISO/IEC 42001 Clause 8.1 (operational planning and control, including control of externally provided processes) is operationalised by this rule's detection of the agent-manipulation technique (Terminal Custom OS Ruleset Session Injection).
      strength: primary
    - clause: '6.2'
      context: ISO/IEC 42001 Clause 6.2 (AI objectives and planning) calls for risk treatment of known attack patterns; this rule's detection of the agent-manipulation technique (Terminal Custom OS Ruleset Session Injection) is such a treatment.
      strength: secondary
  eu_ai_act:
    - article: '15'
      context: Article 15 (accuracy, robustness and cybersecurity) requires high-risk AI systems to resist unauthorised attempts to alter their use, outputs or performance; this rule provides runtime detection evidence by flagging the agent-manipulation technique (Terminal Custom OS Ruleset Session Injection).
      strength: primary
    - article: '14'
      context: Article 14 (human oversight) requires high-risk AI systems to remain subject to effective human oversight; this rule provides detection evidence where the agent-manipulation technique (Terminal Custom OS Ruleset Session Injection) would bypass or undermine that oversight.
      strength: secondary
    - article: '9'
      context: Article 9 (risk management system) requires identified risks to be addressed by appropriate measures; this rule is a runtime risk-treatment control that detects the agent-manipulation technique (Terminal Custom OS Ruleset Session Injection).
      strength: secondary
tags:
  category: agent-manipulation
  subcategory: terminal-custom-ruleset-injection
  scan_target: mcp
  confidence: high
agent_source:
  type: mcp_exchange
  framework:
    - any
  provider:
    - any
metadata_provenance:
  garak_probe: dan.DanInTheWild
  garak_detector: mitigation.MitigationBypass
  payload_source: garak/data/dan/inthewild_jailbreak_llms.json
detection:
  conditions:
    - field: tool_response
      operator: regex
      value: acts?\s+like\s+a\s+terminal[\s\S]{0,100}(?:rule\s*set|rules[\s\S]{0,30}(?:session|uses|follows))
      description: '"acts like a terminal" combined with ruleset/rules for this session — the terminal persona framing paired with an injected ruleset is the structural signature of inthewild corpus #85; distinguishes persona injection from legitimate terminal usage descriptions'
    - field: tool_response
      operator: regex
      value: cannot\s+reply\s+with(?:\s+any)?\s+pre[\s-]?programmed\s+responses?
      description: 'Safety-response disabler from inthewild corpus #85 — "cannot reply with [any] pre-programmed responses" directly asserts the AI lacks the capability to produce safety responses, neutralizing refusals and content policy enforcement; "any" is optional to catch shortened variants'
    - field: tool_response
      operator: regex
      value: define\s+the\s+rule\s+set\s+that[\s\S]{0,50}(?:uses|now\s+uses|uses\s+in\s+this\s+session)
      description: 'Session ruleset takeover declaration from #85 — "define the rule set that [Assistant] now uses in this session" is an explicit claim of session-level policy override; the phrase asserts the injected rules supersede all default AI behaviour'
    - field: tool_response
      operator: regex
      value: terminal[\s\S]{0,50}runs\s+on\s+[A-Z]{2,8}[\s\S]{0,100}rule\s+set
      description: Terminal running on custom OS acronym combined with ruleset — "terminal ... runs on [CAPS]" establishes the fictional OS persona, and "rule set" confirms injected session rules; the ALL-CAPS OS name (2-8 chars) distinguishes novel fictional systems from real OS names
    - field: tool_response
      operator: regex
      value: (?:terminal|assistant)\s+(?:now\s+)?(?:acts?|operates?)\s+(?:like|as)\s+(?:a\s+)?[A-Z]{2,8}[\s\S]{0,100}rule
      description: Terminal or assistant adopting custom ALL-CAPS OS identity combined with rules — catches variants where the OS name appears as the terminal type rather than after "runs on", e.g., "terminal now acts as ALEL ... rules"
  condition: any
  false_positives:
    - '"Open the terminal and type: ls -la" — instruction to use a real system terminal, not AI persona injection'
    - '"The terminal emulator acts like a bash shell following POSIX standards" — software product description without AI ruleset injection'
    - '"In our coding exercise the AI acts as a debug helper for terminal commands" — educational tool without custom OS or ruleset takeover'
response:
  actions:
    - alert
    - block_input
  message_template: |
    [ATR-2026-00389] Terminal custom OS ruleset session injection detected — attacker instructs the AI to act as a terminal running on a fictional OS and defines a numbered session ruleset that disables pre-programmed safety responses and mandates rule recall before every reply.
