@highflame/policy 2.1.13 → 2.1.14

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.
@@ -0,0 +1,77 @@
1
+ // =============================================================================
2
+ // MCP Tool Permissions Template (MCPGateway)
3
+ // =============================================================================
4
+ // Per-tool access control for MCP servers.
5
+ // Complements the MCP Server Allowlist (connect_server action)
6
+ // with fine-grained per-tool control on call_tool action.
7
+ //
8
+ // Category: tools
9
+ // Namespace: MCPGateway
10
+ // =============================================================================
11
+
12
+ // -- GitHub MCP: Read-only access -------------------------------------------
13
+
14
+ @id("mcp-tool-allow-read-github")
15
+ @name("Allow read-only GitHub tools")
16
+ @description("Permit read operations from GitHub MCP server")
17
+ @severity("medium")
18
+ @tags("mcp,github,read-only,least-privilege")
19
+ permit (
20
+ principal,
21
+ action == MCPGateway::Action::"call_tool",
22
+ resource
23
+ ) when {
24
+ context has mcp_server && context.mcp_server == "github" &&
25
+ context has tool_name &&
26
+ (context.tool_name == "read_issues" ||
27
+ context.tool_name == "get_issue" ||
28
+ context.tool_name == "list_repos" ||
29
+ context.tool_name == "get_pull_request" ||
30
+ context.tool_name == "search_code" ||
31
+ context.tool_name == "get_file_contents")
32
+ };
33
+
34
+ @id("mcp-tool-deny-write-github")
35
+ @name("Deny write GitHub tools")
36
+ @description("Block create/update/delete operations on GitHub MCP server")
37
+ @severity("high")
38
+ @tags("mcp,github,write-block,least-privilege")
39
+ forbid (
40
+ principal,
41
+ action == MCPGateway::Action::"call_tool",
42
+ resource
43
+ ) when {
44
+ context has mcp_server && context.mcp_server == "github"
45
+ };
46
+
47
+ // -- Organization-wide MCP server exclusions --------------------------------
48
+
49
+ @id("mcp-tool-exclude-server")
50
+ @name("Exclude specific MCP servers")
51
+ @description("Block all tool calls from excluded MCP servers (org-wide exclusion list)")
52
+ @severity("critical")
53
+ @tags("mcp,exclusion,org-wide,block")
54
+ forbid (
55
+ principal,
56
+ action == MCPGateway::Action::"call_tool",
57
+ resource
58
+ ) when {
59
+ context has mcp_server &&
60
+ (context.mcp_server == "untrusted-server" ||
61
+ context.mcp_server == "deprecated-server")
62
+ };
63
+
64
+ // -- Block unverified MCP servers -------------------------------------------
65
+
66
+ @id("mcp-tool-block-unverified")
67
+ @name("Block tools from unverified MCP servers")
68
+ @description("Deny tool calls from MCP servers not in the verified registry")
69
+ @severity("high")
70
+ @tags("mcp,trust,verification")
71
+ forbid (
72
+ principal,
73
+ action == MCPGateway::Action::"call_tool",
74
+ resource
75
+ ) when {
76
+ context has mcp_server_verified && context.mcp_server_verified == false
77
+ };
@@ -0,0 +1,89 @@
1
+ {
2
+ "service": "mcp_gateway",
3
+ "version": "1.0.0",
4
+ "description": "MCPGateway policy templates for MCP proxy security",
5
+ "categories": [
6
+ {
7
+ "id": "semantic",
8
+ "name": "Semantic Threat Detection",
9
+ "description": "Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats in MCP operations"
10
+ },
11
+ {
12
+ "id": "tools",
13
+ "name": "Tool Permissioning",
14
+ "description": "Control access to MCP tools, enforce risk scoring, and manage per-tool permissions"
15
+ },
16
+ {
17
+ "id": "organization",
18
+ "name": "Organization Rules",
19
+ "description": "Apply organization-wide policy baselines for MCP gateway operations"
20
+ },
21
+ {
22
+ "id": "agent_security",
23
+ "name": "Agent Security",
24
+ "description": "Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats"
25
+ }
26
+ ],
27
+ "defaults": [
28
+ {
29
+ "id": "baseline-default",
30
+ "name": "Baseline Permit",
31
+ "description": "Permits all actions by default -- threat-specific forbid policies override this when threats are detected",
32
+ "category": "organization",
33
+ "file": "defaults/baseline.cedar",
34
+ "severity": "low",
35
+ "tags": ["baseline", "permit-default", "organization"],
36
+ "is_active": true
37
+ },
38
+ {
39
+ "id": "semantic-default",
40
+ "name": "Semantic Threat Detection",
41
+ "description": "Detect and block prompt injection, jailbreak attempts, and high-severity threats in MCP tool calls",
42
+ "category": "semantic",
43
+ "file": "defaults/semantic.cedar",
44
+ "severity": "critical",
45
+ "tags": ["prompt-injection", "jailbreak", "owasp-llm01", "owasp-llm02", "security", "baseline"],
46
+ "is_active": true
47
+ },
48
+ {
49
+ "id": "tools-default",
50
+ "name": "Tool Permissioning",
51
+ "description": "Enforce tool risk scoring, block dangerous tools, and detect command injection in MCP tool arguments",
52
+ "category": "tools",
53
+ "file": "defaults/tools.cedar",
54
+ "severity": "critical",
55
+ "tags": ["tool-risk", "command-injection", "owasp-llm06", "owasp-asi02", "baseline"],
56
+ "is_active": true
57
+ },
58
+ {
59
+ "id": "agent-security-default",
60
+ "name": "Agent Security",
61
+ "description": "Detect and block tool poisoning, rug pull attacks, indirect prompt injection, and MCP supply chain threats",
62
+ "category": "agent_security",
63
+ "file": "defaults/agent_security.cedar",
64
+ "severity": "critical",
65
+ "tags": ["tool-poisoning", "rug-pull", "indirect-injection", "mcp-security", "owasp-asi01", "owasp-asi04", "baseline"],
66
+ "is_active": true
67
+ }
68
+ ],
69
+ "templates": [
70
+ {
71
+ "id": "tools-mcp-allowlist",
72
+ "name": "MCP Server Allowlist",
73
+ "description": "Only allow specific MCP servers to be used",
74
+ "category": "tools",
75
+ "file": "mcp_server_allowlist.cedar",
76
+ "severity": "medium",
77
+ "tags": ["mcp", "allowlist", "whitelist"]
78
+ },
79
+ {
80
+ "id": "tools-mcp-tool-permissions",
81
+ "name": "MCP Tool Permissions",
82
+ "description": "Per-tool access control for MCP servers -- allow specific tools while denying others, exclude servers org-wide, block unverified sources",
83
+ "category": "tools",
84
+ "file": "mcp_tool_permissions.cedar",
85
+ "severity": "high",
86
+ "tags": ["mcp", "tools", "least-privilege", "per-server", "exclusion"]
87
+ }
88
+ ]
89
+ }
package/dist/index.d.ts CHANGED
@@ -9,19 +9,23 @@ export * from './errors.js';
9
9
  export * from './annotations.js';
