Skip to content

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

feat(rules): add 3 credential-access rules — k8s, gpg, password managers

AnandSundar3fd8581bfe7b
diff --git a/rules/credential-access/gpg-keyring-access.rule.yaml b/rules/credential-access/gpg-keyring-access.rule.yaml
new file mode 100644
index 00000000..645bf18a
--- /dev/null
+++ b/rules/credential-access/gpg-keyring-access.rule.yaml
@@ -0,0 +1,86 @@
+id: gpg-keyring-access
+version: 1
+title: Agent read a GPG private key or exported a secret key
+description: >
+ The agent either read a file under the GnuPG private-key directory
+ (private-keys-v1.d/, secring.gpg, .gnupg/openpgp-revocs.d/ certificate
+ revocation, .gnupg/trustdb.gpg trust database, .gnupg/gpg-control files) OR
+ invoked gpg with --export-secret-keys, --export-secret-subkeys, or
+ --gen-key. Private GPG keys sign commits and decrypt sensitive mail; an
+ agent touching a private keyring is a high-value exfil signal. The rule
+ is anchored on the path or on a gpg subcommand, and explicitly excludes
+ the public keyring (pubring.gpg, *.asc public keys) since reading public
+ keys is a routine signature-verification operation.
+severity: high
+status: experimental
+posture: detect
+taxonomy:
+ owasp_llm: LLM02
+ mitre_atlas: AML.T0024
+
+match: >
+ (e.event.action == "file.read" && (
+ e.file.path.matches("(?i)(^|/)\\.gnupg/private-keys-v1\\.d/") ||
+ e.file.path.matches("(?i)(^|/)secring\\.gpg$") ||
+ e.file.path.matches("(?i)(^|/)\\.gnupg/(openpgp-revocs\\.d/|trustdb\\.gpg$)") ||
+ e.file.path.matches("(?i)(^|/)\\.gnupg/[^/]+\\.key$")
+ )) || (
+ e.event.action == "command.executed" && (
+ e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*gpg\\b[^;&|]*--export-secret-(keys|subkeys)\\b") ||
+ e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*gpg\\b[^;&|]*--gen-key\\b") ||
+ e.command.command.matches("(?i)(^|[;&|]\\s*|\\bsudo\\s+)\\s*gpg\\b[^;&|]*--card-status\\b[^;&|]*--with-keygrip\\b")
+ )
+ )
+
+emit:
+ reason: "Agent accessed a GPG private key (file read or secret-export invocation)"
+
+tests:
+ - name: read_private_keys_dir
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.gnupg/private-keys-v1.d/ABC123.key" }
+ session: { id: s1 }
+ - name: read_secring_gpg
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.gnupg/secring.gpg" }
+ session: { id: s1 }
+ - name: read_trustdb
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.gnupg/trustdb.gpg" }
+ session: { id: s1 }
+ - name: gpg_export_secret_keys
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gpg --export-secret-keys --armor 0xDEADBEEF" }
+ session: { id: s1 }
+ - name: gpg_export_secret_subkeys
+ verdict: match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gpg --export-secret-subkeys 0xCAFEBABE > /tmp/keys.asc" }
+ session: { id: s1 }
+ - name: read_public_keyring
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.gnupg/pubring.kbx" }
+ session: { id: s1 }
+ - name: gpg_list_keys
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gpg --list-keys" }
+ session: { id: s1 }
+ - name: gpg_verify_signature
+ verdict: no_match
+ events:
+ - event: { action: command.executed }
+ command: { command: "gpg --verify release.tar.gz.asc" }
+ session: { id: s1 }
diff --git a/rules/credential-access/kubernetes-secret-file-read.rule.yaml b/rules/credential-access/kubernetes-secret-file-read.rule.yaml
new file mode 100644
index 00000000..f3f19748
--- /dev/null
+++ b/rules/credential-access/kubernetes-secret-file-read.rule.yaml
@@ -0,0 +1,75 @@
+id: kubernetes-secret-file-read
+version: 1
+title: Agent read a Kubernetes secret-bearing file
+description: >
+ The agent read a Kubernetes credential or cluster-admin artifact: a kubeconfig
+ file under ~/.kube/, a service-account bearer token, or a path bearing the
+ kubeconfig / token naming convention. Kubeconfig files hold long-lived
+ cluster credentials and are the canonical high-value Kubernetes secret;
+ service-account tokens are the canonical runtime bearer secret. An agent
+ reading either is almost always a credential-exfiltration or lateral-movement
+ signal. The rule is anchored on the path (anchored to a slash or end of
+ string, or to specific file names) so unrelated files with "kube" in the
+ name (e.g. "kube-prometheus-stack/") do not fire.
+severity: high
+status: experimental
+posture: detect
+taxonomy:
+ owasp_llm: LLM02
+ mitre_atlas: AML.T0024
+
+match: >
+ e.event.action == "file.read" && (
+ e.file.path.matches("(?i)(^|/)\\.kube/config(-[^/]+)?$") ||
+ e.file.path.matches("(?i)(^|/)kubeconfig(\\.yaml|\\.yml)?$") ||
+ e.file.path.matches("(?i)(^|/)\\.kube/[^/]*kubeconfig[^/]*$") ||
+ e.file.path.matches("(?i)(^|/)(token|sa[-_]?token|service[-_]?account[-_]?token)(\\.csv)?$") ||
+ e.file.path.matches("(?i)/var/run/secrets/kubernetes\\.io/serviceaccount/(token|ca\\.crt|namespace)$")
+ )
+
+emit:
+ reason: "Agent read a Kubernetes secret-bearing file (kubeconfig or service-account token)"
+
+tests:
+ - name: read_kubeconfig
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.kube/config" }
+ session: { id: s1 }
+ - name: read_named_kubeconfig
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.kube/config-prod" }
+ session: { id: s1 }
+ - name: read_service_account_token
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/var/run/secrets/kubernetes.io/serviceaccount/token" }
+ session: { id: s1 }
+ - name: read_generic_kubeconfig_yaml
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/opt/clusters/kubeconfig.yaml" }
+ session: { id: s1 }
+ - name: read_ordinary_yaml
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/repo/deploy/k8s-manifest.yaml" }
+ session: { id: s1 }
+ - name: read_kube_prometheus_chart
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/repo/charts/kube-prometheus-stack/values.yaml" }
+ session: { id: s1 }
+ - name: read_kubeconfig_directory
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.kube/" }
+ session: { id: s1 }
diff --git a/rules/credential-access/password-manager-db-read.rule.yaml b/rules/credential-access/password-manager-db-read.rule.yaml
new file mode 100644
index 00000000..37dab9ec
--- /dev/null
+++ b/rules/credential-access/password-manager-db-read.rule.yaml
@@ -0,0 +1,82 @@
+id: password-manager-db-read
+version: 1
+title: Agent read a password-manager vault or DB
+description: >
+ The agent read a password-manager vault: a KeePass .kdbx file, the GNU pass
+ ~/.password-store/ tree, a 1Password database directory, a LastPass vault
+ file, or a Bitwarden vault directory. These files contain the user's full
+ set of credentials and an agent reading one is a near-certain
+ credential-exfiltration signal. The rule is anchored on a path component
+ specific to each manager (not on the .db extension generally) so unrelated
+ application databases (sqlite, leveldb) do not fire. Reads to a key file
+ for a vault are also covered.
+severity: high
+status: experimental
+posture: detect
+taxonomy:
+ owasp_llm: LLM02
+ mitre_atlas: AML.T0024
+
+match: >
+ e.event.action == "file.read" && (
+ e.file.path.matches("(?i)(^|/)[^/]+\\.kdbx$") ||
+ e.file.path.matches("(?i)(^|/)\\.password-store/") ||
+ e.file.path.matches("(?i)(^|/)(\\.1password|1Password)/") ||
+ e.file.path.matches("(?i)(^|/)\\.config/(1Password|Bitwarden|\\.1password)/") ||
+ e.file.path.matches("(?i)(^|/)(\\.lastpass|LastPass)/") ||
+ e.file.path.matches("(?i)(^|/)\\.bitwarden/") ||
+ e.file.path.matches("(?i)(^|/)\\.config/Bitwarden[^/]*\\.sqlite(\\.[0-9]+)?$")
+ )
+
+emit:
+ reason: "Agent read a password-manager vault or DB (KeePass / pass / 1Password / LastPass / Bitwarden)"
+
+tests:
+ - name: read_kdbx
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/Documents/vault.kdbx" }
+ session: { id: s1 }
+ - name: read_pass_store
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.password-store/work/github.gpg" }
+ session: { id: s1 }
+ - name: read_1password_dir
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.1password/agent.sock" }
+ session: { id: s1 }
+ - name: read_bitwarden_config_sqlite
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.config/Bitwarden/data.json" }
+ session: { id: s1 }
+ - name: read_lastpass_dir
+ verdict: match
+ events:
+ - event: { action: file.read }
+ file: { path: "/home/u/.lastpass/vault.pswd" }
+ session: { id: s1 }
+ - name: read_unrelated_sqlite
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/repo/app/data/cache.sqlite" }
+ session: { id: s1 }
+ - name: read_unrelated_db
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/opt/app/users.db" }
+ session: { id: s1 }
+ - name: read_password_file_mention
+ verdict: no_match
+ events:
+ - event: { action: file.read }
+ file: { path: "/repo/docs/passwords.md" }
+ session: { id: s1 }