Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔑 fix: Require Colon in API-Key Header Detection (#16803)

Dustin Healye1dfc10449ff
diff --git a/packages/api/src/protection/detectors/pattern.ts b/packages/api/src/protection/detectors/pattern.ts
index 6456b931be..f6c9cdb040 100644
--- a/packages/api/src/protection/detectors/pattern.ts
+++ b/packages/api/src/protection/detectors/pattern.ts
@@ -111,7 +111,7 @@ const STARTER_PATTERNS: readonly CompiledPattern[] = [
{
id: 'api_key_header',
label: 'api-key header',
- pattern: /\b(api-key:?\s+)[^\s"']+/i,
+ pattern: /\b(api-key:\s+)[^\s"']+/i,
category: 'credential',
},
];
diff --git a/packages/api/src/protection/runtime.spec.ts b/packages/api/src/protection/runtime.spec.ts
index 78de09b14c..cb6bb58214 100644
--- a/packages/api/src/protection/runtime.spec.ts
+++ b/packages/api/src/protection/runtime.spec.ts
@@ -345,6 +345,29 @@ describe('configured content inspection', () => {
});
});
+ it('does not interpret the api-key detector label as an API key header', () => {
+ const filters: FiltersConfig = {
+ messages: {
+ pii: {
+ starterPatterns: ['api_key_header'],
+ },
+ },
+ };
+
+ expect(
+ inspectContent(
+ [
+ fragment(
+ 'message',
+ 'text',
+ 'Submitted content contains an api-key header. Remove it and try again.',
+ ),
+ ],
+ { filters },
+ ),
+ ).toBeNull();
+ });
+
it('keeps the runtime starter catalog aligned with the public schema', () => {
expect(FILTER_PII_STARTER_PATTERNS).toEqual(STARTER_PATTERN_CASES.map(([ruleId]) => ruleId));
});