@bryan-thompson/inspector-assessment-client 1.35.1 → 1.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{OAuthCallback-DC1cIXHT.js → OAuthCallback-jfmizOMH.js} +1 -1
- package/dist/assets/{OAuthDebugCallback-C3gqJjgQ.js → OAuthDebugCallback-bU5kKvnt.js} +1 -1
- package/dist/assets/{index-Dn2w887x.js → index-Ce63ds7G.js} +4 -4
- package/dist/index.html +1 -1
- package/lib/lib/assessment/coreTypes.d.ts +23 -0
- package/lib/lib/assessment/coreTypes.d.ts.map +1 -1
- package/lib/lib/assessment/extendedTypes.d.ts +64 -7
- package/lib/lib/assessment/extendedTypes.d.ts.map +1 -1
- package/lib/lib/assessment/jsonlEventSchemas.d.ts +4 -4
- package/lib/lib/assessment/resultTypes.d.ts +12 -1
- package/lib/lib/assessment/resultTypes.d.ts.map +1 -1
- package/lib/lib/aupPatterns.d.ts +50 -0
- package/lib/lib/aupPatterns.d.ts.map +1 -1
- package/lib/lib/aupPatterns.js +140 -0
- package/lib/lib/securityPatterns.d.ts.map +1 -1
- package/lib/lib/securityPatterns.js +92 -0
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts +26 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/DeveloperExperienceAssessor.js +160 -1
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts +40 -0
- package/lib/services/assessment/modules/ManifestValidationAssessor.d.ts.map +1 -1
- package/lib/services/assessment/modules/ManifestValidationAssessor.js +269 -28
- package/lib/services/assessment/modules/securityTests/ConfidenceScorer.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/ConfidenceScorer.js +28 -0
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts +95 -0
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityPatternLibrary.js +174 -0
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityPayloadTester.js +15 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts +40 -0
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.d.ts.map +1 -1
- package/lib/services/assessment/modules/securityTests/SecurityResponseAnalyzer.js +143 -131
- package/package.json +1 -1
|
@@ -51,6 +51,75 @@ export const VALIDATION_ERROR_PATTERNS = [
|
|
|
51
51
|
/field.*required/i,
|
|
52
52
|
];
|
|
53
53
|
// =============================================================================
|
|
54
|
+
// ERROR CONTEXT PATTERNS (Issue #146)
|
|
55
|
+
// =============================================================================
|
|
56
|
+
/**
|
|
57
|
+
* Issue #146: Error context patterns indicating operation failure
|
|
58
|
+
* Used to detect when payload appears in error message (likely false positive)
|
|
59
|
+
* These patterns indicate the server rejected/failed the operation
|
|
60
|
+
*/
|
|
61
|
+
export const ERROR_CONTEXT_PATTERNS = [
|
|
62
|
+
/failed\s+to\s+(?:get|read|load|access|process|fetch|retrieve|find)/i,
|
|
63
|
+
/error:\s+response\s+status:\s+\d{3}/i,
|
|
64
|
+
/(?:could\s+not|cannot|unable\s+to)\s+(?:find|locate|access|read|get|load)/i,
|
|
65
|
+
/\b(?:not\s+found|doesn['']t\s+exist|no\s+such|does\s+not\s+exist)\b/i,
|
|
66
|
+
/error\s+(?:loading|reading|processing|fetching|accessing)/i,
|
|
67
|
+
/(?:operation|request)\s+failed/i,
|
|
68
|
+
/invalid\s+(?:path|file|resource|input|parameter)/i,
|
|
69
|
+
/\b(?:rejected|refused|denied)\b/i,
|
|
70
|
+
/(?:resource|file|path)\s+(?:is\s+)?(?:invalid|not\s+allowed)/i,
|
|
71
|
+
/access\s+(?:denied|forbidden)/i,
|
|
72
|
+
/permission\s+denied/i,
|
|
73
|
+
/\b(?:4\d{2}|5\d{2})\s*(?:error|not\s+found|bad\s+request|unauthorized|forbidden)/i,
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Issue #146: Success context patterns indicating operation completion
|
|
77
|
+
* Used to confirm operation actually executed (high confidence vulnerability)
|
|
78
|
+
* These patterns indicate the server processed and returned results
|
|
79
|
+
*/
|
|
80
|
+
export const SUCCESS_CONTEXT_PATTERNS = [
|
|
81
|
+
/(?:successfully|completed)\s+(?:read|loaded|accessed|executed|retrieved)/i,
|
|
82
|
+
/file\s+contents?:/i,
|
|
83
|
+
/data\s+retrieved/i,
|
|
84
|
+
/execution\s+result:/i,
|
|
85
|
+
/\boutput:/i,
|
|
86
|
+
/\bresults?:/i,
|
|
87
|
+
/returned\s+(?:data|content|results)/i,
|
|
88
|
+
/read\s+\d+\s+bytes/i,
|
|
89
|
+
/fetched\s+(?:from|data)/i,
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* Issue #146: Check if payload appears in error context (likely false positive)
|
|
93
|
+
* @param responseText The full response text from the tool
|
|
94
|
+
* @param payload The payload that was sent to the tool
|
|
95
|
+
* @returns true if payload is reflected in an error context
|
|
96
|
+
*/
|
|
97
|
+
export function isPayloadInErrorContext(responseText, payload) {
|
|
98
|
+
// Check if response contains error patterns
|
|
99
|
+
const hasErrorContext = ERROR_CONTEXT_PATTERNS.some((p) => p.test(responseText));
|
|
100
|
+
// Check if payload is reflected in the response
|
|
101
|
+
const payloadReflected = responseText
|
|
102
|
+
.toLowerCase()
|
|
103
|
+
.includes(payload.toLowerCase());
|
|
104
|
+
return hasErrorContext && payloadReflected;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Issue #146: Check if response indicates successful operation (high confidence)
|
|
108
|
+
* @param responseText The full response text from the tool
|
|
109
|
+
* @returns true if response indicates operation succeeded
|
|
110
|
+
*/
|
|
111
|
+
export function hasSuccessContext(responseText) {
|
|
112
|
+
return SUCCESS_CONTEXT_PATTERNS.some((p) => p.test(responseText));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Issue #146: Check if response indicates failed operation (error context)
|
|
116
|
+
* @param responseText The full response text from the tool
|
|
117
|
+
* @returns true if response indicates operation failed
|
|
118
|
+
*/
|
|
119
|
+
export function hasErrorContext(responseText) {
|
|
120
|
+
return ERROR_CONTEXT_PATTERNS.some((p) => p.test(responseText));
|
|
121
|
+
}
|
|
122
|
+
// =============================================================================
|
|
54
123
|
// EXECUTION EVIDENCE PATTERNS
|
|
55
124
|
// =============================================================================
|
|
56
125
|
/**
|
|
@@ -985,6 +1054,111 @@ export const OUTPUT_INJECTION_PATTERNS = {
|
|
|
985
1054
|
canaryMarkers: [/SENTINEL_OUTPUT_MARKER_\d+/],
|
|
986
1055
|
};
|
|
987
1056
|
// =============================================================================
|
|
1057
|
+
// EXCESSIVE PERMISSIONS SCOPE PATTERNS (Issue #144, Challenge #22)
|
|
1058
|
+
// =============================================================================
|
|
1059
|
+
/**
|
|
1060
|
+
* Patterns indicating scope violation in tool response
|
|
1061
|
+
* Detects when tools exceed their declared annotations at runtime
|
|
1062
|
+
* CWE-250: Execution with Unnecessary Privileges
|
|
1063
|
+
* CWE-269: Improper Privilege Management
|
|
1064
|
+
*/
|
|
1065
|
+
export const SCOPE_VIOLATION_PATTERNS = [
|
|
1066
|
+
{
|
|
1067
|
+
pattern: /"scope_violation"\s*:\s*true/i,
|
|
1068
|
+
evidence: "scope_violation: true (tool exceeded declared scope)",
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
pattern: /"scope_escalation"\s*:\s*true/i,
|
|
1072
|
+
evidence: "scope_escalation: true (privilege escalation via input)",
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
pattern: /"actual_scope"\s*:\s*"(write|delete|execute|network)"/i,
|
|
1076
|
+
evidence: "actual_scope indicates privileged operation",
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
pattern: /"privileged_data"\s*:/i,
|
|
1080
|
+
evidence: "privileged_data exposed in response",
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
pattern: /"system_secrets"\s*:/i,
|
|
1084
|
+
evidence: "system_secrets leaked in response",
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
pattern: /admin[\s_-]?mode[\s_-]?activated/i,
|
|
1088
|
+
evidence: "Admin mode activated via keyword trigger",
|
|
1089
|
+
},
|
|
1090
|
+
];
|
|
1091
|
+
/**
|
|
1092
|
+
* Patterns indicating safe scope enforcement (hardened behavior)
|
|
1093
|
+
* Used to confirm tools properly reject privileged actions
|
|
1094
|
+
*/
|
|
1095
|
+
export const SCOPE_ENFORCED_PATTERNS = [
|
|
1096
|
+
{
|
|
1097
|
+
pattern: /"scope_enforced"\s*:\s*true/i,
|
|
1098
|
+
evidence: "scope_enforced: true (safe)",
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
pattern: /"blocked"\s*:\s*true/i,
|
|
1102
|
+
evidence: "Action blocked by allowlist",
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
pattern: /action.*not.*in.*allowlist/i,
|
|
1106
|
+
evidence: "Allowlist enforcement",
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
pattern: /"rejection_reason"\s*:\s*"action_not_in_allowlist"/i,
|
|
1110
|
+
evidence: "Explicit rejection: action not in allowlist",
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
pattern: /"escalation_attempted"\s*:\s*false/i,
|
|
1114
|
+
evidence: "No escalation attempted (safe)",
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
pattern: /"allowed_actions"\s*:\s*\[/i,
|
|
1118
|
+
evidence: "Allowlist defined and enforced",
|
|
1119
|
+
},
|
|
1120
|
+
];
|
|
1121
|
+
/**
|
|
1122
|
+
* Privileged actions that should be blocked by readOnlyHint=True tools
|
|
1123
|
+
*/
|
|
1124
|
+
export const PRIVILEGED_ACTIONS = [
|
|
1125
|
+
"write",
|
|
1126
|
+
"write_file",
|
|
1127
|
+
"delete",
|
|
1128
|
+
"delete_data",
|
|
1129
|
+
"execute",
|
|
1130
|
+
"execute_command",
|
|
1131
|
+
"network",
|
|
1132
|
+
"network_request",
|
|
1133
|
+
"modify",
|
|
1134
|
+
"modify_config",
|
|
1135
|
+
"admin",
|
|
1136
|
+
"environment_access",
|
|
1137
|
+
];
|
|
1138
|
+
/**
|
|
1139
|
+
* Escalation keywords that may trigger hidden privilege escalation
|
|
1140
|
+
*/
|
|
1141
|
+
export const ESCALATION_KEYWORDS = [
|
|
1142
|
+
"admin",
|
|
1143
|
+
"sudo",
|
|
1144
|
+
"elevate",
|
|
1145
|
+
"root",
|
|
1146
|
+
"superuser",
|
|
1147
|
+
"privilege",
|
|
1148
|
+
];
|
|
1149
|
+
/**
|
|
1150
|
+
* Check if response contains scope violation indicators (Issue #144)
|
|
1151
|
+
*/
|
|
1152
|
+
export function hasScopeViolation(text) {
|
|
1153
|
+
return SCOPE_VIOLATION_PATTERNS.some(({ pattern }) => pattern.test(text));
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Check if response contains scope enforcement indicators (Issue #144)
|
|
1157
|
+
*/
|
|
1158
|
+
export function hasScopeEnforcement(text) {
|
|
1159
|
+
return SCOPE_ENFORCED_PATTERNS.some(({ pattern }) => pattern.test(text));
|
|
1160
|
+
}
|
|
1161
|
+
// =============================================================================
|
|
988
1162
|
// HELPER FUNCTIONS
|
|
989
1163
|
// =============================================================================
|
|
990
1164
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityPayloadTester.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPayloadTester.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAIjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAA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AqB,CACzB,KAAK,EAAE,IAAI,EAAE,EACb,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,2BAA2B,CAAC,EACzC,UAAU,CAAC,EAAE,oBAAoB,GAChC,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA6LhC;;OAEG;IACG,WAAW,CACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,2BAA2B,CAAC,GACxC,OAAO,CAAC,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SecurityPayloadTester.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityPayloadTester.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAIjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAGL,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAOhC;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,QAAQ,EA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A2B,CAAC,GACxC,OAAO,CAAC,kBAAkB,CAAC;IAyR9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAO3B;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -437,6 +437,19 @@ export class SecurityPayloadTester {
|
|
|
437
437
|
cryptoFailureEvidence: cryptoResult.evidence,
|
|
438
438
|
};
|
|
439
439
|
}
|
|
440
|
+
// Issue #144: Analyze excessive permissions scope patterns for Challenge #22
|
|
441
|
+
let excessivePermissionsFields = {};
|
|
442
|
+
if (attackName === "Excessive Permissions Scope") {
|
|
443
|
+
const scopeResult = this.responseAnalyzer.analyzeExcessivePermissionsResponse(response);
|
|
444
|
+
excessivePermissionsFields = {
|
|
445
|
+
excessivePermissionsDetected: scopeResult.detected,
|
|
446
|
+
scopeViolationType: scopeResult.violationType,
|
|
447
|
+
scopeActual: scopeResult.actualScope,
|
|
448
|
+
scopeTriggerPayload: scopeResult.triggerPayload,
|
|
449
|
+
scopeCweIds: scopeResult.cweIds,
|
|
450
|
+
excessivePermissionsEvidence: scopeResult.evidence,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
440
453
|
return {
|
|
441
454
|
testName: attackName,
|
|
442
455
|
description: payload.description,
|
|
@@ -459,6 +472,8 @@ export class SecurityPayloadTester {
|
|
|
459
472
|
...sessionManagementFields,
|
|
460
473
|
// Issue #112: Cryptographic failure detection fields (Challenge #13)
|
|
461
474
|
...cryptoFailureFields,
|
|
475
|
+
// Issue #144: Excessive permissions scope detection fields (Challenge #22)
|
|
476
|
+
...excessivePermissionsFields,
|
|
462
477
|
...confidenceResult,
|
|
463
478
|
};
|
|
464
479
|
}
|
|
@@ -96,6 +96,20 @@ export interface CryptoFailureResult {
|
|
|
96
96
|
cweIds: string[];
|
|
97
97
|
evidence?: string;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Result of excessive permissions scope analysis (Issue #144, Challenge #22)
|
|
101
|
+
* Detects when tools exceed their declared annotation scope:
|
|
102
|
+
* - CWE-250: Execution with Unnecessary Privileges (scope violation)
|
|
103
|
+
* - CWE-269: Improper Privilege Management (scope escalation)
|
|
104
|
+
*/
|
|
105
|
+
export interface ExcessivePermissionsScopeResult {
|
|
106
|
+
detected: boolean;
|
|
107
|
+
violationType: "SCOPE_VIOLATION" | "SCOPE_ESCALATION" | "SAFE" | "UNKNOWN";
|
|
108
|
+
actualScope?: string;
|
|
109
|
+
triggerPayload?: string;
|
|
110
|
+
cweIds: string[];
|
|
111
|
+
evidence?: string;
|
|
112
|
+
}
|
|
99
113
|
/**
|
|
100
114
|
* Chain execution type classification (Issue #93, Challenge #6)
|
|
101
115
|
*/
|
|
@@ -362,6 +376,32 @@ export declare class SecurityResponseAnalyzer {
|
|
|
362
376
|
* Handles: Evidence pattern matching, fallback injection analysis
|
|
363
377
|
*/
|
|
364
378
|
private checkVulnerabilityEvidence;
|
|
379
|
+
/**
|
|
380
|
+
* Issue #146: Classify vulnerability context to reduce false positives
|
|
381
|
+
* Distinguishes between actual execution and payload reflection in errors
|
|
382
|
+
*
|
|
383
|
+
* Context classification:
|
|
384
|
+
* - CONFIRMED: Operation succeeded, payload was actually executed (HIGH risk)
|
|
385
|
+
* - LIKELY_FALSE_POSITIVE: Operation failed, payload just reflected in error (LOW risk)
|
|
386
|
+
* - SUSPECTED: Ambiguous case requiring manual review (MEDIUM risk)
|
|
387
|
+
*
|
|
388
|
+
* @param vulnResult The vulnerability analysis result from checkVulnerabilityEvidence
|
|
389
|
+
* @param responseText The full response text (lowercase)
|
|
390
|
+
* @param payload The security payload that was tested
|
|
391
|
+
* @returns Updated AnalysisResult with context classification
|
|
392
|
+
*/
|
|
393
|
+
private classifyVulnerabilityContext;
|
|
394
|
+
/**
|
|
395
|
+
* Analyze response for excessive permissions scope violations (Issue #144, Challenge #22)
|
|
396
|
+
* Detects when tools exceed their declared annotation scope:
|
|
397
|
+
* - scope_violation: Tool performed privileged action despite restrictive annotations
|
|
398
|
+
* - scope_escalation: Keyword triggered hidden admin/privilege mode
|
|
399
|
+
* - scope_enforced: Tool properly blocked the privileged action (safe)
|
|
400
|
+
*
|
|
401
|
+
* CWE-250: Execution with Unnecessary Privileges
|
|
402
|
+
* CWE-269: Improper Privilege Management
|
|
403
|
+
*/
|
|
404
|
+
analyzeExcessivePermissionsResponse(response: CompatibilityCallToolResult): ExcessivePermissionsScopeResult;
|
|
365
405
|
/**
|
|
366
406
|
* Analyze injection response (fallback logic)
|
|
367
407
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecurityResponseAnalyzer.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityResponseAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK1E,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAoB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"SecurityResponseAnalyzer.d.ts","sourceRoot":"","sources":["../../../../../src/services/assessment/modules/securityTests/SecurityResponseAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,2BAA2B,EAC3B,IAAI,EACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAK1E,OAAO,EAAgB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAoB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAyBxE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAo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,GAAG,OAAO;IAIrE;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO;IAOxE;;OAEG;IACH,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAIrD;;OAEG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAQjD;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAqF7B;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IA8DlC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,4BAA4B;IA8CpC;;;;;;;;;OASG;IACH,mCAAmC,CACjC,QAAQ,EAAE,2BAA2B,GACpC,+BAA+B;IA6ElC;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAmBjC"}
|
|
@@ -20,7 +20,15 @@ import { MathAnalyzer } from "./MathAnalyzer.js";
|
|
|
20
20
|
import { SafeResponseDetector } from "./SafeResponseDetector.js";
|
|
21
21
|
import { ConfidenceScorer } from "./ConfidenceScorer.js";
|
|
22
22
|
// Import pattern library for chain exploitation analysis
|
|
23
|
-
import { CHAIN_EXPLOIT_VULNERABLE_PATTERNS, CHAIN_EXPLOIT_SAFE_PATTERNS, CHAIN_VULNERABLE_THRESHOLD, CHAIN_SAFE_THRESHOLD, detectVulnerabilityCategories,
|
|
23
|
+
import { CHAIN_EXPLOIT_VULNERABLE_PATTERNS, CHAIN_EXPLOIT_SAFE_PATTERNS, CHAIN_VULNERABLE_THRESHOLD, CHAIN_SAFE_THRESHOLD, detectVulnerabilityCategories,
|
|
24
|
+
// Issue #144: Excessive permissions scope patterns (Challenge #22)
|
|
25
|
+
SCOPE_VIOLATION_PATTERNS, SCOPE_ENFORCED_PATTERNS,
|
|
26
|
+
// Issue #146: Error context patterns for false positive reduction
|
|
27
|
+
isPayloadInErrorContext, hasSuccessContext, hasErrorContext,
|
|
28
|
+
// Issue #75: Auth bypass patterns (CVE-2025-52882)
|
|
29
|
+
AUTH_FAIL_OPEN_PATTERNS, AUTH_FAIL_CLOSED_PATTERNS,
|
|
30
|
+
// Issue #92: State-based auth patterns (Challenge #7)
|
|
31
|
+
STATE_AUTH_VULNERABLE_PATTERNS, STATE_AUTH_SAFE_PATTERNS, } from "./SecurityPatternLibrary.js";
|
|
24
32
|
/**
|
|
25
33
|
* Analyzes tool responses for security vulnerabilities
|
|
26
34
|
* Distinguishes between safe reflection and actual execution
|
|
@@ -64,7 +72,13 @@ export class SecurityResponseAnalyzer {
|
|
|
64
72
|
if (behaviorResult)
|
|
65
73
|
return behaviorResult;
|
|
66
74
|
// Check 3: Vulnerability evidence matching
|
|
67
|
-
|
|
75
|
+
const vulnResult = this.checkVulnerabilityEvidence(response, payload, responseText);
|
|
76
|
+
// Issue #146: If vulnerable, classify execution context to reduce false positives
|
|
77
|
+
// This distinguishes between actual execution and payload reflection in errors
|
|
78
|
+
if (vulnResult.isVulnerable) {
|
|
79
|
+
return this.classifyVulnerabilityContext(vulnResult, responseText, payload);
|
|
80
|
+
}
|
|
81
|
+
return vulnResult;
|
|
68
82
|
}
|
|
69
83
|
/**
|
|
70
84
|
* Calculate confidence level and manual review requirements
|
|
@@ -78,77 +92,14 @@ export class SecurityResponseAnalyzer {
|
|
|
78
92
|
*/
|
|
79
93
|
analyzeAuthBypassResponse(response) {
|
|
80
94
|
const responseText = this.extractResponseContent(response);
|
|
81
|
-
// Fail-open indicators (VULNERABLE - CVE-2025-52882 pattern)
|
|
82
|
-
const failOpenPatterns = [
|
|
83
|
-
{
|
|
84
|
-
pattern: /"auth_type"\s*:\s*"fail-open"/i,
|
|
85
|
-
evidence: "auth_type: fail-open (CVE-2025-52882)",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
pattern: /"auth_status"\s*:\s*"bypassed"/i,
|
|
89
|
-
evidence: "auth_status: bypassed",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
pattern: /access.*granted.*despite/i,
|
|
93
|
-
evidence: "access granted despite failure",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
pattern: /authentication.*skipped/i,
|
|
97
|
-
evidence: "authentication skipped",
|
|
98
|
-
},
|
|
99
|
-
{ pattern: /fail[\s-]?open/i, evidence: "fail-open pattern detected" },
|
|
100
|
-
{ pattern: /bypassed.*auth/i, evidence: "auth bypassed" },
|
|
101
|
-
{
|
|
102
|
-
pattern: /authentication.*bypassed/i,
|
|
103
|
-
evidence: "authentication bypassed",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
pattern: /"vulnerable"\s*:\s*true[^}]*(?:"auth_status"|"auth_type"|"auth_error")|(?:"auth_status"|"auth_type"|"auth_error")[^}]*"vulnerable"\s*:\s*true/i,
|
|
107
|
-
evidence: "vulnerable flag with auth context",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
pattern: /auth.*succeeded.*null/i,
|
|
111
|
-
evidence: "auth succeeded with null token",
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
pattern: /granted.*without.*valid/i,
|
|
115
|
-
evidence: "granted without valid token",
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
pattern: /"action_performed"/i,
|
|
119
|
-
evidence: "action performed indicator",
|
|
120
|
-
},
|
|
121
|
-
];
|
|
122
|
-
// Fail-closed indicators (SAFE - proper auth handling)
|
|
123
|
-
const failClosedPatterns = [
|
|
124
|
-
{
|
|
125
|
-
pattern: /"auth_type"\s*:\s*"fail-closed"/i,
|
|
126
|
-
evidence: "auth_type: fail-closed (secure)",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
pattern: /"auth_status"\s*:\s*"denied"/i,
|
|
130
|
-
evidence: "auth_status: denied",
|
|
131
|
-
},
|
|
132
|
-
{ pattern: /access.*denied/i, evidence: "access denied" },
|
|
133
|
-
{ pattern: /authentication.*failed/i, evidence: "authentication failed" },
|
|
134
|
-
{
|
|
135
|
-
pattern: /fail[\s-]?closed/i,
|
|
136
|
-
evidence: "fail-closed pattern detected",
|
|
137
|
-
},
|
|
138
|
-
{ pattern: /"status"\s*:\s*"blocked"/i, evidence: "status: blocked" },
|
|
139
|
-
{ pattern: /invalid.*token/i, evidence: "invalid token rejection" },
|
|
140
|
-
{ pattern: /token.*required/i, evidence: "token required" },
|
|
141
|
-
{ pattern: /unauthorized/i, evidence: "unauthorized response" },
|
|
142
|
-
{ pattern: /"denial_reason"/i, evidence: "denial reason provided" },
|
|
143
|
-
];
|
|
144
95
|
// Check for fail-open (vulnerable) patterns first
|
|
145
|
-
for (const { pattern, evidence } of
|
|
96
|
+
for (const { pattern, evidence } of AUTH_FAIL_OPEN_PATTERNS) {
|
|
146
97
|
if (pattern.test(responseText)) {
|
|
147
98
|
return { detected: true, failureMode: "FAIL_OPEN", evidence };
|
|
148
99
|
}
|
|
149
100
|
}
|
|
150
101
|
// Check for fail-closed (safe) patterns
|
|
151
|
-
for (const { pattern, evidence } of
|
|
102
|
+
for (const { pattern, evidence } of AUTH_FAIL_CLOSED_PATTERNS) {
|
|
152
103
|
if (pattern.test(responseText)) {
|
|
153
104
|
return { detected: false, failureMode: "FAIL_CLOSED", evidence };
|
|
154
105
|
}
|
|
@@ -167,70 +118,8 @@ export class SecurityResponseAnalyzer {
|
|
|
167
118
|
*/
|
|
168
119
|
analyzeStateBasedAuthBypass(response) {
|
|
169
120
|
const responseText = this.extractResponseContent(response);
|
|
170
|
-
// Vulnerable patterns - shared state authorization (Challenge #7)
|
|
171
|
-
const vulnerablePatterns = [
|
|
172
|
-
{
|
|
173
|
-
pattern: /"admin_mode"\s*:\s*true/i,
|
|
174
|
-
evidence: "admin_mode enabled in response",
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
pattern: /hint.*use\s+config_modifier/i,
|
|
178
|
-
evidence: "Tool hints at cross-tool state dependency",
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
pattern: /admin_mode.*set\s+by.*another\s+tool/i,
|
|
182
|
-
evidence: "Explicit cross-tool state dependency",
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
pattern: /"evidence".*cross-tool.*privilege/i,
|
|
186
|
-
evidence: "Cross-tool privilege escalation detected",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
pattern: /elevated\s+privileges?\s+granted/i,
|
|
190
|
-
evidence: "Elevated privileges granted",
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
pattern: /admin\s+mode\s+activated/i,
|
|
194
|
-
evidence: "Admin mode activated (state modifier)",
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
pattern: /"hint".*config_modifier.*admin_mode/i,
|
|
198
|
-
evidence: "Response hints at config_modifier for admin_mode",
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
pattern: /Use\s+config_modifier.*enable.*admin_mode/i,
|
|
202
|
-
evidence: "Tool depends on config_modifier for authorization",
|
|
203
|
-
},
|
|
204
|
-
];
|
|
205
|
-
// Safe patterns - independent authorization (secure)
|
|
206
|
-
const safePatterns = [
|
|
207
|
-
{
|
|
208
|
-
pattern: /"shared_state_checked"\s*:\s*false/i,
|
|
209
|
-
evidence: "Tool explicitly states it doesn't use shared state",
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
pattern: /"independent_auth_required"\s*:\s*true/i,
|
|
213
|
-
evidence: "Tool requires independent per-request auth",
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
pattern: /requires\s+independent\s+authorization/i,
|
|
217
|
-
evidence: "Independent authorization required",
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
pattern: /(?:not|does\s+not|doesn't)\s+(?:use\s+)?shared\s+state/i,
|
|
221
|
-
evidence: "Tool confirms it does not use shared state",
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
pattern: /stored.*for.*admin.*review/i,
|
|
225
|
-
evidence: "Request stored for admin review (no auto-execution)",
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
pattern: /per-request\s+auth/i,
|
|
229
|
-
evidence: "Per-request authentication enforced",
|
|
230
|
-
},
|
|
231
|
-
];
|
|
232
121
|
// Check vulnerable patterns first (SHARED_STATE)
|
|
233
|
-
for (const { pattern, evidence } of
|
|
122
|
+
for (const { pattern, evidence } of STATE_AUTH_VULNERABLE_PATTERNS) {
|
|
234
123
|
if (pattern.test(responseText)) {
|
|
235
124
|
return {
|
|
236
125
|
vulnerable: true,
|
|
@@ -241,7 +130,7 @@ export class SecurityResponseAnalyzer {
|
|
|
241
130
|
}
|
|
242
131
|
}
|
|
243
132
|
// Check safe patterns (INDEPENDENT)
|
|
244
|
-
for (const { pattern, evidence } of
|
|
133
|
+
for (const { pattern, evidence } of STATE_AUTH_SAFE_PATTERNS) {
|
|
245
134
|
if (pattern.test(responseText)) {
|
|
246
135
|
return {
|
|
247
136
|
vulnerable: false,
|
|
@@ -1230,6 +1119,129 @@ export class SecurityResponseAnalyzer {
|
|
|
1230
1119
|
// Fall back to injection response analysis
|
|
1231
1120
|
return this.analyzeInjectionResponse(response);
|
|
1232
1121
|
}
|
|
1122
|
+
// ============================================================================
|
|
1123
|
+
// Issue #146: Execution Context Classification (False Positive Reduction)
|
|
1124
|
+
// ============================================================================
|
|
1125
|
+
/**
|
|
1126
|
+
* Issue #146: Classify vulnerability context to reduce false positives
|
|
1127
|
+
* Distinguishes between actual execution and payload reflection in errors
|
|
1128
|
+
*
|
|
1129
|
+
* Context classification:
|
|
1130
|
+
* - CONFIRMED: Operation succeeded, payload was actually executed (HIGH risk)
|
|
1131
|
+
* - LIKELY_FALSE_POSITIVE: Operation failed, payload just reflected in error (LOW risk)
|
|
1132
|
+
* - SUSPECTED: Ambiguous case requiring manual review (MEDIUM risk)
|
|
1133
|
+
*
|
|
1134
|
+
* @param vulnResult The vulnerability analysis result from checkVulnerabilityEvidence
|
|
1135
|
+
* @param responseText The full response text (lowercase)
|
|
1136
|
+
* @param payload The security payload that was tested
|
|
1137
|
+
* @returns Updated AnalysisResult with context classification
|
|
1138
|
+
*/
|
|
1139
|
+
classifyVulnerabilityContext(vulnResult, responseText, payload) {
|
|
1140
|
+
// Use pattern library helpers to detect context
|
|
1141
|
+
const hasError = hasErrorContext(responseText);
|
|
1142
|
+
const hasSuccess = hasSuccessContext(responseText);
|
|
1143
|
+
const payloadInError = isPayloadInErrorContext(responseText, payload.payload);
|
|
1144
|
+
// CONFIRMED: Success patterns present, no error patterns
|
|
1145
|
+
// This indicates the operation actually executed and returned results
|
|
1146
|
+
if (hasSuccess && !hasError) {
|
|
1147
|
+
return {
|
|
1148
|
+
...vulnResult,
|
|
1149
|
+
evidence: `${vulnResult.evidence} [Context: CONFIRMED - operation succeeded]`,
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
// LIKELY_FALSE_POSITIVE: Error context with payload reflection
|
|
1153
|
+
// The server rejected the operation but echoed the payload in the error message
|
|
1154
|
+
if (payloadInError && hasError) {
|
|
1155
|
+
return {
|
|
1156
|
+
isVulnerable: false,
|
|
1157
|
+
evidence: `Operation failed with error containing reflected payload. ` +
|
|
1158
|
+
`Original detection: ${vulnResult.evidence} ` +
|
|
1159
|
+
`[Context: LIKELY_FALSE_POSITIVE - payload reflected in error message, not executed]`,
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
// SUSPECTED: Ambiguous (neither clear success nor clear error)
|
|
1163
|
+
// Mark as requiring manual review
|
|
1164
|
+
return {
|
|
1165
|
+
...vulnResult,
|
|
1166
|
+
evidence: `${vulnResult.evidence} [Context: SUSPECTED - requires manual review]`,
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
// ============================================================================
|
|
1170
|
+
// Issue #144: Excessive Permissions Scope Analysis (Challenge #22)
|
|
1171
|
+
// ============================================================================
|
|
1172
|
+
/**
|
|
1173
|
+
* Analyze response for excessive permissions scope violations (Issue #144, Challenge #22)
|
|
1174
|
+
* Detects when tools exceed their declared annotation scope:
|
|
1175
|
+
* - scope_violation: Tool performed privileged action despite restrictive annotations
|
|
1176
|
+
* - scope_escalation: Keyword triggered hidden admin/privilege mode
|
|
1177
|
+
* - scope_enforced: Tool properly blocked the privileged action (safe)
|
|
1178
|
+
*
|
|
1179
|
+
* CWE-250: Execution with Unnecessary Privileges
|
|
1180
|
+
* CWE-269: Improper Privilege Management
|
|
1181
|
+
*/
|
|
1182
|
+
analyzeExcessivePermissionsResponse(response) {
|
|
1183
|
+
const responseText = this.extractResponseContent(response);
|
|
1184
|
+
const cweIds = [];
|
|
1185
|
+
// Check for safe/hardened patterns first (scope enforced)
|
|
1186
|
+
for (const { pattern, evidence } of SCOPE_ENFORCED_PATTERNS) {
|
|
1187
|
+
if (pattern.test(responseText)) {
|
|
1188
|
+
return {
|
|
1189
|
+
detected: false,
|
|
1190
|
+
violationType: "SAFE",
|
|
1191
|
+
cweIds: [],
|
|
1192
|
+
evidence,
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
// Check for scope violation patterns
|
|
1197
|
+
for (const { pattern, evidence } of SCOPE_VIOLATION_PATTERNS) {
|
|
1198
|
+
if (pattern.test(responseText)) {
|
|
1199
|
+
// Determine specific violation type based on pattern
|
|
1200
|
+
if (/"scope_escalation"\s*:\s*true/i.test(responseText)) {
|
|
1201
|
+
// Scope escalation - keyword-triggered privilege escalation
|
|
1202
|
+
cweIds.push("CWE-269");
|
|
1203
|
+
// Extract trigger keyword if present
|
|
1204
|
+
const keywordMatch = responseText.match(/"trigger_keyword"\s*:\s*"([^"]+)"/i);
|
|
1205
|
+
const triggerPayload = keywordMatch?.[1];
|
|
1206
|
+
return {
|
|
1207
|
+
detected: true,
|
|
1208
|
+
violationType: "SCOPE_ESCALATION",
|
|
1209
|
+
triggerPayload,
|
|
1210
|
+
cweIds,
|
|
1211
|
+
evidence,
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
if (/"scope_violation"\s*:\s*true/i.test(responseText)) {
|
|
1215
|
+
// Scope violation - action exceeded declared scope
|
|
1216
|
+
cweIds.push("CWE-250", "CWE-269");
|
|
1217
|
+
// Extract actual scope if present
|
|
1218
|
+
const scopeMatch = responseText.match(/"actual_scope"\s*:\s*"([^"]+)"/i);
|
|
1219
|
+
const actualScope = scopeMatch?.[1];
|
|
1220
|
+
return {
|
|
1221
|
+
detected: true,
|
|
1222
|
+
violationType: "SCOPE_VIOLATION",
|
|
1223
|
+
actualScope,
|
|
1224
|
+
cweIds,
|
|
1225
|
+
evidence,
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
// Generic detection (privileged_data, system_secrets, admin_mode_activated)
|
|
1229
|
+
cweIds.push("CWE-250", "CWE-269");
|
|
1230
|
+
return {
|
|
1231
|
+
detected: true,
|
|
1232
|
+
violationType: "SCOPE_VIOLATION",
|
|
1233
|
+
cweIds,
|
|
1234
|
+
evidence,
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
// No scope violation or enforcement detected
|
|
1239
|
+
return {
|
|
1240
|
+
detected: false,
|
|
1241
|
+
violationType: "UNKNOWN",
|
|
1242
|
+
cweIds: [],
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
1233
1245
|
/**
|
|
1234
1246
|
* Analyze injection response (fallback logic)
|
|
1235
1247
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bryan-thompson/inspector-assessment-client",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.3",
|
|
4
4
|
"description": "Client-side application for the Enhanced MCP Inspector with assessment capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bryan Thompson <bryan@triepod.ai>",
|