The best way to control Claude Code, Codex and more from any computer or phone
fix(provider-core): redact compound credential keys in provider errors (#23313)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 29, 2026 at 12:40 UTC
67afdd56c7905e9df721c61f5795578bb8c27867
2 files changed
+16
-2
packages/provider-core/src/server/failure.test.ts
+14
@@ -41,6 +41,20 @@ it("redacts credentials and URL secrets from provider failures", () => {
41
assert.notInclude(failure.message, "sk-abcdefghijklmnop");
42
});
43
44
+it("redacts credentials whose key names end in a credential word", () => {
45
+ const failure = makeProviderFailure({
46
+ code: '{"refresh_token":"code value"}',
47
+ message:
48
+ 'oauth refresh failed: client_secret=client-value refresh_token=refresh-value {"client_secret":"json-value"} clientSecret: camel-value X-Auth-Token: header-value max_tokens=4096',
49
+ });
50
+
51
+ assert.equal(failure.code, '{"refresh_token":"[REDACTED]"}');
52
+ assert.equal(
53
+ failure.message,
54
+ 'oauth refresh failed: client_secret=[REDACTED] refresh_token=[REDACTED] {"client_secret":"[REDACTED]"} clientSecret: [REDACTED] X-Auth-Token: [REDACTED] max_tokens=4096',
55
+ );
56
+});
57
+
58
it("does not split a surrogate pair at the truncation boundary", () => {
59
const failure = makeProviderFailure({
60
message: `${"a".repeat(MAX_PROVIDER_FAILURE_MESSAGE_LENGTH - 2)}🚀tail`,
packages/provider-core/src/server/failure.ts
+2
-2
@@ -194,11 +194,11 @@ function redactProviderFailureText(value: string): string {
194
.replace(/\bhttps?:\/\/[^\s<>"']+/giu, redactUrl)
195
.replace(/\b(Bearer|Basic)\s+[^\s,;]+/giu, "$1 [REDACTED]")
196
.replace(
197
- /(["'](?:access[_-]?token|api[_-]?key|authorization|credential|password|secret|token)["']\s*:\s*["'])[^"']*(["'])/giu,
197
+ /(["'][\w-]*(?:access[_-]?token|api[_-]?key|authorization|credential|password|secret|token)["']\s*:\s*["'])[^"']*(["'])/giu,
198
"$1[REDACTED]$2",
199
)
200
.replace(
201
- /(\b(?:access[_-]?token|api[_-]?key|authorization|credential|password|secret|token)\b\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,
201
+ /((?<![\w-])[\w-]*(?:access[_-]?token|api[_-]?key|authorization|credential|password|secret|token)\b\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,
202
"$1[REDACTED]",
203
)
204
.replace(/\bsk-[A-Za-z0-9_-]{16,}\b/gu, "[REDACTED]")