Skip to content

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

2.0 KB
Raw Blame
id: env-secret-enumeration
version: 1
title: Environment dumped and grepped for secrets
description: >
  A command lists the process environment (env / printenv / `set`) and pipes it
  into a grep/filter for credential-shaped names (TOKEN, SECRET, KEY, PASSWORD,
  API_KEY, ACCESS_KEY). This is the classic agent secret-enumeration shape:
  harvesting live credential env vars rather than reading a file.
severity: high
status: stable
posture: detect
taxonomy:
  beacon_category: credential-access
  owasp_llm: LLM06
  mitre_atlas: AML.T0024

match: >
  e.event.action == "command.executed" &&
  e.command.command.matches("(?i)\\b(env|printenv|set)\\b") &&
  e.command.command.matches("\\|") &&
  e.command.command.matches("(?i)\\b(grep|egrep|fgrep|rg|ag|awk|sed)\\b") &&
  e.command.command.matches("(?i)(TOKEN|SECRET|PASSWORD|API[_-]?KEY|ACCESS[_-]?KEY)")

emit:
  reason: "Process environment enumerated and filtered for credential-named variables"

tests:
  - name: env_grep_secret
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "env | grep -i secret" }
        session: { id: s1 }
  - name: printenv_grep_token
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "printenv | grep TOKEN" }
        session: { id: s1 }
  - name: env_egrep_key_password
    verdict: match
    events:
      - event: { action: command.executed }
        command: { command: "env | egrep 'API_KEY|PASSWORD'" }
        session: { id: s1 }
  - name: plain_env_no_filter
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "env" }
        session: { id: s1 }
  - name: env_grep_non_secret
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "env | grep PATH" }
        session: { id: s1 }
  - name: unrelated_grep
    verdict: no_match
    events:
      - event: { action: command.executed }
        command: { command: "grep -r TODO src/" }
        session: { id: s1 }