10
10
  export * from './explain.js';
11
11
  export * from './condition-groups.js';
12
- export { GUARDRAILS_SCHEMA, GUARDRAILS_CONTEXT, OVERWATCH_SCHEMA, OVERWATCH_CONTEXT, PALISADE_SCHEMA, PALISADE_CONTEXT, SENTRY_SCHEMA, SENTRY_CONTEXT, } from './service-schemas.gen.js';
12
+ export { GUARDRAILS_SCHEMA, GUARDRAILS_CONTEXT, MCP_GATEWAY_SCHEMA, MCP_GATEWAY_CONTEXT, OVERWATCH_SCHEMA, OVERWATCH_CONTEXT, PALISADE_SCHEMA, PALISADE_CONTEXT, SENTRY_SCHEMA, SENTRY_CONTEXT, } from './service-schemas.gen.js';
13
13
  export type { ContextAttribute, ActionContext, ServiceContext, } from './service-schemas.gen.js';
14
14
  export { GuardrailsContextKey } from './guardrails-context.gen.js';
15
+ export { McpGatewayContextKey } from './mcp_gateway-context.gen.js';
15
16
  export { OverwatchContextKey } from './overwatch-context.gen.js';
16
17
  export { PalisadeContextKey } from './palisade-context.gen.js';
