Skip to content

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

fix(redaction): redact url passwords that have no user name (#1068)

Rudy Mizrahi Celekli6247ce4e439a
diff --git a/pkg/asymptoteobserve/privacy.go b/pkg/asymptoteobserve/privacy.go
index 29c2d16d..ab259d6b 100644
--- a/pkg/asymptoteobserve/privacy.go
+++ b/pkg/asymptoteobserve/privacy.go
@@ -366,8 +366,9 @@ var redactionRules = concatRules([]redactionRule{
// in SanitizeMap already treats a structured `cookie` field. Only where a header or key can
// 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"),
- // The password in a URL's userinfo: `postgres://user:pw@host`, `https://x-access-token:[email protected]`.
- foldedRule(`(?i)(\b[a-z][a-z0-9+.-]*://[^/\s:@"'<>]+:)([^@/\s"'<>]+)(@)`, "${1}"+redactedValue+"${3}", nil, "://"),
+ // 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, "://"),
// 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 on
diff --git a/pkg/asymptoteobserve/privacy_test.go b/pkg/asymptoteobserve/privacy_test.go
index a74393cb..b21d4f7d 100644
--- a/pkg/asymptoteobserve/privacy_test.go
+++ b/pkg/asymptoteobserve/privacy_test.go
@@ -116,6 +116,8 @@ func TestRedactStringRedactsCommonCredentialFormats(t *testing.T) {
{"clone url", "git clone https://x-access-token:[email protected]/org/repo", "opaqueValue123"},
{"database url", "DATABASE_URL=postgres://app:[email protected]:5432/app", "pa55w0rd"},
{"bare database url", "connect to postgres://app:[email protected]:5432/app", "pa55w0rd"},
+ {"url password without a user", "REDIS_URL=redis://:[email protected]:6379/0", "pa55w0rd"},
+ {"bare url password without a user", "redis-cli -u redis://:pa55w0rd@localhost:6379 ping", "pa55w0rd"},
{"password flag", "mysql --user root --password hunter2hunter2", "hunter2hunter2"},
{"token flag", "tool login --token=opaque-flag-value", "opaque-flag-value"},
{"curl basic auth", "curl -u admin:hunter2hunter2 https://api.example.com/v1", "hunter2hunter2"},