The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(privacy): redact provider and platform keys that have no label beside them
aakashpawar1999d5da6ed4eb2b
diff --git a/docs/security/retention-redaction.mdx b/docs/security/retention-redaction.mdxindex 42a72c33..88a32217 100644--- a/docs/security/retention-redaction.mdx+++ b/docs/security/retention-redaction.mdx@@ -27,7 +27,7 @@ Redaction runs on retained text (prompts, command output, diffs, tool arguments| Authorization headers and flags | `Authorization: Bearer …`, `Authorization: Basic …`, `--password …`, `--token=…` || URL credentials | the password in `postgres://user:…@host`, `https://x-access-token:…@github.com` || Private keys | PEM and OpenSSH `PRIVATE KEY` blocks, including a block cut off before its end line |-| Recognizable tokens (the public type prefix stays, as in `ghp_[REDACTED]`) | Anthropic and OpenAI `sk-…`, AWS `AKIA…`/`ASIA…`, GitHub `ghp_…`/`github_pat_…`, GitLab `glpat-…`, Slack `xox…-` and `xapp-…`, Stripe `sk_live_…`, Google `AIza…`, npm, Hugging Face, Beacon keys and tokens (`bcn_api_…`, `bcn_device_…`, `bcn_enfdev_…`, `bcn_mcp_…`, `bcn_mcprt_…`, and the `beacon login` token `bcn_cli_…` with its `bcn_code_…`, `bcn_client_…` and `bcn_exchange_…` values), and JWTs |+| Recognizable tokens (the public type prefix stays, as in `ghp_[REDACTED]`) | Anthropic and OpenAI `sk-…`, AWS `AKIA…`/`ASIA…`, GitHub `ghp_…`/`github_pat_…`, GitLab `glpat-…`, Slack `xox…-` and `xapp-…`, Stripe `sk_live_…`, Google `AIza…`, npm, Hugging Face, HashiCorp Vault `hvs.…`, Groq `gsk_…`, Perplexity `pplx-…`, Replicate `r8_…`, xAI `xai-…`, LangSmith `lsv2_…`, Pinecone `pcsk_…`, DigitalOcean `dop_v1_…`, Databricks `dapi…`, PyPI `pypi-…`, Shopify `shpat_…`, Linear `lin_api_…`, Doppler `dp.pt.…`, SendGrid `SG.…`, Beacon keys and tokens (`bcn_api_…`, `bcn_device_…`, `bcn_enfdev_…`, `bcn_mcp_…`, `bcn_mcprt_…`, and the `beacon login` token `bcn_cli_…` with its `bcn_code_…`, `bcn_client_…` and `bcn_exchange_…` values), and JWTs || An AWS secret key beside its key id | the 40-character secret that follows an `AKIA…` or `ASIA…` key id within a few spaces, commas, colons, pipes or quotes, as in a credentials CSV (`AKIA…,wJalr…`) or a table |Redaction is pattern-based. A credential with no label and no recognizable shape, such as a bare random password, is not detected, so treat retained content as sensitive. Metadata-only forwarding is the control for keeping content off Beacon Cloud entirely, and [`beacon share`](/cli/share#metadata-only-endpoints) follows it: a Metadata-only endpoint shares no content either.diff --git a/pkg/asymptoteobserve/privacy.go b/pkg/asymptoteobserve/privacy.goindex f24fd5ce..f2e0f873 100644--- a/pkg/asymptoteobserve/privacy.go+++ b/pkg/asymptoteobserve/privacy.go@@ -456,6 +456,22 @@ var redactionRules = concatRules([]redactionRule{shapeRule(`\b(ya29\.)(?:c\.)?[0-9A-Za-z_-]{20,}`, "${1}"+redactedValue, "ya29."), // Google OAuth access tokenshapeRule(`\b(npm_)[A-Za-z0-9]{36}`, "${1}"+redactedValue, "npm_"), // npmshapeRule(`\b(hf_)[A-Za-z0-9]{30,}`, "${1}"+redactedValue, "hf_"), // Hugging Face+ // Model providers and developer platforms whose keys agents handle all day. Each length and+ // alphabet is gitleaks' rule of the same name, or trufflehog's detector where gitleaks has none.+ shapeRule(`\b(hv[sbr]\.)[A-Za-z0-9_-]{24,}`, "${1}"+redactedValue, "hvs.", "hvb.", "hvr."), // HashiCorp Vault+ shapeRule(`\b(gsk_)[A-Za-z0-9]{52}\b`, "${1}"+redactedValue, "gsk_"), // Groq+ shapeRule(`\b(pplx-)[A-Za-z0-9]{48}\b`, "${1}"+redactedValue, "pplx-"), // Perplexity+ shapeRule(`\b(r8_)[A-Za-z0-9_-]{37}`, "${1}"+redactedValue, "r8_"), // Replicate+ shapeRule(`\b(xai-)[A-Za-z0-9_]{80}\b`, "${1}"+redactedValue, "xai-"), // xAI+ shapeRule(`\b(lsv2_(?:pt|sk)_)[0-9a-f]{32}_[0-9a-f]{10}\b`, "${1}"+redactedValue, "lsv2_pt_", "lsv2_sk_"), // LangSmith+ shapeRule(`\b(pcsk_)[A-Za-z0-9]{5,6}_[A-Za-z0-9]{63}\b`, "${1}"+redactedValue, "pcsk_"), // Pinecone+ shapeRule(`\b(do[por]_v1_)[0-9a-f]{64}\b`, "${1}"+redactedValue, "dop_v1_", "doo_v1_", "dor_v1_"), // DigitalOcean+ shapeRule(`\b(dapi)[0-9a-f]{32}(?:-\d)?\b`, "${1}"+redactedValue, "dapi"), // Databricks+ shapeRule(`\b(pypi-)AgEIcHlwaS5vcmc[A-Za-z0-9_-]{50,}`, "${1}"+redactedValue, "pypi-AgEIcHlwaS5vcmc"), // PyPI upload token+ shapeRule(`\b(shp(?:at|ca|pa|ss)_)[a-fA-F0-9]{32}\b`, "${1}"+redactedValue, "shpat_", "shpca_", "shppa_", "shpss_"), // Shopify+ shapeRule(`\b(lin_api_)[A-Za-z0-9]{40}\b`, "${1}"+redactedValue, "lin_api_"), // Linear+ shapeRule(`\b(dp\.pt\.)[A-Za-z0-9]{43}\b`, "${1}"+redactedValue, "dp.pt."), // Doppler+ shapeRule(`\b(SG\.)[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}`, "${1}"+redactedValue, "SG."), // SendGrid// Beacon's own keys and tokens: API keys, device and enforcement keys, MCP tokens and their refresh// tokens, and the CLI sign-in's access token, authorization code, client and exchange values.shapeRule(`\b(bcn_(?:api|device|mcprt|mcp|enfdev|cli|code|client|exchange)_)[A-Za-z0-9_-]{8,}`, "${1}"+redactedValue, "bcn_"),diff --git a/pkg/asymptoteobserve/privacy_gate_test.go b/pkg/asymptoteobserve/privacy_gate_test.goindex b4367b26..de80b3d2 100644--- a/pkg/asymptoteobserve/privacy_gate_test.go+++ b/pkg/asymptoteobserve/privacy_gate_test.go@@ -18,6 +18,8 @@ var redactGateFragments = []string{"hunter2hunter2", "null", "true", "42", "https://", "postgres://user:", "pw", "@host", "://","sk-", "sk-ant-api03-", "AKIA", "ASIA", "ABCDEFGHIJKLMNOP", "ghp_", "gho_", "ghs_", "github_pat_","glpat-", "xoxb-", "xoxe-", "xapp-", "sk_live_", "rk_test_", "AIza", "ya29.", "npm_", "hf_", "bcn_api_", "bcn_device_",+ "hvs.", "hvb.", "gsk_", "pplx-", "r8_", "xai-", "lsv2_pt_", "lsv2_sk_", "pcsk_", "dop_v1_", "doo_v1_", "dapi",+ "pypi-AgEIcHlwaS5vcmc", "pypi-", "shpat_", "shpss_", "lin_api_", "dp.pt.", "SG.","bcn_cli_", "bcn_mcprt_", "bcn_code_", "bcn_client_", "bcn_exchange_", "bcn_mcp_", "bcn_enfdev_", "bcn_other_","AKIAIOSFODNN7EXAMPLE", "ASIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", "|", "/", "+","0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJ", "-----BEGIN RSA PRIVATE KEY-----",diff --git a/pkg/asymptoteobserve/privacy_test.go b/pkg/asymptoteobserve/privacy_test.goindex 10188801..1e1c8915 100644--- a/pkg/asymptoteobserve/privacy_test.go+++ b/pkg/asymptoteobserve/privacy_test.go@@ -168,6 +168,71 @@ func TestRedactStringRedactsCommonCredentialFormats(t *testing.T) {}}+// Keys for model providers and developer platforms that agents read and paste all day, often+// with no label beside them: a positional argument, a pasted line in a prompt, command output.+// Each length and alphabet is gitleaks' rule of the same name, or trufflehog's detector where+// gitleaks has none. Fixtures are built with strings.Repeat so secret scanners do not take them+// for live keys.+func TestRedactStringRedactsProviderTokenShapes(t *testing.T) {+ hex := func(n int) string { return strings.Repeat("0123456789abcdef", 8)[:n] }+ alnum := func(n int) string { return strings.Repeat("Ab3Cd4Ef5Gh6", 12)[:n] }+ tests := []struct {+ name, input, want string+ }{+ {"hashicorp vault service token", "export VAULT_ADDR=x; vault login " + "hvs." + alnum(90), "export VAULT_ADDR=x; vault login hvs.[REDACTED]"},+ {"hashicorp vault batch token", "token hvb." + alnum(138), "token hvb.[REDACTED]"},+ {"groq", `Groq(api_key_value="` + "gsk_" + alnum(52) + `")`, `Groq(api_key_value="gsk_[REDACTED]")`},+ {"perplexity", "use " + "pplx-" + alnum(48) + " for search", "use pplx-[REDACTED] for search"},+ {"replicate", "replicate " + "r8_" + alnum(36) + "-", "replicate r8_[REDACTED]"},+ {"xai", "key: " + "xai-" + alnum(80), "key: xai-[REDACTED]"},+ {"langsmith personal token", "lsv2_pt_" + hex(32) + "_" + hex(10), "lsv2_pt_[REDACTED]"},+ {"langsmith service key", "lsv2_sk_" + hex(32) + "_" + hex(10), "lsv2_sk_[REDACTED]"},+ {"pinecone", `Pinecone("` + "pcsk_" + alnum(6) + "_" + alnum(63) + `")`, `Pinecone("pcsk_[REDACTED]")`},+ {"digitalocean personal token", "doctl auth init -t " + "dop_v1_" + hex(64), "doctl auth init -t dop_v1_[REDACTED]"},+ {"digitalocean oauth token", "doo_v1_" + hex(64), "doo_v1_[REDACTED]"},+ {"databricks", "host=x " + "dapi" + hex(32) + "-2", "host=x dapi[REDACTED]"},+ {"pypi upload token", "twine upload -p " + "pypi-AgEIcHlwaS5vcmc" + alnum(60) + " dist/*", "twine upload -p pypi-[REDACTED] dist/*"},+ {"shopify admin token", "shpat_" + hex(32), "shpat_[REDACTED]"},+ {"shopify shared secret", "shpss_" + hex(32), "shpss_[REDACTED]"},+ {"linear", "lin_api_" + alnum(40), "lin_api_[REDACTED]"},+ {"doppler", "created service token " + "dp.pt." + alnum(43) + " for ci", "created service token dp.pt.[REDACTED] for ci"},+ {"sendgrid", "SG." + alnum(22) + "." + alnum(43), "SG.[REDACTED]"},+ }+ for _, tc := range tests {+ t.Run(tc.name, func(t *testing.T) {+ if got := RedactString(tc.input); got != tc.want {+ t.Fatalf("RedactString(%q) = %q, want %q", tc.input, got, tc.want)+ }+ })+ }+}++// Text that only resembles those keys stays readable: too short, the wrong alphabet, or the+// prefix inside a longer word.+func TestRedactStringLeavesProviderTokenLookalikes(t *testing.T) {+ for _, input := range []string{+ "gsk_short",+ "pplx-search is the package name",+ "r8_tooshort",+ "xai-sdk",+ "lsv2_pt_notahexvalue_atall",+ "pcsk_abc",+ "dop_v1_0123abcd",+ "dapi_reference and dapiVersion",+ "pip install pypi-simple",+ "shpat_ZZZZ",+ "lin_api_key",+ "dp.pt.short",+ "SG.aaaa.bbbb",+ "hvs.short",+ "rapidapi" + strings.Repeat("0", 32),+ } {+ if got := RedactString(input); got != input {+ t.Errorf("RedactString(%q) = %q, want it unchanged", input, got)+ }+ }+}+// An AWS secret key is recognized only next to its key id, keeps the separators around it, and a// longer run of key characters there is not taken for one.func TestRedactStringRedactsAnAWSSecretBesideItsKeyID(t *testing.T) {diff --git a/pkg/asymptoteobserve/redact_adjacent_test.go b/pkg/asymptoteobserve/redact_adjacent_test.goindex 46d745f6..9a6a3d11 100644--- a/pkg/asymptoteobserve/redact_adjacent_test.go+++ b/pkg/asymptoteobserve/redact_adjacent_test.go@@ -208,6 +208,10 @@ var adjacentSecrets = []string{"glpat-abcdefghijklmnopqrstuv", "xoxb-1234567890-abc", "sk_live_abcdefghijklmnop", "ya29.abcdefghijklmnopqrstuvwxyz","bcn_api_abcdefgh", "postgres://user:pw@host/db", "https://x-access-token:[email protected]", "token=abcdefgh12345678","Bearer abcdefghijk", "curl -u admin:hunter2 ", "abcdefgh12345678",+ "hvs." + strings.Repeat("Ab3_", 8), "gsk_" + strings.Repeat("Ab3C", 13), "r8_" + strings.Repeat("Ab3-", 9) + "x",+ "lsv2_pt_" + strings.Repeat("0a", 16) + "_" + strings.Repeat("0a", 5), "pcsk_Ab3Cd_" + strings.Repeat("Ab3", 21),+ "dapi" + strings.Repeat("0a", 16) + "-2", "pypi-AgEIcHlwaS5vcmc" + strings.Repeat("Ab3_", 13),+ "dp.pt." + strings.Repeat("Ab3", 14) + "C", "SG." + strings.Repeat("Ab", 11) + "." + strings.Repeat("Ab3", 14) + "C",}// Idempotence and the gate's equivalence over many random texts where secrets meet, beyond what