Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(telemetry): redact a curl password given as -uuser:pass, --user=user:pass or in quotes (#742)
Charan Rathore1c96911b6a2c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 18b32c3e..c1581c1f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,14 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.## Unreleased+- A password given to `curl` as `-uuser:password`, `--user=user:password` or `-u "user:pass word"` is+ now redacted in a Bot's recorded shell command. Only `-u user:password` with a space and no quotes+ was recognised, so the other spellings kept the password in the command that was stored or exported.+- A password, token or API key sent as a JSON field in a shell command is now redacted before the+ command is kept or exported. `curl -d '{"password":"x"}'` was recorded with the secret in clear,+ because only `NAME=value` and `--name value` forms were recognised and a quoted JSON key was+ neither. The key is still shown, so the command reads the same.+- A Bot's browser is now refused names under `.localhost`, such as `http://admin.localhost:5432`, thesame as bare `localhost`. The whole `.localhost` zone is loopback and Chromium resolves it withoutDNS, but only the exact name `localhost` was on the refused list, so a deployment that had not opted@@ -31,6 +39,7 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.connection checked out of the pool on every attempt.+- A conversation title cut at 60 characters no longer ends in half an emoji. `slice` counts UTF-16code units and an emoji is two of them, so a title cut between the halves rendered a replacementcharacter in the sidebar and the picker, where the character itself should have been.diff --git a/server/src/telemetry/scrub.ts b/server/src/telemetry/scrub.tsindex a87c30c0..23d9f8d1 100644--- a/server/src/telemetry/scrub.ts+++ b/server/src/telemetry/scrub.ts@@ -42,6 +42,16 @@ const RULES: [RegExp, (match: string, ...groups: string[]) => string][] = [/(x-api-key\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s'"]+)/gi,(_m, lead) => `${lead}${REDACTED}`,],+ // A quoted key in a JSON body: `-d '{"password":"x"}'`, or `-d "{\\"password\\":\\"x\\"}"` once the+ // shell quoting around it has escaped the inner quotes. The rule below stops at the closing quote+ // of the key, so it never saw these.+ [+ new RegExp(+ `(\\\\?["']${SECRET_NAME}\\\\?["']\\s*:\\s*)(\\\\"[^"\\\\]*\\\\"|"[^"]*"|'[^']*'|[^\\s,}'"\\\\]+)`,+ "gi",+ ),+ (_m, lead) => `${lead}${REDACTED}`,+ ],// `NAME=value`, `export NAME=value`, `--name=value`, `NAME: value`.[new RegExp(@@ -63,10 +73,14 @@ const RULES: [RegExp, (match: string, ...groups: string[]) => string][] = [/(\bmysql(?:dump)?\b[^|;&]*?\s-p)(\S+)/gi,(_m, lead) => `${lead}${REDACTED}`,],- // `curl -u user:password`.+ // `curl -u user:password`, and the other ways curl takes it: `-uuser:password`,+ // `--user=user:password`, and either of them with the pair in quotes.[- /(\s(?:-u|--user)\s+)([^\s:]+):(\S+)/g,- (_m, lead, user) => `${lead}${user}:${REDACTED}`,+ /(\s(?:-u\s*|--user(?:=|\s+)))(?:"([^":]*):[^"]*"|'([^':]*):[^']*'|([^\s:"']+):\S+)/g,+ (_m, lead, doubleQuoted, singleQuoted, bare) => {+ const user = doubleQuoted ?? singleQuoted ?? bare;+ return `${lead}${user}:${REDACTED}`;+ },],// Userinfo in any URL: `https://user:pass@host`.[diff --git a/server/tests/enterprise-controls.test.ts b/server/tests/enterprise-controls.test.tsindex 2249e928..f87e61c8 100644--- a/server/tests/enterprise-controls.test.ts+++ b/server/tests/enterprise-controls.test.ts@@ -372,6 +372,30 @@ describe("scrubbing commands", () => {"curl -u admin:[REDACTED] https://x.test",],["echo sk-proj-abcdefghijklmnopqrstuvwxyz", "echo [REDACTED]"],+ [+ `curl -d '{"user":"ann","password":"hunter2"}' https://x.test`,+ `curl -d '{"user":"ann","password":[REDACTED]}' https://x.test`,+ ],+ [+ `curl -d '{"api_key": "abcd1234", "n": 1}' https://x.test`,+ `curl -d '{"api_key": [REDACTED], "n": 1}' https://x.test`,+ ],+ [+ 'curl -d "{\\"client_secret\\":\\"hunter2\\"}" https://x.test',+ 'curl -d "{\\"client_secret\\":[REDACTED]}" https://x.test',+ ],+ [+ "curl -uadmin:s3cret https://x.test",+ "curl -uadmin:[REDACTED] https://x.test",+ ],+ [+ "curl --user=admin:s3cret https://x.test",+ "curl --user=admin:[REDACTED] https://x.test",+ ],+ [+ 'curl -u "admin:s3 cret" https://x.test',+ "curl -u admin:[REDACTED] https://x.test",+ ],];for (const [input, output] of cases) {test(input, () => expect(scrubCommand(input)).toBe(output));