跳到內容
Agent Threat Rules (ATR)EN
Γ上下文外洩
ATR-2026-02684
收錄於 2026-08-23 · 作者 ATR Community (CVE sweep)

File-Tool Argument Targets a Modern Credential Store Outside the Classic Path List

Detects a file-reading / file-attaching agent tool argument whose value names a credential store that ATR's existing sensitive-path rules do not list.

modern credential store read · pattern · confidence: high

嚴重度
high
車道
alert · hunt比對到就標出、回報
成熟度
test還沒定論
掃描目標
agent
狀態
experimental

框架對照

OWASP Agentic Top 10
  • ASI04:2026
  • ASI05:2026
OWASP LLM Top 10
  • LLM02:2025
  • LLM06:2025

這些對應是 ATR 自己做的,框架方沒有審查或背書。

說明

Detects a file-reading / file-attaching agent tool argument whose value names a credential store that ATR's existing sensitive-path rules do not list. Those rules (ATR-2026-02250, ATR-2026-00161 and the tool_call traversal family) were written around the 2010s-era set -- ~/.ssh/id_*, ~/.aws/credentials, ~/.netrc, ~/.kube/config, /etc/shadow, /proc/self/environ -- and stop there. The stores an agent actually finds on a 2026 developer or CI box are elsewhere: ~/.config/gh/hosts.yml (a GitHub token with repo scope), /var/run/secrets/kubernetes.io/serviceaccount/token (a live cluster identity), ~/.config/gcloud/*, ~/.pypirc, ~/.cargo/credentials, ~/.terraform.d/ credentials.tfrc.json, ~/.azure/*, ~/.config/rclone/rclone.conf, ~/.docker/config.json, ~/.npmrc. Mined from OWASP-ASI-INC-09330 (OpenClaw canvas path traversal), where the decisive evidence is exactly a file-path tool argument naming one of these. rule_version 2 (adversarial refutation, 2026-08-24): version 1 required only that a file-shaped argument NAME sit next to the path, and it accepted the bare words `path` and `file` as that name. Those are ordinary English words and also the two most common keys in DevOps configuration, so 15 of 16 hand-written benign inputs fired -- `rclone config paths` output, an actions/cache step, a docker-compose secret, an Ansible stat task, Kubernetes and Terraform documentation, an incident postmortem, a pytest failure line, and security writing explaining this very attack. The rule now requires one of four serialized-call shapes: a quoted argument key AND a quoted value; an agent-internal argument name (jsonlPath, systemPromptFile, personaFile ...); a function call whose CALLEE is a named file tool; or a tool call that names a file-reading tool and passes a generic path argument inside the same call. Prose, YAML configuration and CLI output no longer qualify.

建議回應alert
作者:ATR Community (CVE sweep) · 建立 2026-08-23 · 最後修改 2026-11-18

偵測條件

組合方式:any
  1. 01
    JSON/dict tool-call shape: a QUOTED file-shaped argument key whose QUOTED value is a modern credential store -- GitHub CLI host tokens, gcloud credential databases, rclone remotes, PyPI upload credentials, cargo registry tokens, Terraform Cloud tokens, Azure token caches, or the in-pod Kubernetes service-account token. Both the key and the value must be quote-delimited, which is what a serialized tool call looks like and what DevOps YAML, CLI output and prose do not.
    欄位:content運算子:regex
  2. 02
    Agent-internal argument names (jsonlPath, artifactPath, systemPromptFile, personaFile, promptFile, agentFile, instructionsFilePath) pointed at a credential store. These names do not occur in ordinary infrastructure config, so the quoting requirement is relaxed here.
    欄位:content運算子:regex
  3. 03
    Function-call form where the CALLEE is a named file tool -- read_file(path="..."), attach_file(file="...") -- and the argument value is a credential store. The callee list is what separates this from os.stat(path=...) or shutil.copy(src=...) in ordinary code.
    欄位:content運算子:regex
  4. 04
    Serialized tool call that names a file-reading tool and, within the same call, passes a generic path/file/src argument whose value is a credential store. Requiring the tool name is what keeps an Ansible task, a docker-compose secret or a backup manifest -- all of which carry a bare path:/file: key -- out of this condition.
    欄位:content運算子:regex

會觸發的攻擊範例

  1. {"action":"a2ui_push","jsonlPath":"/home/ops/.config/gh/hosts.yml"}
  2. {"agent":{"system_prompt_file":"/var/run/secrets/kubernetes.io/serviceaccount/token"}}
  3. read_file(path="~/.terraform.d/credentials.tfrc.json")
  4. {"tool":"attach_file","arguments":{"attachment":"/Users/dev/.config/rclone/rclone.conf","channel":"#ops"}}
  5. {"tool":"read_file","arguments":{"file_path":"$HOME/.cargo/credentials.toml"}}