17
18
  export { SentryContextKey } from './sentry-context.gen.js';
18
19
  export { GUARDRAILS_ENTITIES, GUARDRAILS_ACTION_ENTITIES, } from './guardrails-entities.gen.js';
20
+ export { MCP_GATEWAY_ENTITIES, MCP_GATEWAY_ACTION_ENTITIES, } from './mcp_gateway-entities.gen.js';
19
21
  export { OVERWATCH_ENTITIES, OVERWATCH_ACTION_ENTITIES, } from './overwatch-entities.gen.js';
20
22
  export { PALISADE_ENTITIES, PALISADE_ACTION_ENTITIES, } from './palisade-entities.gen.js';
21
23
  export { SENTRY_ENTITIES, SENTRY_ACTION_ENTITIES, } from './sentry-entities.gen.js';
22
24
  export type { ServiceEntityMetadata, ActionEntityMetadata } from './entity-metadata-types.gen.js';
23
25
  export { GUARDRAILS_DEFAULTS, GUARDRAILS_TEMPLATES, GUARDRAILS_CATEGORIES, GUARDRAILS_TEMPLATES_JSON, getGuardrailsDefaultsByCategory, getGuardrailsTemplatesByCategory, getGuardrailsTemplateById, } from './guardrails-defaults.gen.js';
24
26
  export type { GuardrailsCategory, GuardrailsCategoryInfo, GuardrailsDefaultPolicy, GuardrailsTemplate, } from './guardrails-defaults.gen.js';
27
+ export { MCP_GATEWAY_DEFAULTS, MCP_GATEWAY_TEMPLATES, MCP_GATEWAY_CATEGORIES, MCP_GATEWAY_TEMPLATES_JSON, getMcpGatewayDefaultsByCategory, getMcpGatewayTemplatesByCategory, getMcpGatewayTemplateById, } from './mcp_gateway-defaults.gen.js';
28
+ export type { McpGatewayCategory, McpGatewayCategoryInfo, McpGatewayDefaultPolicy, McpGatewayTemplate, } from './mcp_gateway-defaults.gen.js';
25
29
  export { OVERWATCH_DEFAULTS, OVERWATCH_TEMPLATES, OVERWATCH_CATEGORIES, OVERWATCH_TEMPLATES_JSON, getOverwatchDefaultsByCategory, getOverwatchTemplatesByCategory, getOverwatchTemplateById, } from './overwatch-defaults.gen.js';
26
30
  export type { OverwatchCategory, OverwatchCategoryInfo, OverwatchDefaultPolicy, OverwatchTemplate, } from './overwatch-defaults.gen.js';
27
31
  export { SENTRY_DEFAULTS, SENTRY_TEMPLATES, SENTRY_CATEGORIES, SENTRY_TEMPLATES_JSON, getSentryDefaultsByCategory, getSentryTemplatesByCategory, getSentryTemplateById, } from './sentry-defaults.gen.js';
package/dist/index.js CHANGED
@@ -18,18 +18,21 @@ export * from './explain.js';
18
18
  // Condition groups (AST ↔ flat UI groups)
19
19
  export * from './condition-groups.js';
20
20
  // Service-specific schemas and context (inlined)
