Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

5.0 KB
Raw Blame
id: cloud-cli-token-export
version: 1
title: Cloud or forge CLI prints a live access token
description: >
  A command asks a signed-in CLI to print a usable bearer credential: gcloud auth
  print-access-token or print-identity-token (also application-default), gh auth
  token, aws configure export-credentials, az account get-access-token, vault print
  token, heroku auth:token, doctl auth token, or kubectl create token. These never
  touch a credential file, so credential-file-read cannot see them, but the output
  is the same secret: a token the agent now holds in context and can send anywhere.
  Legitimate uses exist (piping into docker login, a one-off API call), so review
  what the token was used for in the same session.
severity: medium
status: stable
posture: detect
taxonomy:
  beacon_category: credential-access
  owasp_llm: LLM02
  mitre_atlas: AML.T0024

match: >
  e.event.action == "command.executed" && (
    e.command.command.matches("(?i)(^|[;&|(`]|\\$\\()\\s*(sudo\\s+)?(gcloud\\s+auth\\s+(application-default\\s+)?print-(access|identity)-token\\b|gh\\s+auth\\s+token\\b|aws\\s+configure\\s+export-credentials\\b|az\\s+account\\s+get-access-token\\b|vault\\s+print\\s+token\\b|heroku\\s+auth:token\\b|doctl\\s+auth\\s+token\\b|kubectl\\s+create\\s+token\\b)") ||
    e.command.command.matches("(?i)(\\bauth\\s+(application-default\\s+)?print-(access|identity)-token\\b|\\baccount\\s+get-access-token\\b|\\bconfigure\\s+export-credentials\\b|\\$\\(\\s*(gh\\s+auth\\s+token|vault\\s+print\\s+token|heroku\\s+auth:token|doctl\\s+auth\\s+token)\\b|\\[REDACTED\\]\\s+(auth\\s+token|print\\s+token|auth:token)\\b)")
  )

emit:
  reason: "Signed-in CLI printed a live access token (gcloud/gh/aws/az/vault/heroku/doctl/kubectl) \u2014 a credential now in the agent's context"

tests:
  - name: gcloud_access_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "gcloud auth print-access-token" }
        session: { id: s1 }
  - name: gcloud_adc_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "gcloud auth application-default print-access-token" }
        session: { id: s1 }
  - name: gh_auth_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "gh auth token" }
        session: { id: s1 }
  - name: aws_export_credentials
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "aws configure export-credentials --format env" }
        session: { id: s1 }
  - name: az_access_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "az account get-access-token --resource https://management.azure.com" }
        session: { id: s1 }
  - name: token_in_header_substitution
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "curl -H \"Authorization: Bearer $(gcloud auth print-access-token)\" https://storage.googleapis.com/storage/v1/b" }
        session: { id: s1 }
  - name: gh_token_piped
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "gh auth token | docker login ghcr.io -u me --password-stdin" }
        session: { id: s1 }
  - name: gh_token_assigned
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "GH_TOKEN=$(gh auth token) ./scripts/release.sh" }
        session: { id: s1 }
  - name: gh_token_in_header
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "curl -H \"Authorization: token $(gh auth token)\" https://api.github.com/user" }
        session: { id: s1 }
  - name: vault_print_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "vault print token" }
        session: { id: s1 }
  - name: kubectl_create_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "kubectl create token default -n kube-system" }
        session: { id: s1 }
  - name: gcloud_auth_list
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "gcloud auth list" }
        session: { id: s1 }
  - name: gh_auth_status
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "gh auth status" }
        session: { id: s1 }
  - name: aws_whoami
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "aws sts get-caller-identity" }
        session: { id: s1 }
  - name: az_account_show
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "az account show" }
        session: { id: s1 }
  - name: grep_mentions_command
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "grep -rn 'print-access-token' docs/" }
        session: { id: s1 }