mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 18:18:21 +00:00
fix(browser): block sensitive header intercept matchers
Squash merge PR #1294 into dev.
This commit is contained in:
1 parent
1a06ead908
commit
a86486497b
2 files changed
+63
-1
No files matched your search
@@ -83,6 +83,16 @@ const TOOL_HOVER = 'browser_hover';
|
||||
const TOOL_QUERY = 'browser_query';
|
||||
const TOOL_TAKE_ELEMENT_SCREENSHOT = 'browser_take_element_screenshot';
|
||||
const TOOL_WAIT_FOR_EVENT = 'browser_wait_for_event';
|
||||
const SENSITIVE_INTERCEPT_HEADER_NAMES = new Set([
|
||||
'authorization',
|
||||
'cookie',
|
||||
'cookie2',
|
||||
'proxy-authorization',
|
||||
'x-api-key',
|
||||
'x-api-token',
|
||||
'x-auth-token',
|
||||
]);
|
||||
|
||||
const TOOL_NAMES = [
|
||||
TOOL_SESSION_INFO,
|
||||
TOOL_URL_TITLE,
|
||||
@@ -612,10 +622,15 @@ function getTools() {
|
||||
urlRegex: { type: 'string' },
|
||||
headerMatchers: {
|
||||
type: 'array',
|
||||
description:
|
||||
'Match non-sensitive request headers. Cookie, Authorization, and token headers are not allowed.',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: { type: 'string' },
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Non-sensitive request header name to match.',
|
||||
},
|
||||
valueIncludes: { type: 'string' },
|
||||
valueRegex: { type: 'string' },
|
||||
},
|
||||
@@ -1379,6 +1394,10 @@ function parseOptionalPriority(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function isSensitiveInterceptHeaderName(name) {
|
||||
return SENSITIVE_INTERCEPT_HEADER_NAMES.has(name.toLowerCase());
|
||||
}
|
||||
|
||||
function parseOptionalHeaderMatchers(value) {
|
||||
if (value === undefined) {
|
||||
return [];
|
||||
@@ -1391,6 +1410,9 @@ function parseOptionalHeaderMatchers(value) {
|
||||
throw new Error('headerMatchers entries must be objects');
|
||||
}
|
||||
const name = requireNonEmptyString(entry.name, 'headerMatchers.name');
|
||||
if (isSensitiveInterceptHeaderName(name)) {
|
||||
throw new Error(`headerMatchers.name cannot target sensitive request header: ${name}`);
|
||||
}
|
||||
const valueIncludes =
|
||||
entry.valueIncludes === undefined
|
||||
? ''
|
||||
|
||||
Reference in new issue
Block a user