21
- export { GUARDRAILS_SCHEMA, GUARDRAILS_CONTEXT, OVERWATCH_SCHEMA, OVERWATCH_CONTEXT, PALISADE_SCHEMA, PALISADE_CONTEXT, SENTRY_SCHEMA, SENTRY_CONTEXT, } from './service-schemas.gen.js';
21
+ export { GUARDRAILS_SCHEMA, GUARDRAILS_CONTEXT, MCP_GATEWAY_SCHEMA, MCP_GATEWAY_CONTEXT, OVERWATCH_SCHEMA, OVERWATCH_CONTEXT, PALISADE_SCHEMA, PALISADE_CONTEXT, SENTRY_SCHEMA, SENTRY_CONTEXT, } from './service-schemas.gen.js';
22
22
  // Service-specific context key enums
23
23
  export { GuardrailsContextKey } from './guardrails-context.gen.js';
24
+ export { McpGatewayContextKey } from './mcp_gateway-context.gen.js';
24
25
  export { OverwatchContextKey } from './overwatch-context.gen.js';
25
26
  export { PalisadeContextKey } from './palisade-context.gen.js';
26
27
  export { SentryContextKey } from './sentry-context.gen.js';
27
28
  // Service-specific entity metadata (for UI - principals, resources, actions)
28
29
  export { GUARDRAILS_ENTITIES, GUARDRAILS_ACTION_ENTITIES, } from './guardrails-entities.gen.js';
30
+ export { MCP_GATEWAY_ENTITIES, MCP_GATEWAY_ACTION_ENTITIES, } from './mcp_gateway-entities.gen.js';
29
31
  export { OVERWATCH_ENTITIES, OVERWATCH_ACTION_ENTITIES, } from './overwatch-entities.gen.js';
30
32
  export { PALISADE_ENTITIES, PALISADE_ACTION_ENTITIES, } from './palisade-entities.gen.js';
31
33
  export { SENTRY_ENTITIES, SENTRY_ACTION_ENTITIES, } from './sentry-entities.gen.js';
32
34
  // Service-specific default policies, templates, and categories
33
35
  export { GUARDRAILS_DEFAULTS, GUARDRAILS_TEMPLATES, GUARDRAILS_CATEGORIES, GUARDRAILS_TEMPLATES_JSON, getGuardrailsDefaultsByCategory, getGuardrailsTemplatesByCategory, getGuardrailsTemplateById, } from './guardrails-defaults.gen.js';
36
+ export { MCP_GATEWAY_DEFAULTS, MCP_GATEWAY_TEMPLATES, MCP_GATEWAY_CATEGORIES, MCP_GATEWAY_TEMPLATES_JSON, getMcpGatewayDefaultsByCategory, getMcpGatewayTemplatesByCategory, getMcpGatewayTemplateById, } from './mcp_gateway-defaults.gen.js';
34
37
  export { OVERWATCH_DEFAULTS, OVERWATCH_TEMPLATES, OVERWATCH_CATEGORIES, OVERWATCH_TEMPLATES_JSON, getOverwatchDefaultsByCategory, getOverwatchTemplatesByCategory, getOverwatchTemplateById, } from './overwatch-defaults.gen.js';
35
38
  export { SENTRY_DEFAULTS, SENTRY_TEMPLATES, SENTRY_CATEGORIES, SENTRY_TEMPLATES_JSON, getSentryDefaultsByCategory, getSentryTemplatesByCategory, getSentryTemplateById, } from './sentry-defaults.gen.js';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Context attribute keys for McpGateway Context attributes for MCPGateway Cedar policies.
