Repository navigation
Expand file tree
/
Copy pathCopilotSafetyModels.cs
More file actions
161 lines (153 loc) · 5.17 KB
/
Copy pathCopilotSafetyModels.cs
File metadata and controls
161 lines (153 loc) · 5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System;
using System.Collections.Generic;
using MissionController.Core.Enums;
namespace MissionController.Core.Models;
/// <summary>
/// Execution environment target for a Copilot tool invocation.
/// </summary>
public enum CopilotExecutionEnvironment
{
/// <summary>
/// Native Windows execution using Win32 Job Objects, Restricted Token de-escalation, and NT ACL jails.
/// </summary>
WindowsJobSandbox,
/// <summary>
/// Linux/WSL2 execution using in-kernel BPF-LSM capability leases, cgroups v2, and OverlayFS.
/// </summary>
LinuxBpfLsmLease
}
/// <summary>
/// Security classification and risk severity for Copilot actions and violations.
/// </summary>
public enum CopilotSecuritySeverity
{
Informational = 1,
Low = 2,
Medium = 3,
High = 4,
Critical = 5
}
/// <summary>
/// CISO enterprise policy rules governing Copilot and Semantic Kernel tool execution.
/// </summary>
public record CopilotSafetyPolicy(
string PolicyId,
string PolicyName,
bool EnforceRestrictedToken,
bool EnforceJobObjectResourceLimits,
bool StreamToMicrosoftSentinel,
IReadOnlyList<string> AllowedExecutables,
IReadOnlyList<string> BlockedPathSubstrings,
IReadOnlyList<string> BlockedArgumentPatterns,
long MaxMemoryBytes = 256 * 1024 * 1024, // 256 MB default
int MaxCpuPercent = 50, // 50% CPU clamp
int TimeoutSeconds = 30, // 30s timeout
bool AllowNetworkEgress = false,
IReadOnlyList<string>? AllowedEgressIps = null,
IReadOnlyList<uint>? AllowedEgressPorts = null)
{
/// <summary>
/// Default hardened CISO policy for enterprise Windows Copilot deployments.
/// </summary>
public static CopilotSafetyPolicy CreateEnterpriseDefault() => new(
PolicyId: "POL-COPILOT-DEFAULT-CISO",
PolicyName: "Enterprise Copilot Native Hardening Policy",
EnforceRestrictedToken: true,
EnforceJobObjectResourceLimits: true,
StreamToMicrosoftSentinel: true,
AllowedExecutables: new[]
{
"powershell.exe", "pwsh.exe", "cmd.exe", "wmic.exe", "netstat.exe",
"ipconfig.exe", "ping.exe", "tracert.exe", "nslookup.exe", "systeminfo.exe",
"tasklist.exe", "whoami.exe", "python.exe", "python3.exe", "git.exe", "curl.exe"
},
BlockedPathSubstrings: new[]
{
@"\System32\config\SAM",
@"\System32\config\SYSTEM",
@"\System32\config\SECURITY",
@"\Windows\NTDS",
@"\.ssh\",
@"\.aws\",
@"\.azure\",
@"\AppData\Local\Microsoft\Credentials",
@"\AppData\Roaming\Microsoft\Credentials",
@"\AppData\Roaming\Microsoft\Protect",
@"/etc/shadow",
@"/etc/sudoers",
@"/root/.ssh"
},
BlockedArgumentPatterns: new[]
{
"Invoke-Expression",
"iex ",
"DownloadString",
"IEX(",
"mimikatz",
"sekurlsa",
"procdump",
"lsass",
"Set-ExecutionPolicy Unrestricted",
"Disable-WindowsOptionalFeature"
},
MaxMemoryBytes: 256 * 1024 * 1024,
MaxCpuPercent: 50,
TimeoutSeconds: 30,
AllowNetworkEgress: false,
AllowedEgressIps: new[] { "127.0.0.1" },
AllowedEgressPorts: new uint[] { 80, 443 }
);
}
/// <summary>
/// Telemetry context passed when a Copilot agent invokes a tool or Semantic Kernel function.
/// </summary>
public record CopilotToolCallContext(
Guid SessionId,
string AgentId,
string ToolName,
string ExecutableOrCommand,
string Arguments,
string? WorkingDirectory,
string OperatorIdentity,
IReadOnlyDictionary<string, string>? Metadata = null,
CopilotExecutionEnvironment PreferredEnvironment = CopilotExecutionEnvironment.WindowsJobSandbox);
/// <summary>
/// Security violation detected by SPLAT pre-execution checks or in-kernel hooks.
/// </summary>
public record CopilotSecurityViolation(
string ViolationType,
string Description,
CopilotSecuritySeverity Severity,
string OffendingValue,
DateTime TimestampUtc);
/// <summary>
/// Result returned after executing a Copilot tool within the SPLAT safety substrate.
/// </summary>
public record CopilotExecutionResult(
bool IsSuccess,
bool PolicyBlocked,
int ExitCode,
string StandardOutput,
string StandardError,
bool TimedOut,
JobResourceMetrics? ResourceMetrics,
IReadOnlyList<CopilotSecurityViolation> Violations,
string? MerkleEntryHash,
DateTime TimestampUtc)
{
public static CopilotExecutionResult Blocked(
string reason,
IReadOnlyList<CopilotSecurityViolation> violations,
string? merkleHash = null) =>
new(
IsSuccess: false,
PolicyBlocked: true,
ExitCode: -1,
StandardOutput: string.Empty,
StandardError: $"[SPLAT COPILOT SAFETY SUBSTRATE] Blocked tool execution: {reason}",
TimedOut: false,
ResourceMetrics: null,
Violations: violations,
MerkleEntryHash: merkleHash,
TimestampUtc: DateTime.UtcNow);
}