Skip to content

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.

Refuse a Basic or Bearer value only when a credential follows the scheme (#528)

Vaibhav Zopeee990eb32eaf
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f9131e34..a3a93b8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,17 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
## Unreleased
+### A tool argument that starts with "Basic" or "Bearer" is no longer refused as a credential
+
+Content inspection read any MCP tool argument whose first word was "basic" or "bearer", in any case,
+as an authorization header. A Bot searching Drive for "Basic onboarding checklist", or posting
+"Bearer of bad news" to a channel, was refused because its arguments "contain credential material".
+Those words are now refused only when what follows them is shaped like a credential: base64 that
+decodes to `user:password` after `Basic`, and a token of at least 16 characters with a digit,
+punctuation or mixed case after `Bearer`. A shorter bearer token, or a Basic value that does not
+decode to `user:password`, is no longer caught by this pattern; the same value under an
+`authorization` field is still refused by name.
+
## 0.0.10
### The LangGraph Bot says a refused tool call was refused, not that it found nothing
diff --git a/server/src/plugins/content-governance.ts b/server/src/plugins/content-governance.ts
index b22cae93..06f9cd9c 100644
--- a/server/src/plugins/content-governance.ts
+++ b/server/src/plugins/content-governance.ts
@@ -88,11 +88,37 @@ function normalizedFieldName(value: string): string {
return normalized.startsWith("x_") ? normalized.slice(2) : normalized;
}
+const basicCredential = /^\s*Basic\s+([A-Za-z0-9+/]+={0,2})(?![A-Za-z0-9+/=])/i;
+const bearerCredential =
+ /^\s*Bearer\s+([A-Za-z0-9._~+/-]{16,}=*)(?![A-Za-z0-9._~+/=-])/i;
+
+function isBasicCredential(encoded: string): boolean {
+ try {
+ const decoded = new TextDecoder("utf-8", { fatal: true }).decode(
+ Buffer.from(encoded, "base64"),
+ );
+ return decoded.includes(":") && !/\p{Cc}/u.test(decoded);
+ } catch {
+ return false;
+ }
+}
+
+function isAuthorizationHeader(value: string): boolean {
+ const basic = basicCredential.exec(value);
+ if (basic?.[1] && isBasicCredential(basic[1])) return true;
+ const token = bearerCredential.exec(value)?.[1];
+ if (!token) return false;
+ return (
+ /[0-9._~+/=-]/.test(token) ||
+ (/[a-z]/.test(token) && /[A-Z]/.test(token.slice(1)))
+ );
+}
+
function categoryForValue(value: string): SensitiveArgumentCategory | null {
if (/-----BEGIN (?:[A-Z ]+ )?PRIVATE KEY-----/.test(value)) {
return "private_key";
}
- if (/^\s*(?:Basic|Bearer)\s+\S+/i.test(value)) {
+ if (isAuthorizationHeader(value)) {
return "authorization_header";
}
if (providerTokenPatterns.some((pattern) => pattern.test(value))) {
diff --git a/server/tests/content-governance.test.ts b/server/tests/content-governance.test.ts
index 77128307..fe56a14a 100644
--- a/server/tests/content-governance.test.ts
+++ b/server/tests/content-governance.test.ts
@@ -163,4 +163,35 @@ describe("MCP tool argument content governance", () => {
safe: true,
});
});
+
+ test.each([
+ "Basic onboarding checklist",
+ "basic setup guide",
+ "Basic auth broken on staging",
+ " basic training for new hires",
+ "Bearer of bad news: the launch slips a week",
+ "Bearer responsibilities",
+ ])(
+ "allows %s, which only starts with an authorization scheme name",
+ (text) => {
+ expect(inspectToolArguments({ title: text })).toEqual({ safe: true });
+ },
+ );
+
+ test.each([
+ ["a Basic credential", `Basic ${btoa("aladdin:open sesame")}`],
+ ["a lowercase basic credential", `basic ${btoa("user:pass")}`],
+ [
+ "a Bearer token followed by text",
+ "Bearer eyJhbGciOiJIUzI1NiJ9.payload.signature is the one to use",
+ ],
+ ["an opaque bearer token", `bearer ${"a1".repeat(12)}`],
+ ["a bearer token with no digits", "Bearer QmFzZVRva2VuV2l0aE5vRGlnaXRz"],
+ ])("still refuses %s", (_label, value) => {
+ expect(inspectToolArguments({ value })).toEqual({
+ safe: false,
+ reason: "sensitive_content",
+ findings: [{ category: "authorization_header", path: "$.value" }],
+ });
+ });
});