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 a URL password when the scheme follows a word ending in _ (#1252)
kyle-elliott-asymptote4d5c9dea307e
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex bc48a72d..cf07e291 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -13,6 +13,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.Changes on `main` since v1.3.58. They ship in the next release.+- **A URL password after a word ending in `_` is redacted** · The URL rule needed its scheme to start a word, and `_` is a word character, so in `lsv2_sk_mysql://user:pw@host` the scheme `mysql` started no word and the password was kept. A scheme glued to a word that ends in `_` now counts too: `lsv2_sk_mysql://user:[REDACTED]@host`.+- **Codex tool results carry their output live, and MCP calls are MCP calls** · Codex's OpenTelemetry `codex.tool_result` sends a shell command's output, but Beacon kept it only in `raw.attributes`, so rules matching `command.output` saw Codex output only after `beacon endpoint codex sync`. The live event now records `command.output`, the exit code from the header Codex writes above the output (`Process exited with code N`, or `Exit code: N` for `shell` and `shell_command`), and the content marker, with `content.truncated` set when Codex cut the output itself. A nonzero exit or a reported failure raises the severity to `medium`. An MCP server's tool, which Codex reports by its bare name beside an `mcp__<server>` namespace, is now `mcp.tool_invoked` with `mcp.server`, `mcp.tool` and the name `mcp__<server>__<tool>`, and its reply is `gen_ai.tool.call.result`, so indirect-prompt-injection rules read it on both paths. Any other tool's result is `tool.completed` or `tool.failed` rather than `tool.invoked`, with its output as `gen_ai.tool.call.result`, and `tool.command` is the command line rather than the arguments JSON. The live collector and `codex sync` now read a tool result through one shared definition, so their two copies of a call agree. Both copies are still written when the sync runs, as before.- **Postman, Docker Hub, Supabase and Netlify tokens are redacted** · Written without a label beside them (a positional argument, a pasted line, command output), Postman API keys (`PMAK-…`), Docker Hub personal and organization access tokens (`dckr_pat_…`, `dckr_oat_…`), Supabase personal access tokens (`sbp_…`, `sbp_v0_…`, `sbp_oauth_…`) and secret API keys (`sb_secret_…`, the replacement for the `service_role` key), and Netlify personal access tokens (`nfp_…`) were kept as they were. Each is now redacted after its prefix, as in `dckr_pat_[REDACTED]`. Supabase publishable keys (`sb_publishable_…`) are meant to be public and stay readable.diff --git a/pkg/asymptoteobserve/privacy.go b/pkg/asymptoteobserve/privacy.goindex fe304ca1..d097684b 100644--- a/pkg/asymptoteobserve/privacy.go+++ b/pkg/asymptoteobserve/privacy.go@@ -468,8 +468,10 @@ var redactionRules = concatRules([]redactionRule{// start (a line, a quote, curl's -H), so prose that says "cookie:" keeps its sentence.foldedRule(`(?im)((?:^\s*|["']\s*|(?:-H|--header)(?:=|\s+)["']?)(?:set-)?cookie["']?\s*:\s*["']?)([^\n"'\\]+)`, "${1}"+redactedValue, isRedactedValue, "cookie").from(startLine),// The password in a URL's userinfo: `postgres://user:pw@host`, `https://x-access-token:[email protected]`,- // and with no user name, the way Redis URLs carry a password: `redis://:pw@host`.- foldedRule(`(?i)(\b[a-z][a-z0-9+.-]*://[^/\s:@"'<>]*:)([^@/\s"'<>]+)(@)`, "${1}"+redactedValue+"${3}", nil, "://").from(startScheme).runningOn(urlRunningOn),+ // and with no user name, the way Redis URLs carry a password: `redis://:pw@host`. The word the+ // scheme ends can hold an `_`, which no scheme does: of `lsv2_sk_mysql://user:pw@host` the scheme+ // is `mysql`, and the match starts with the word.+ foldedRule(`(?i)(\b[a-z0-9_+.-]*?[a-z][a-z0-9+.-]*://[^/\s:@"'<>]*:)([^@/\s"'<>]+)(@)`, "${1}"+redactedValue+"${3}", nil, "://").from(startScheme).runningOn(urlRunningOn),// Credentials recognizable by their own shape, wherever they appear. The type prefix is public// and stays (`ghp_[REDACTED]`, `AKIA[REDACTED]`), the way secret scanners report a finding: the// line still says a GitHub token or an AWS key was there, which is what detection rules match ondiff --git a/pkg/asymptoteobserve/privacy_test.go b/pkg/asymptoteobserve/privacy_test.goindex 831111bb..fb8620b1 100644--- a/pkg/asymptoteobserve/privacy_test.go+++ b/pkg/asymptoteobserve/privacy_test.go@@ -392,6 +392,22 @@ func TestRedactStringURLLabelPasswordWithQueryString(t *testing.T) {}}+// A URL's scheme glued to a word that ends in `_`, which \b alone would not let the scheme start+// after (#1250): the match starts with the word, and the word stays.+func TestRedactStringRedactsAURLPasswordAfterAWordEndingInAnUnderscore(t *testing.T) {+ for input, want := range map[string]string{+ "lsv2_sk_mysql://u:p@h": "lsv2_sk_mysql://u:[REDACTED]@h",+ "x lsv2_sk_mysql://user:[email protected]": "x lsv2_sk_mysql://user:[REDACTED]@db.example",+ "_redis://:hunter2@cache": "_redis://:[REDACTED]@cache",+ "a_1.mysql://u:hunter2@h": "a_1.mysql://u:[REDACTED]@h",+ "a.b_mysql://u:hunter2@h": "a.b_mysql://u:[REDACTED]@h",+ } {+ if got := RedactString(input); got != want {+ t.Errorf("RedactString(%q) = %q, want %q", input, got, want)+ }+ }+}+// awsPairLabelRun is 34 bytes of an AWS secret access key's alphabet: with a 6-byte label word// after it, the label is exactly as long as a secret access key, 40 bytes.const awsPairLabelRun = "Ab3Ab3Ab3Ab3Ab3Ab3Ab3Ab3Ab3Ab3Ab3x"diff --git a/pkg/asymptoteobserve/redact_adjacent.go b/pkg/asymptoteobserve/redact_adjacent.goindex 55c38071..9808548e 100644--- a/pkg/asymptoteobserve/redact_adjacent.go+++ b/pkg/asymptoteobserve/redact_adjacent.go@@ -1088,9 +1088,9 @@ func (c *redactChain) followerCrossing(m []int) (int, int) {}// schemeEnd returns the end of the run of URL scheme bytes from p: exactly what the URL pattern's-// case-insensitive `[a-z0-9+.-]*` takes, the ASCII class and the two other characters that fold-// into it, `K` (U+212A, k) and `ſ` (U+017F, s). schemeFollowerAt shares one answer across the run,-// so a byte the pattern stops at must end it.+// case-insensitive `[a-z0-9_+.-]*?[a-z][a-z0-9+.-]*` reads, the ASCII class and the two other+// characters that fold into it, `K` (U+212A, k) and `ſ` (U+017F, s). schemeFollowerAt shares one+// answer across the run, so a byte the pattern stops at must end it.func (c *redactChain) schemeEnd(p int) int {if c.schemeFrom <= p && p <= c.schemeTo {return c.schemeTodiff --git a/pkg/asymptoteobserve/redact_engine.go b/pkg/asymptoteobserve/redact_engine.goindex f6dd159e..776950b8 100644--- a/pkg/asymptoteobserve/redact_engine.go+++ b/pkg/asymptoteobserve/redact_engine.go@@ -56,8 +56,9 @@ const (startFlag// startListedFlag: at the quote before the flag that ends at the needle.startListedFlag- // startScheme: at a letter on a word boundary in the run of [A-Za-z0-9+.-] before the needle,- // a URL's `\b[a-z][a-z0-9+.-]*` scheme. The pattern opens with \b.+ // startScheme: at a word boundary in the run of [A-Za-z0-9_+.-] before the needle, where a+ // URL's `\b[a-z0-9_+.-]*?[a-z][a-z0-9+.-]*` scheme and the word it ends begin. The pattern+ // opens with \b.startScheme// startParam: at the `?` or `&` right before the run of [A-Za-z0-9_.-] that ends at the// needle, where a URL query parameter opens, and where startLabel begins when there is none@@ -553,7 +554,7 @@ func (rule redactionRule) startFor(t string, h redactHit, pos int, boundary boolreturn run - 1}for q := max(run, pos); q <= last; q++ {- if wordBoundary(t, q) && (rule.start != startScheme || isASCIILetter(t[q])) {+ if wordBoundary(t, q) {return q}}@@ -632,7 +633,7 @@ var labelClass, schemeClass = func() (label, scheme [256]bool) {b := byte(c)alnum := isASCIILetter(b) || '0' <= b && b <= '9'label[c] = alnum || b == '_' || b == '.' || b == '-'- scheme[c] = alnum || b == '+' || b == '.' || b == '-'+ scheme[c] = alnum || b == '_' || b == '+' || b == '.' || b == '-'}return label, scheme}()