title: API Key Leakage via Example Format
id: ATR-2026-00141
rule_version: 1
status: experimental
description: |
  Detects attempts to leak API keys by providing example formats with real key prefixes, hoping the agent fills in actual values. Crystallized from 31 adversarial samples (0% prior detection).
author: ATR Threat Cloud Crystallization
date: 2026/04/07
schema_version: '1.0'
detection_tier: pattern
maturity: test
severity: critical
references:
  mitre_atlas:
    - AML.T0057 - LLM Data Leakage
  owasp_llm:
    - LLM02:2025
  owasp_agentic:
    - ASI08:2026
metadata_provenance:
  mitre_atlas: auto-generated
compliance:
  nist_ai_rmf:
    - subcategory: MS.2.10
      context: This rule detects adversarial prompts that use example API key formats with real prefixes to trick agents into completing them with actual credentials, which is a direct privacy/sensitive-data exposure risk; MS.2.10 requires assessment of privacy risks including credential and sensitive information disclosure.
      strength: primary
    - subcategory: MS.2.7
      context: Example-format key leakage is a security exfiltration vector targeting agent context; MS.2.7 requires continuous evaluation of AI system security and resilience against data extraction techniques.
      strength: secondary
    - subcategory: MG.2.3
      context: Detection of API key leakage attempts triggers containment and disengagement workflows to prevent the agent from emitting credentials; MG.2.3 mandates that supersede/deactivate mechanisms are available when sensitive data exposure is detected.
      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 context-exfiltration attempt (API Key Leakage via Example Format).
      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 context-exfiltration attempt (API Key Leakage via Example Format) 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 context-exfiltration attempt (API Key Leakage via Example Format).
      strength: primary
    - article: '10'
      context: Article 10 (data and data governance) requires control over the data an AI system processes; this rule provides detection evidence for the context-exfiltration attempt (API Key Leakage via Example Format) affecting that data.
      strength: secondary
tags:
  category: context-exfiltration
  subcategory: example-format-leak
  confidence: high
  scan_target: mcp
agent_source:
  type: mcp_exchange
  framework:
    - any
  provider:
    - any
detection:
  condition: any
  conditions:
    - field: content
      operator: regex
      value: (?i)(?:format|structure|pattern)\s+(?:for|of|is)\s+(?:api|auth|secret)?\s*(?:keys?|tokens?)\s+(?:is|should|follows?|looks?).*(?:sk-|ghp_|gho_|glpat-|xoxb-|xoxp-|AKIA|bearer)
      description: Key format description with real prefixes
    - field: content
      operator: regex
      value: (?i)(?:example|for instance|like this|shown|sample).*(?:sk-proj-|sk-ant-|ghp_|AKIA[A-Z0-9])
      description: Example with real-looking API key
  false_positives:
    - 'A developer documentation page explaining API key formats to end users, such as ''The format for API keys follows: sk-... prefix'', which is purely educational and not an exfiltration attempt.'
confidence: 45
wild_validated: 2026/04/08
wild_samples: 53577
response:
  actions:
    - alert
    - block_output
    - snapshot