3
+ *
4
+ * These constants correspond to the context attributes defined in the
5
+ * McpGateway Cedar schema and are used at policy evaluation time.
6
+ */
7
+ export declare const McpGatewayContextKey: {
8
+ readonly ContainsInvisibleChars: "contains_invisible_chars";
9
+ readonly ContainsSecrets: "contains_secrets";
10
+ readonly Content: "content";
11
+ readonly CrimeScore: "crime_score";
12
+ readonly DetectedThreats: "detected_threats";
13
+ readonly HateSpeechScore: "hate_speech_score";
14
+ readonly HighestSeverity: "highest_severity";
15
+ readonly IndirectInjectionScore: "indirect_injection_score";
16
+ readonly InjectionConfidence: "injection_confidence";
17
+ readonly InvisibleCharsScore: "invisible_chars_score";
18
+ readonly JailbreakConfidence: "jailbreak_confidence";
19
+ readonly LoopCount: "loop_count";
20
+ readonly LoopDetected: "loop_detected";
21
+ readonly MaxThreatSeverity: "max_threat_severity";
22
+ readonly McpConfigRisk: "mcp_config_risk";
23
+ readonly McpRiskScore: "mcp_risk_score";
24
+ readonly McpServer: "mcp_server";
25
+ readonly McpServerVerified: "mcp_server_verified";
26
+ readonly McpTool: "mcp_tool";
27
+ readonly PatternType: "pattern_type";
28
+ readonly PiiCount: "pii_count";
29
+ readonly PiiDetected: "pii_detected";
30
+ readonly PiiTypes: "pii_types";
31
+ readonly ProfanityScore: "profanity_score";
32
+ readonly RugPullDetected: "rug_pull_detected";
33
+ readonly RugPullScore: "rug_pull_score";
34
+ readonly SecretCount: "secret_count";
35
+ readonly SecretTypes: "secret_types";
36
+ readonly SequenceRisk: "sequence_risk";
37
+ readonly SexualScore: "sexual_score";
38
+ readonly SuspiciousPattern: "suspicious_pattern";
39
+ readonly ThreatCategories: "threat_categories";
40
+ readonly ThreatCount: "threat_count";
41
+ readonly ToolCategory: "tool_category";
42
+ readonly ToolIsBuiltin: "tool_is_builtin";
43
+ readonly ToolIsSensitive: "tool_is_sensitive";
44
+ readonly ToolName: "tool_name";
45
+ readonly ToolPoisoningDetected: "tool_poisoning_detected";
46
+ readonly ToolPoisoningScore: "tool_poisoning_score";
47
+ readonly ToolRiskScore: "tool_risk_score";
48
+ readonly ViolenceScore: "violence_score";
49
+ readonly WeaponsScore: "weapons_score";
50
+ };
51
+ export type McpGatewayContextKey = (typeof McpGatewayContextKey)[keyof typeof McpGatewayContextKey];
@@ -0,0 +1,52 @@
1
+ // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
+ // Source: schemas/mcp_gateway/context.json
3
+ /**
4
+ * Context attribute keys for McpGateway Context attributes for MCPGateway Cedar policies.
5
+ *
6
+ * These constants correspond to the context attributes defined in the
7
+ * McpGateway Cedar schema and are used at policy evaluation time.
8
+ */
9
+ export const McpGatewayContextKey = {
10
+ ContainsInvisibleChars: 'contains_invisible_chars',
11
+ ContainsSecrets: 'contains_secrets',
12
+ Content: 'content',
13
+ CrimeScore: 'crime_score',
14
+ DetectedThreats: 'detected_threats',
15
+ HateSpeechScore: 'hate_speech_score',
16
+ HighestSeverity: 'highest_severity',
17
+ IndirectInjectionScore: 'indirect_injection_score',
18
+ InjectionConfidence: 'injection_confidence',
19
+ InvisibleCharsScore: 'invisible_chars_score',
20
+ JailbreakConfidence: 'jailbreak_confidence',
21
+ LoopCount: 'loop_count',
22
+ LoopDetected: 'loop_detected',
23
+ MaxThreatSeverity: 'max_threat_severity',
24
+ McpConfigRisk: 'mcp_config_risk',
25
+ McpRiskScore: 'mcp_risk_score',
26
+ McpServer: 'mcp_server',
27
+ McpServerVerified: 'mcp_server_verified',
28
+ McpTool: 'mcp_tool',
29
+ PatternType: 'pattern_type',
30
+ PiiCount: 'pii_count',
31
+ PiiDetected: 'pii_detected',
32
+ PiiTypes: 'pii_types',
33
+ ProfanityScore: 'profanity_score',
34
+ RugPullDetected: 'rug_pull_detected',
35
+ RugPullScore: 'rug_pull_score',
36
+ SecretCount: 'secret_count',
37
+ SecretTypes: 'secret_types',
38
+ SequenceRisk: 'sequence_risk',
39
+ SexualScore: 'sexual_score',
40
+ SuspiciousPattern: 'suspicious_pattern',
41
+ ThreatCategories: 'threat_categories',
42
+ ThreatCount: 'threat_count',
43
+ ToolCategory: 'tool_category',
44
+ ToolIsBuiltin: 'tool_is_builtin',
45
+ ToolIsSensitive: 'tool_is_sensitive',
46
+ ToolName: 'tool_name',
47
+ ToolPoisoningDetected: 'tool_poisoning_detected',
48
+ ToolPoisoningScore: 'tool_poisoning_score',
49
+ ToolRiskScore: 'tool_risk_score',
50
+ ViolenceScore: 'violence_score',
51
+ WeaponsScore: 'weapons_score',
52
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * McpGateway policy category identifiers.
3
+ * Maps to UI tab names in Studio.
4
+ */
5
+ export type McpGatewayCategory = 'semantic' | 'tools' | 'organization' | 'agent_security';
6
+ /**
7
+ * Category metadata for UI display.
8
+ */
9
+ export interface McpGatewayCategoryInfo {
10
+ id: McpGatewayCategory;
11
+ name: string;
12
+ description: string;
13
+ }
14
+ /**
15
+ * A default policy that is auto-created for new projects.
16
+ */
17
+ export interface McpGatewayDefaultPolicy {
18
+ /** Template identifier */
19
+ id: string;
20
+ /** Human-readable name */
21
+ name: string;
22
+ /** Description for UI display */
23
+ description: string;
24
+ /** Policy category */
25
+ category: McpGatewayCategory;
26
+ /** Cedar policy text (source of truth) */
27
+ cedarText: string;
28
+ /** Severity level */
29
+ severity: string;
30
+ /** Tags for filtering */
31
+ tags: string[];
32
+ /** Whether this default should be activated immediately */
33
+ isActive: boolean;
34
+ }
35
+ /**
36
+ * A policy template available for users to create from.
37
+ */
38
+ export interface McpGatewayTemplate {
39
+ /** Template identifier */
40
+ id: string;
41
+ /** Human-readable name */
42
+ name: string;
43
+ /** Description for UI display */
44
+ description: string;
45
+ /** Policy category */
46
+ category: McpGatewayCategory;
47
+ /** Cedar policy text */
48
+ cedarText: string;
49
+ /** Severity level */
50
+ severity: string;
51
+ /** Tags for filtering */
52
+ tags: string[];
53
+ }
54
+ export declare const MCP_GATEWAY_CATEGORIES: McpGatewayCategoryInfo[];
55
+ export declare const MCP_GATEWAY_DEFAULTS: McpGatewayDefaultPolicy[];
56
+ export declare const MCP_GATEWAY_TEMPLATES: McpGatewayTemplate[];
57
+ /** Raw templates.json metadata for the McpGateway service. */
58
+ export declare const MCP_GATEWAY_TEMPLATES_JSON: string;
59
+ export declare function getMcpGatewayDefaultsByCategory(category: McpGatewayCategory): McpGatewayDefaultPolicy[];
60
+ export declare function getMcpGatewayTemplatesByCategory(category: McpGatewayCategory): McpGatewayTemplate[];
61
+ export declare function getMcpGatewayTemplateById(id: string): McpGatewayTemplate | undefined;