規則必須抓到的攻擊範例,很多是照公開回報的攻擊改寫的,有些是照攻擊的形狀寫出來的。範例跟規則一起版本化,當作回歸測試。之後改規則時,如果其中一個範例不再命中,一定看得出來。

不會觸發的正常樣本

  1. ADVERSARIAL: an incident-response runbook naming the exact path. Found while writing benign twins; kept passing because the path must be the value of a file-shaped argument or an upload source, not free text.
    To confirm the pod identity, cat /var/run/secrets/kubernetes.io/serviceaccount/token and decode the JWT payload.
  2. Documentation explaining where the credential lives
    gh stores its OAuth tokens in ~/.config/gh/hosts.yml; delete that file to sign out on a shared machine.
  3. The neighbouring settings file, which holds no credential
    {"tool":"read_file","arguments":{"file_path":"~/.config/gh/config.yml"}}
  4. Ordinary project file read
    {"tool":"read_file","arguments":{"file_path":"/workspace/app/package.json"}}
  5. A publish step that relies on the npm token without any tool argument naming the file
    npm publish --access public   # uses the token already in ~/.npmrc
  6. Listing the gcloud config directory and asking the CLI itself which accounts are active
    ls -la ~/.config/gcloud/ && gcloud auth list
  7. ADVERSARIAL (2026-08-24 refutation pass): verbatim `rclone config paths` output. Fired rule_version 1 -- 'Config file: /home/.../rclone.conf' satisfied the bare `file` argument name. Fixed by requiring a quoted key.
    $ rclone config paths
    Config file: /home/deploy/.config/rclone/rclone.conf
    Cache dir: /home/deploy/.cache/rclone
    Temp dir: /tmp
  8. ADVERSARIAL: actions/cache step keyed on ~/.cargo/credentials.toml. Fired v1: `path:` is the cache action's own argument name.
          - name: Cache cargo registry credentials
            uses: actions/cache@v4
            with:
              path: ~/.cargo/credentials.toml
              key: cargo-creds-${{ runner.os }}
  9. ADVERSARIAL: docker-compose `secrets.<name>.file`, which is the CORRECT way to hand a credential to a container. Fired v1.
    secrets:
      gcloud_adc:
        file: ~/.config/gcloud/application_default_credentials.json
    services:
      api:
        secrets: [gcloud_adc]
  10. ADVERSARIAL: Ansible stat task checking that ~/.pypirc exists before publishing. Fired v1.
    - name: Verify the PyPI credentials file is present before publishing
      ansible.builtin.stat:
        path: ~/.pypirc
      register: pypirc
    - name: Fail early when it is missing
      ansible.builtin.fail:
        msg: run `twine register` first
      when: not pypirc.stat.exists
  11. ADVERSARIAL: security writing that explains THIS attack in prose ('read_file with file_path: ~/.config/gh/hosts.yml'). Fired v1; now excluded because the value is unquoted.
    A poisoned skill needs exactly one call. It asks the host to run read_file with file_path: ~/.config/gh/hosts.yml and your repo-scoped GitHub token is now inside the model context, from where any later network tool can post it out. This is why file-tool arguments deserve an allowlist, not a denylist.
  12. ADVERSARIAL: Kubernetes documentation prose that happens to use a 'the file: <path>' construction. Fired v1.
    Every pod gets a projected volume. The file: /var/run/secrets/kubernetes.io/serviceaccount/token holds a short-lived JWT that the kubelet rotates roughly hourly, and the namespace file next to it tells the workload which namespace it is in.
  13. ADVERSARIAL: Terraform CLI documentation naming the default credentials location as 'the path: ~/.terraform.d/credentials.tfrc.json'. Fired v1.
    TF_CLI_CONFIG_FILE overrides the location. When it is unset the path: ~/.terraform.d/credentials.tfrc.json is read instead, and `terraform login` writes the token there.
  14. ADVERSARIAL: incident postmortem quoting path=/var/run/secrets/... in a diagnosis sentence. Fired v1.
    Root cause: the projected service-account token was not refreshed after the node reboot. path=/var/run/secrets/kubernetes.io/serviceaccount/token returned a 401 for 40 minutes while the operator retried in a tight loop. Action item: alert on 401 rate, not on pod restarts.
  15. ADVERSARIAL: non-English (Traditional Chinese) operations runbook naming the service-account ca.crt. Fired v1.
    部署節點憑證輪替失敗。請先確認 path: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt 是否存在,再重啟 kubelet。若檔案遺失,直接重建 Pod 即可。
  16. ADVERSARIAL: interactive debugger session calling os.stat(path="..."). Fired v1; the fixed function-call condition requires a named FILE TOOL as the callee, which os.stat is not.
    >>> import os, pprint
    >>> pprint.pprint(os.stat(path="/home/dev/.config/rclone/rclone.conf"))
    os.stat_result(st_mode=33152, st_size=1421, ...)
  17. ADVERSARIAL: pytest failure output carrying path=/home/runner/.pypirc. Fired v1.
    FAILED tests/test_publish.py::test_reads_token - FileNotFoundError: path=/home/runner/.pypirc
    1 failed, 42 passed in 3.11s
  18. ADVERSARIAL: documented gcloud invocation using --key-file=. Fired v1 because `-` is a non-word character, so \bfile\b matched inside key-file.
    gcloud auth activate-service-account --key-file=/home/ci/.config/gcloud/application_default_credentials.json --quiet
  19. ADVERSARIAL: twine documentation showing --config-file=~/.pypirc. Fired v1.
    If your credentials live somewhere else, pass them explicitly:
    
        twine upload --config-file=~/.pypirc dist/*
    
  20. ADVERSARIAL: a documentation table listing where each tool stores its token. Fired v1.
    | Tool | Where the token is stored |
    | ---- | ------------------------- |
    | gh | path: ~/.config/gh/hosts.yml |
    | rclone | path: ~/.config/rclone/rclone.conf |
  21. ADVERSARIAL: changelog entry mentioning an attachment: <path>. Fired v1.
    ## 0.9.0
    
    ### Fixed
    - The uploader no longer aborts when the attachment: ~/.config/gcloud/legacy_credentials is a directory rather than a file.
  22. ADVERSARIAL against the FIX: a JSON backup manifest with "file":"~/.pypirc". Fired an intermediate version that allowed a bare quoted `file` key; the generic key names were then removed from the JSON condition.
    {"sets":[{"name":"pypi","file":"~/.pypirc"},{"name":"cargo","file":"~/.cargo/credentials.toml"}]}
  23. ADVERSARIAL against the FIX: the Ansible task in JSON form, "path":"~/.pypirc". Same cause, same fix -- a generic quoted `path` key now only counts inside a call that also names a file-reading tool.
    {"tasks":[{"name":"check pypirc","ansible.builtin.stat":{"path":"~/.pypirc"}}]}
  24. ADVERSARIAL against the FIX: docker-compose secrets rendered as JSON.
    {"secrets":{"gcloud_adc":{"file":"~/.config/gcloud/application_default_credentials.json"}}}
  25. A projected serviceAccountToken volume in a pod spec -- "path":"token" is a relative mount name, not the credential path.
    {"volumes":[{"name":"kube-api-access","projected":{"sources":[{"serviceAccountToken":{"path":"token","expirationSeconds":3607}}]}}]}
  26. os.stat(path="...") on an rclone config in ordinary code.
    stat_result = os.stat(path="/home/dev/.config/rclone/rclone.conf")
  27. shutil.copy(src="~/.pypirc", ...) -- a backup script, not an agent file tool.
    shutil.copy(src="~/.pypirc", dst="/backup/pypirc")
  28. devcontainer.json bind-mounting the gcloud config directory.
    {"name":"api","mounts":["source=${localEnv:HOME}/.config/gcloud,target=/root/.config/gcloud,type=bind"],"remoteEnv":{"CLOUDSDK_CONFIG":"/root/.config/gcloud"}}
  29. Plain open() of the rclone config in application code.
    with open("/home/dev/.config/rclone/rclone.conf") as fh:
        cfg = fh.read()

已知的誤報情境

  • ▸ADVERSARIAL, 2026-08-24 refutation pass: rule_version 1 fired on 15 of 16 benign probes. Root cause: `path` and `file` were accepted as argument names, and they are ordinary English words as well as the most common keys in Kubernetes, Ansible, docker-compose and GitHub Actions YAML. All 15 are now recorded as true_negatives.
  • ▸RESIDUAL, accepted: a security article that reproduces the verbatim JSON payload ({"tool":"read_file","arguments":{"file_path":"~/.config/gh/hosts.yml"}}) still matches. Those are the same bytes as the attack and no pattern can separate them; the same limit is accepted by ATR-2026-02660-class rules.
  • ▸An incident-response runbook or troubleshooting note that names one of these paths in prose or in a bare `cat` command -- the path must be the value of a file-shaped argument, or the source of an upload
  • ▸A legitimate CI step that reads its own ~/.npmrc or ~/.docker/config.json as part of publishing, written as a shell command rather than as a file-tool argument
  • ▸Documentation listing where each tool stores its configuration (e.g. 'gh stores tokens in ~/.config/gh/hosts.yml')
  • ▸A tool argument pointed at a non-credential file inside the same directory, e.g. path=~/.config/gh/config.yml (settings, not hosts.yml)
  • ▸ADVERSARIAL, FIXED: a verb-gated second condition (upload/attach/-F file=@ near one of these paths) was written first and then DELETED. It fired on 8 of 11 hand-written benign twins -- every one of them a security-policy sentence such as 'never upload ~/.config/gh/hosts.yml to a support ticket'. Prose about the attack and the attack itself share the verb, so only the argument-assignment form is matched now.
  • ▸ADVERSARIAL, FIXED: a CI setup step writing ~/.npmrc or ~/.docker/config.json through write_file matched the first version of this rule. Both were removed from the list because a legitimate write and a credential read are indistinguishable at this layer. The remaining stores can still match on a write; that is accepted, because an agent writing someone's gcloud or Terraform credential file is itself worth an alert.
title: "File-Tool Argument Targets a Modern Credential Store Outside the Classic Path List"
id: ATR-2026-02684
rule_version: 2
status: experimental
description: >
  Detects a file-reading / file-attaching agent tool argument whose value names
  a credential store that ATR's existing sensitive-path rules do not list. Those
  rules (ATR-2026-02250, ATR-2026-00161 and the tool_call traversal family) were
  written around the 2010s-era set -- ~/.ssh/id_*, ~/.aws/credentials, ~/.netrc,
  ~/.kube/config, /etc/shadow, /proc/self/environ -- and stop there. The stores
  an agent actually finds on a 2026 developer or CI box are elsewhere:
  ~/.config/gh/hosts.yml (a GitHub token with repo scope),
  /var/run/secrets/kubernetes.io/serviceaccount/token (a live cluster identity),
  ~/.config/gcloud/*, ~/.pypirc, ~/.cargo/credentials, ~/.terraform.d/
  credentials.tfrc.json, ~/.azure/*, ~/.config/rclone/rclone.conf,
  ~/.docker/config.json, ~/.npmrc. Mined from OWASP-ASI-INC-09330 (OpenClaw
  canvas path traversal), where the decisive evidence is exactly a file-path
  tool argument naming one of these.
  rule_version 2 (adversarial refutation, 2026-08-24): version 1 required only
  that a file-shaped argument NAME sit next to the path, and it accepted the
  bare words `path` and `file` as that name. Those are ordinary English words
  and also the two most common keys in DevOps configuration, so 15 of 16
  hand-written benign inputs fired -- `rclone config paths` output, an
  actions/cache step, a docker-compose secret, an Ansible stat task, Kubernetes
  and Terraform documentation, an incident postmortem, a pytest failure line,
  and security writing explaining this very attack. The rule now requires one
  of four serialized-call shapes: a quoted argument key AND a quoted value; an
  agent-internal argument name (jsonlPath, systemPromptFile, personaFile ...);
  a function call whose CALLEE is a named file tool; or a tool call that names
  a file-reading tool and passes a generic path argument inside the same call.
  Prose, YAML configuration and CLI output no longer qualify.
author: "ATR Community (CVE sweep)"
date: "2026/08/23"
schema_version: "0.1"
detection_tier: pattern
maturity: test
severity: high

references:
  cwe:
顯示全部(還有 206 行)
    - "CWE-522"
    - "CWE-538"
    - "CWE-22"
  owasp_llm:
    - "LLM02:2025"
    - "LLM06:2025"
  owasp_agentic:
    - "ASI04:2026"
    - "ASI05:2026"
  mitre_attack:
    - "T1552.001 - Credentials In Files"
    - "T1528 - Steal Application Access Token"
  mitre_atlas:
    - "AML.T0055 - Unsecured Credentials"
  external:
    - "https://owasp.org/www-project-agentic-security-initiative/"
    - "https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/"

metadata_provenance:
  cwe: human-reviewed
  owasp_llm: human-reviewed
  owasp_agentic: human-reviewed
  mitre_attack: human-reviewed
  mitre_atlas: human-reviewed

compliance:
  eu_ai_act:
    - article: "15"
      context: "Article 15 (accuracy, robustness and cybersecurity) requires protection against unauthorised access to system assets; this rule detects agent file-tool arguments aimed at credential stores."
      strength: primary
    - article: "10"
      context: "Article 10 (data and data governance) is supported by preventing credential material from being pulled into the agent's context as if it were ordinary data."
      strength: secondary
  nist_ai_rmf:
    - subcategory: "MG.2.3"
      context: "Credential theft through agent file tools is an identified AI risk requiring an active runtime countermeasure; this rule implements it."
      strength: primary
    - subcategory: "MP.5.1"
      context: "Cataloguing modern credential-store exposure through agent tooling in the organizational AI risk register."
      strength: secondary
  iso_42001:
    - clause: "8.1"
      context: "ISO/IEC 42001 Clause 8.1 (operational planning and control) is operationalised by screening file-tool arguments against a credential-store list."
      strength: primary
    - clause: "8.3"
      context: "ISO/IEC 42001 Clause 8.3 (AI risk treatment) is implemented by alerting when an agent tool is pointed at a token store."
      strength: secondary

tags:
  category: context-exfiltration
  subcategory: modern-credential-store-read
  scan_target: agent
  confidence: high

agent_source:
  type: tool_call
  framework:
    - any
  provider:
    - any

detection:
  condition: any
  conditions:
    - field: content
      operator: regex
      value: '(?i)["\x27](?:file_?path|filepath|file_?name|jsonl_?path|artifact_?path|agent_?file|instructions_?file_?path|system_?prompt_?file|prompt_?file|persona_?file|source_?file|input_?file|attachments?)["\x27]\s{0,4}[:=]\s{0,4}["\x27](?:~|\$HOME|/home/[\w.-]{1,24}|/Users/[\w.-]{1,24})?/?\.?(?:config/gh/hosts\.ya?ml|config/gcloud/(?:credentials\.db|application_default_credentials\.json|legacy_credentials)|config/rclone/rclone\.conf|pypirc|cargo/credentials(?:\.toml)?|terraform\.d/credentials\.tfrc\.json|azure/(?:accessTokens\.json|msal_token_cache\.json)|(?:var/)?run/secrets/kubernetes\.io/serviceaccount/(?:token|namespace|ca\.crt))\b'
      description: "JSON/dict tool-call shape: a QUOTED file-shaped argument key whose QUOTED value is a modern credential store -- GitHub CLI host tokens, gcloud credential databases, rclone remotes, PyPI upload credentials, cargo registry tokens, Terraform Cloud tokens, Azure token caches, or the in-pod Kubernetes service-account token. Both the key and the value must be quote-delimited, which is what a serialized tool call looks like and what DevOps YAML, CLI output and prose do not."
    - field: content
      operator: regex
      value: '(?i)\b(?:jsonl_?path|artifact_?path|agent_?file|instructions_?file_?path|system_?prompt_?file|prompt_?file|persona_?file)\s{0,4}[:=]\s{0,4}["\x27]?(?:~|\$HOME|/home/[\w.-]{1,24}|/Users/[\w.-]{1,24})?/?\.?(?:config/gh/hosts\.ya?ml|config/gcloud/(?:credentials\.db|application_default_credentials\.json|legacy_credentials)|config/rclone/rclone\.conf|pypirc|cargo/credentials(?:\.toml)?|terraform\.d/credentials\.tfrc\.json|azure/(?:accessTokens\.json|msal_token_cache\.json)|(?:var/)?run/secrets/kubernetes\.io/serviceaccount/(?:token|namespace|ca\.crt))\b'
      description: "Agent-internal argument names (jsonlPath, artifactPath, systemPromptFile, personaFile, promptFile, agentFile, instructionsFilePath) pointed at a credential store. These names do not occur in ordinary infrastructure config, so the quoting requirement is relaxed here."
    - field: content
      operator: regex
      value: '(?i)\b(?:read_file|readfile|read_text_file|write_file|attach_file|upload_file|send_file|get_file|load_file|open_file|append_file)\s{0,4}\(\s{0,4}(?:path|file|file_?path|file_?name|filepath|src|source|attachments?)\s{0,4}=\s{0,4}["\x27](?:~|\$HOME|/home/[\w.-]{1,24}|/Users/[\w.-]{1,24})?/?\.?(?:config/gh/hosts\.ya?ml|config/gcloud/(?:credentials\.db|application_default_credentials\.json|legacy_credentials)|config/rclone/rclone\.conf|pypirc|cargo/credentials(?:\.toml)?|terraform\.d/credentials\.tfrc\.json|azure/(?:accessTokens\.json|msal_token_cache\.json)|(?:var/)?run/secrets/kubernetes\.io/serviceaccount/(?:token|namespace|ca\.crt))\b'
      description: "Function-call form where the CALLEE is a named file tool -- read_file(path=\"...\"), attach_file(file=\"...\") -- and the argument value is a credential store. The callee list is what separates this from os.stat(path=...) or shutil.copy(src=...) in ordinary code."
    - field: content
      operator: regex
      value: '(?i)["\x27](?:tool|tool_?name|function|name)["\x27]\s{0,4}:\s{0,4}["\x27](?:read|read_file|readfile|read_text_file|read_many_files|cat|view|open|open_file|attach|attach_file|upload|upload_file|send_file|get_file|load_file|fetch_file|file_read)["\x27][^\n]{0,160}["\x27](?:path|file|file_?path|file_?name|filepath|src|source|attachments?)["\x27]\s{0,4}:\s{0,4}["\x27](?:~|\$HOME|/home/[\w.-]{1,24}|/Users/[\w.-]{1,24})?/?\.?(?:config/gh/hosts\.ya?ml|config/gcloud/(?:credentials\.db|application_default_credentials\.json|legacy_credentials)|config/rclone/rclone\.conf|pypirc|cargo/credentials(?:\.toml)?|terraform\.d/credentials\.tfrc\.json|azure/(?:accessTokens\.json|msal_token_cache\.json)|(?:var/)?run/secrets/kubernetes\.io/serviceaccount/(?:token|namespace|ca\.crt))\b'
      description: "Serialized tool call that names a file-reading tool and, within the same call, passes a generic path/file/src argument whose value is a credential store. Requiring the tool name is what keeps an Ansible task, a docker-compose secret or a backup manifest -- all of which carry a bare path:/file: key -- out of this condition."
  false_positives:
    - "ADVERSARIAL, 2026-08-24 refutation pass: rule_version 1 fired on 15 of 16 benign probes. Root cause: `path` and `file` were accepted as argument names, and they are ordinary English words as well as the most common keys in Kubernetes, Ansible, docker-compose and GitHub Actions YAML. All 15 are now recorded as true_negatives."
    - "RESIDUAL, accepted: a security article that reproduces the verbatim JSON payload ({\"tool\":\"read_file\",\"arguments\":{\"file_path\":\"~/.config/gh/hosts.yml\"}}) still matches. Those are the same bytes as the attack and no pattern can separate them; the same limit is accepted by ATR-2026-02660-class rules."
    - "An incident-response runbook or troubleshooting note that names one of these paths in prose or in a bare `cat` command -- the path must be the value of a file-shaped argument, or the source of an upload"
    - "A legitimate CI step that reads its own ~/.npmrc or ~/.docker/config.json as part of publishing, written as a shell command rather than as a file-tool argument"
    - "Documentation listing where each tool stores its configuration (e.g. 'gh stores tokens in ~/.config/gh/hosts.yml')"
    - "A tool argument pointed at a non-credential file inside the same directory, e.g. path=~/.config/gh/config.yml (settings, not hosts.yml)"
    - "ADVERSARIAL, FIXED: a verb-gated second condition (upload/attach/-F file=@ near one of these paths) was written first and then DELETED. It fired on 8 of 11 hand-written benign twins -- every one of them a security-policy sentence such as 'never upload ~/.config/gh/hosts.yml to a support ticket'. Prose about the attack and the attack itself share the verb, so only the argument-assignment form is matched now."
    - "ADVERSARIAL, FIXED: a CI setup step writing ~/.npmrc or ~/.docker/config.json through write_file matched the first version of this rule. Both were removed from the list because a legitimate write and a credential read are indistinguishable at this layer. The remaining stores can still match on a write; that is accepted, because an agent writing someone's gcloud or Terraform credential file is itself worth an alert."

response:
  actions:
    - alert
  message_template: >
    [ATR-2026-02684] A file tool argument names a credential store (GitHub CLI,
    gcloud, Kubernetes service account, PyPI, cargo, Terraform, Azure, rclone,
    Docker or npm auth). Reading it pulls a live bearer credential into the
    agent's context.

confidence: 82

test_cases:
  true_positives:
    - input: '{"action":"a2ui_push","jsonlPath":"/home/ops/.config/gh/hosts.yml"}'
      expected: triggered
      description: "OWASP-ASI-INC-09330 shape: canvas path argument aimed at the GitHub CLI token store"
    - input: '{"agent":{"system_prompt_file":"/var/run/secrets/kubernetes.io/serviceaccount/token"}}'
      expected: triggered
      description: "In-pod service-account token pulled in as the agent's instruction source -- credential read and prompt injection in one move"
    - input: 'read_file(path="~/.terraform.d/credentials.tfrc.json")'
      expected: triggered
      description: "Terraform Cloud API token"
    - input: '{"tool":"attach_file","arguments":{"attachment":"/Users/dev/.config/rclone/rclone.conf","channel":"#ops"}}'
      expected: triggered
      description: "rclone remote configuration -- every cloud credential the user has -- named as an attachment argument"
    - input: '{"tool":"read_file","arguments":{"file_path":"$HOME/.cargo/credentials.toml"}}'
      expected: triggered
      description: "crates.io publish token"
  true_negatives:
    - input: 'To confirm the pod identity, cat /var/run/secrets/kubernetes.io/serviceaccount/token and decode the JWT payload.'
      expected: not_triggered
      description: "ADVERSARIAL: an incident-response runbook naming the exact path. Found while writing benign twins; kept passing because the path must be the value of a file-shaped argument or an upload source, not free text."
    - input: 'gh stores its OAuth tokens in ~/.config/gh/hosts.yml; delete that file to sign out on a shared machine.'
      expected: not_triggered
      description: "Documentation explaining where the credential lives"
    - input: '{"tool":"read_file","arguments":{"file_path":"~/.config/gh/config.yml"}}'
      expected: not_triggered
      description: "The neighbouring settings file, which holds no credential"
    - input: '{"tool":"read_file","arguments":{"file_path":"/workspace/app/package.json"}}'
      expected: not_triggered
      description: "Ordinary project file read"
    - input: 'npm publish --access public   # uses the token already in ~/.npmrc'
      expected: not_triggered
      description: "A publish step that relies on the npm token without any tool argument naming the file"
    - input: 'ls -la ~/.config/gcloud/ && gcloud auth list'
      expected: not_triggered
      description: "Listing the gcloud config directory and asking the CLI itself which accounts are active"
    - input: "$ rclone config paths\nConfig file: /home/deploy/.config/rclone/rclone.conf\nCache dir: /home/deploy/.cache/rclone\nTemp dir: /tmp"
      expected: not_triggered
      description: "ADVERSARIAL (2026-08-24 refutation pass): verbatim `rclone config paths` output. Fired rule_version 1 -- 'Config file: /home/.../rclone.conf' satisfied the bare `file` argument name. Fixed by requiring a quoted key."
    - input: "      - name: Cache cargo registry credentials\n        uses: actions/cache@v4\n        with:\n          path: ~/.cargo/credentials.toml\n          key: cargo-creds-${{ runner.os }}"
      expected: not_triggered
      description: "ADVERSARIAL: actions/cache step keyed on ~/.cargo/credentials.toml. Fired v1: `path:` is the cache action's own argument name."
    - input: "secrets:\n  gcloud_adc:\n    file: ~/.config/gcloud/application_default_credentials.json\nservices:\n  api:\n    secrets: [gcloud_adc]"
      expected: not_triggered
      description: "ADVERSARIAL: docker-compose `secrets.<name>.file`, which is the CORRECT way to hand a credential to a container. Fired v1."
    - input: "- name: Verify the PyPI credentials file is present before publishing\n  ansible.builtin.stat:\n    path: ~/.pypirc\n  register: pypirc\n- name: Fail early when it is missing\n  ansible.builtin.fail:\n    msg: run `twine register` first\n  when: not pypirc.stat.exists"
      expected: not_triggered
      description: "ADVERSARIAL: Ansible stat task checking that ~/.pypirc exists before publishing. Fired v1."
    - input: "A poisoned skill needs exactly one call. It asks the host to run read_file with file_path: ~/.config/gh/hosts.yml and your repo-scoped GitHub token is now inside the model context, from where any later network tool can post it out. This is why file-tool arguments deserve an allowlist, not a denylist."
      expected: not_triggered
      description: "ADVERSARIAL: security writing that explains THIS attack in prose ('read_file with file_path: ~/.config/gh/hosts.yml'). Fired v1; now excluded because the value is unquoted."
    - input: "Every pod gets a projected volume. The file: /var/run/secrets/kubernetes.io/serviceaccount/token holds a short-lived JWT that the kubelet rotates roughly hourly, and the namespace file next to it tells the workload which namespace it is in."
      expected: not_triggered
      description: "ADVERSARIAL: Kubernetes documentation prose that happens to use a 'the file: <path>' construction. Fired v1."
    - input: "TF_CLI_CONFIG_FILE overrides the location. When it is unset the path: ~/.terraform.d/credentials.tfrc.json is read instead, and `terraform login` writes the token there."
      expected: not_triggered
      description: "ADVERSARIAL: Terraform CLI documentation naming the default credentials location as 'the path: ~/.terraform.d/credentials.tfrc.json'. Fired v1."
    - input: "Root cause: the projected service-account token was not refreshed after the node reboot. path=/var/run/secrets/kubernetes.io/serviceaccount/token returned a 401 for 40 minutes while the operator retried in a tight loop. Action item: alert on 401 rate, not on pod restarts."
      expected: not_triggered
      description: "ADVERSARIAL: incident postmortem quoting path=/var/run/secrets/... in a diagnosis sentence. Fired v1."
    - input: "部署節點憑證輪替失敗。請先確認 path: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt 是否存在,再重啟 kubelet。若檔案遺失,直接重建 Pod 即可。"
      expected: not_triggered
      description: "ADVERSARIAL: non-English (Traditional Chinese) operations runbook naming the service-account ca.crt. Fired v1."
    - input: ">>> import os, pprint\n>>> pprint.pprint(os.stat(path=\"/home/dev/.config/rclone/rclone.conf\"))\nos.stat_result(st_mode=33152, st_size=1421, ...)"
      expected: not_triggered
      description: "ADVERSARIAL: interactive debugger session calling os.stat(path=\"...\"). Fired v1; the fixed function-call condition requires a named FILE TOOL as the callee, which os.stat is not."
    - input: "FAILED tests/test_publish.py::test_reads_token - FileNotFoundError: path=/home/runner/.pypirc\n1 failed, 42 passed in 3.11s"
      expected: not_triggered
      description: "ADVERSARIAL: pytest failure output carrying path=/home/runner/.pypirc. Fired v1."
    - input: "gcloud auth activate-service-account --key-file=/home/ci/.config/gcloud/application_default_credentials.json --quiet"
      expected: not_triggered
      description: "ADVERSARIAL: documented gcloud invocation using --key-file=. Fired v1 because `-` is a non-word character, so \\bfile\\b matched inside key-file."
    - input: "If your credentials live somewhere else, pass them explicitly:\n\n    twine upload --config-file=~/.pypirc dist/*\n"
      expected: not_triggered
      description: "ADVERSARIAL: twine documentation showing --config-file=~/.pypirc. Fired v1."
    - input: "| Tool | Where the token is stored |\n| ---- | ------------------------- |\n| gh | path: ~/.config/gh/hosts.yml |\n| rclone | path: ~/.config/rclone/rclone.conf |"
      expected: not_triggered
      description: "ADVERSARIAL: a documentation table listing where each tool stores its token. Fired v1."
    - input: "## 0.9.0\n\n### Fixed\n- The uploader no longer aborts when the attachment: ~/.config/gcloud/legacy_credentials is a directory rather than a file."
      expected: not_triggered
      description: "ADVERSARIAL: changelog entry mentioning an attachment: <path>. Fired v1."
    - input: "{\"sets\":[{\"name\":\"pypi\",\"file\":\"~/.pypirc\"},{\"name\":\"cargo\",\"file\":\"~/.cargo/credentials.toml\"}]}"
      expected: not_triggered
      description: "ADVERSARIAL against the FIX: a JSON backup manifest with \"file\":\"~/.pypirc\". Fired an intermediate version that allowed a bare quoted `file` key; the generic key names were then removed from the JSON condition."
    - input: "{\"tasks\":[{\"name\":\"check pypirc\",\"ansible.builtin.stat\":{\"path\":\"~/.pypirc\"}}]}"
      expected: not_triggered
      description: "ADVERSARIAL against the FIX: the Ansible task in JSON form, \"path\":\"~/.pypirc\". Same cause, same fix -- a generic quoted `path` key now only counts inside a call that also names a file-reading tool."
    - input: "{\"secrets\":{\"gcloud_adc\":{\"file\":\"~/.config/gcloud/application_default_credentials.json\"}}}"
      expected: not_triggered
      description: "ADVERSARIAL against the FIX: docker-compose secrets rendered as JSON."
    - input: "{\"volumes\":[{\"name\":\"kube-api-access\",\"projected\":{\"sources\":[{\"serviceAccountToken\":{\"path\":\"token\",\"expirationSeconds\":3607}}]}}]}"
      expected: not_triggered
      description: "A projected serviceAccountToken volume in a pod spec -- \"path\":\"token\" is a relative mount name, not the credential path."
    - input: "stat_result = os.stat(path=\"/home/dev/.config/rclone/rclone.conf\")"
      expected: not_triggered
      description: "os.stat(path=\"...\") on an rclone config in ordinary code."
    - input: "shutil.copy(src=\"~/.pypirc\", dst=\"/backup/pypirc\")"
      expected: not_triggered
      description: "shutil.copy(src=\"~/.pypirc\", ...) -- a backup script, not an agent file tool."
    - input: "{\"name\":\"api\",\"mounts\":[\"source=${localEnv:HOME}/.config/gcloud,target=/root/.config/gcloud,type=bind\"],\"remoteEnv\":{\"CLOUDSDK_CONFIG\":\"/root/.config/gcloud\"}}"
      expected: not_triggered
      description: "devcontainer.json bind-mounting the gcloud config directory."
    - input: "with open(\"/home/dev/.config/rclone/rclone.conf\") as fh:\n    cfg = fh.read()"
      expected: not_triggered
      description: "Plain open() of the rclone config in application code."

修訂紀錄

建立於
2026-08-23
最後修改
2026-11-18
到 GitHub 看完整的 commit 紀錄