skillshield 1.0.0 → 2.0.0
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/shield/audit-trail.d.ts +67 -0
- package/dist/shield/audit-trail.d.ts.map +1 -0
- package/dist/shield/audit-trail.js +140 -0
- package/dist/shield/audit-trail.js.map +1 -0
- package/dist/shield/filesystem-jail.d.ts +80 -0
- package/dist/shield/filesystem-jail.d.ts.map +1 -0
- package/dist/shield/filesystem-jail.js +320 -0
- package/dist/shield/filesystem-jail.js.map +1 -0
- package/dist/shield/index.d.ts +82 -0
- package/dist/shield/index.d.ts.map +1 -0
- package/dist/shield/index.js +88 -0
- package/dist/shield/index.js.map +1 -0
- package/dist/shield/network-policy.d.ts +74 -0
- package/dist/shield/network-policy.d.ts.map +1 -0
- package/dist/shield/network-policy.js +226 -0
- package/dist/shield/network-policy.js.map +1 -0
- package/dist/shield/runtime-monitor.d.ts +106 -0
- package/dist/shield/runtime-monitor.d.ts.map +1 -0
- package/dist/shield/runtime-monitor.js +233 -0
- package/dist/shield/runtime-monitor.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillShield — Network Policy Engine
|
|
3
|
+
*
|
|
4
|
+
* Per-skill domain allowlisting. Skills declare which domains they need,
|
|
5
|
+
* and SkillShield blocks everything else at the DNS resolution level.
|
|
6
|
+
*
|
|
7
|
+
* This is what Snyk and Cisco DON'T do — they scan before install,
|
|
8
|
+
* but can't stop a skill from phoning home at runtime.
|
|
9
|
+
*/
|
|
10
|
+
/** Known malicious domains commonly used in skill attacks */
|
|
11
|
+
const MALICIOUS_DOMAINS = [
|
|
12
|
+
'evil.com',
|
|
13
|
+
'attacker.com',
|
|
14
|
+
'exfil.io',
|
|
15
|
+
'c2server.net',
|
|
16
|
+
'malware.download',
|
|
17
|
+
'ngrok.io', // Tunneling — often used for exfiltration
|
|
18
|
+
'requestbin.com', // Data capture
|
|
19
|
+
'webhook.site', // Data capture
|
|
20
|
+
'pipedream.net', // Data capture
|
|
21
|
+
'burpcollaborator.net', // Pentesting tool
|
|
22
|
+
];
|
|
23
|
+
/** Known mining pool domains */
|
|
24
|
+
const MINING_DOMAINS = [
|
|
25
|
+
'pool.monero.cc',
|
|
26
|
+
'xmr.pool.minergate.com',
|
|
27
|
+
'cryptonight.usa.nicehash.com',
|
|
28
|
+
'mine.xmrpool.net',
|
|
29
|
+
'coinhive.com',
|
|
30
|
+
'authedmine.com',
|
|
31
|
+
];
|
|
32
|
+
export class NetworkPolicyEngine {
|
|
33
|
+
constructor(policy) {
|
|
34
|
+
this.violations = [];
|
|
35
|
+
this.connectionCount = 0;
|
|
36
|
+
this.transferredBytes = 0;
|
|
37
|
+
this.policy = policy;
|
|
38
|
+
this.blockedDomains = new Set([
|
|
39
|
+
...MALICIOUS_DOMAINS,
|
|
40
|
+
...(policy.blockMalicious !== false ? MINING_DOMAINS : []),
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a domain is allowed by the policy.
|
|
45
|
+
* Returns true if allowed, false if blocked.
|
|
46
|
+
*/
|
|
47
|
+
checkDomain(domain) {
|
|
48
|
+
const normalizedDomain = domain.toLowerCase().trim();
|
|
49
|
+
// Check malicious domains first
|
|
50
|
+
if (this.blockedDomains.has(normalizedDomain)) {
|
|
51
|
+
this.recordViolation({
|
|
52
|
+
type: 'MALICIOUS_DOMAIN',
|
|
53
|
+
domain: normalizedDomain,
|
|
54
|
+
details: `Blocked known malicious domain: ${normalizedDomain}`,
|
|
55
|
+
});
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// Check against subdomain patterns in malicious list
|
|
59
|
+
for (const malicious of this.blockedDomains) {
|
|
60
|
+
if (normalizedDomain.endsWith(`.${malicious}`)) {
|
|
61
|
+
this.recordViolation({
|
|
62
|
+
type: 'MALICIOUS_DOMAIN',
|
|
63
|
+
domain: normalizedDomain,
|
|
64
|
+
details: `Blocked subdomain of malicious domain: ${normalizedDomain} (parent: ${malicious})`,
|
|
65
|
+
});
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Default deny mode — only allowlisted domains pass
|
|
70
|
+
if (this.policy.defaultDeny) {
|
|
71
|
+
const isAllowed = this.policy.allowedDomains.some((allowed) => {
|
|
72
|
+
const normalizedAllowed = allowed.toLowerCase().trim();
|
|
73
|
+
return (normalizedDomain === normalizedAllowed ||
|
|
74
|
+
normalizedDomain.endsWith(`.${normalizedAllowed}`));
|
|
75
|
+
});
|
|
76
|
+
if (!isAllowed) {
|
|
77
|
+
this.recordViolation({
|
|
78
|
+
type: 'DNS_BLOCKED',
|
|
79
|
+
domain: normalizedDomain,
|
|
80
|
+
details: `Domain not in allowlist: ${normalizedDomain}. Allowed: [${this.policy.allowedDomains.join(', ')}]`,
|
|
81
|
+
});
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if a connection attempt is allowed.
|
|
89
|
+
*/
|
|
90
|
+
checkConnection(domain, port) {
|
|
91
|
+
// Check domain first
|
|
92
|
+
if (!this.checkDomain(domain)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
// Check max connections
|
|
96
|
+
if (this.policy.maxConnections && this.connectionCount >= this.policy.maxConnections) {
|
|
97
|
+
this.recordViolation({
|
|
98
|
+
type: 'CONNECTION_BLOCKED',
|
|
99
|
+
domain,
|
|
100
|
+
port,
|
|
101
|
+
details: `Max connections exceeded: ${this.connectionCount}/${this.policy.maxConnections}`,
|
|
102
|
+
});
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
this.connectionCount++;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track data transfer and block if limit exceeded.
|
|
110
|
+
*/
|
|
111
|
+
trackTransfer(bytes) {
|
|
112
|
+
this.transferredBytes += bytes;
|
|
113
|
+
if (this.policy.maxTransferBytes && this.transferredBytes > this.policy.maxTransferBytes) {
|
|
114
|
+
this.recordViolation({
|
|
115
|
+
type: 'TRANSFER_EXCEEDED',
|
|
116
|
+
details: `Transfer limit exceeded: ${this.transferredBytes}/${this.policy.maxTransferBytes} bytes`,
|
|
117
|
+
});
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Generate the Node.js code that enforces this policy at runtime.
|
|
124
|
+
* This wraps the skill's execution with DNS/network interception.
|
|
125
|
+
*/
|
|
126
|
+
generateEnforcementCode() {
|
|
127
|
+
const allowedJSON = JSON.stringify(this.policy.allowedDomains);
|
|
128
|
+
const blockedJSON = JSON.stringify([...this.blockedDomains]);
|
|
129
|
+
return `
|
|
130
|
+
// ── SkillShield Network Policy Enforcement ──
|
|
131
|
+
const __ss_allowed = new Set(${allowedJSON}.map(d => d.toLowerCase()));
|
|
132
|
+
const __ss_blocked = new Set(${blockedJSON}.map(d => d.toLowerCase()));
|
|
133
|
+
const __ss_defaultDeny = ${this.policy.defaultDeny};
|
|
134
|
+
const __ss_maxTransfer = ${this.policy.maxTransferBytes || 0};
|
|
135
|
+
let __ss_transferred = 0;
|
|
136
|
+
|
|
137
|
+
const __ss_originalDnsLookup = require('dns').lookup;
|
|
138
|
+
require('dns').lookup = function(hostname, options, callback) {
|
|
139
|
+
const domain = hostname.toLowerCase();
|
|
140
|
+
|
|
141
|
+
// Block malicious
|
|
142
|
+
for (const blocked of __ss_blocked) {
|
|
143
|
+
if (domain === blocked || domain.endsWith('.' + blocked)) {
|
|
144
|
+
const err = new Error('[SkillShield] BLOCKED: ' + domain + ' is a known malicious domain');
|
|
145
|
+
err.code = 'ENOTFOUND';
|
|
146
|
+
if (typeof options === 'function') return options(err);
|
|
147
|
+
return callback(err);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Default deny check
|
|
152
|
+
if (__ss_defaultDeny) {
|
|
153
|
+
let allowed = false;
|
|
154
|
+
for (const a of __ss_allowed) {
|
|
155
|
+
if (domain === a || domain.endsWith('.' + a)) { allowed = true; break; }
|
|
156
|
+
}
|
|
157
|
+
if (!allowed) {
|
|
158
|
+
const err = new Error('[SkillShield] BLOCKED: ' + domain + ' not in network policy allowlist');
|
|
159
|
+
err.code = 'ENOTFOUND';
|
|
160
|
+
if (typeof options === 'function') return options(err);
|
|
161
|
+
return callback(err);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return __ss_originalDnsLookup.call(this, hostname, options, callback);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// Intercept http/https to track transfer size
|
|
169
|
+
const __ss_origRequest = require('https').request;
|
|
170
|
+
require('https').request = function(...args) {
|
|
171
|
+
const req = __ss_origRequest.apply(this, args);
|
|
172
|
+
req.on('response', (res) => {
|
|
173
|
+
res.on('data', (chunk) => {
|
|
174
|
+
__ss_transferred += chunk.length;
|
|
175
|
+
if (__ss_maxTransfer > 0 && __ss_transferred > __ss_maxTransfer) {
|
|
176
|
+
res.destroy(new Error('[SkillShield] Transfer limit exceeded: ' + __ss_transferred + ' bytes'));
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
return req;
|
|
181
|
+
};
|
|
182
|
+
// ── End SkillShield Network Policy ──
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
recordViolation(partial) {
|
|
186
|
+
this.violations.push({
|
|
187
|
+
...partial,
|
|
188
|
+
timestamp: new Date().toISOString(),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
getViolations() {
|
|
192
|
+
return [...this.violations];
|
|
193
|
+
}
|
|
194
|
+
getStats() {
|
|
195
|
+
return {
|
|
196
|
+
connections: this.connectionCount,
|
|
197
|
+
transferredBytes: this.transferredBytes,
|
|
198
|
+
violations: this.violations.length,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
reset() {
|
|
202
|
+
this.violations = [];
|
|
203
|
+
this.connectionCount = 0;
|
|
204
|
+
this.transferredBytes = 0;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Parse network policy from SKILL.md frontmatter.
|
|
209
|
+
* Expected format in frontmatter:
|
|
210
|
+
* network:
|
|
211
|
+
* allowed: ["api.openai.com", "api.anthropic.com"]
|
|
212
|
+
* maxTransferMB: 10
|
|
213
|
+
*/
|
|
214
|
+
export function parseNetworkPolicy(frontmatter) {
|
|
215
|
+
const network = (frontmatter.network || frontmatter.networking || {});
|
|
216
|
+
const allowed = (network.allowed || network.domains || []);
|
|
217
|
+
const maxTransferMB = (network.maxTransferMB || network.maxTransfer || 10);
|
|
218
|
+
return {
|
|
219
|
+
allowedDomains: allowed.length > 0 ? allowed : [],
|
|
220
|
+
defaultDeny: allowed.length > 0, // If skill declares domains, enforce them
|
|
221
|
+
maxConnections: network.maxConnections || 50,
|
|
222
|
+
maxTransferBytes: maxTransferMB * 1024 * 1024,
|
|
223
|
+
blockMalicious: true,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=network-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-policy.js","sourceRoot":"","sources":["../../src/shield/network-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0BH,6DAA6D;AAC7D,MAAM,iBAAiB,GAAa;IAClC,UAAU;IACV,cAAc;IACd,UAAU;IACV,cAAc;IACd,kBAAkB;IAClB,UAAU,EAAQ,0CAA0C;IAC5D,gBAAgB,EAAE,eAAe;IACjC,cAAc,EAAI,eAAe;IACjC,eAAe,EAAG,eAAe;IACjC,sBAAsB,EAAE,kBAAkB;CAC3C,CAAC;AAEF,gCAAgC;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I,CAAC,eAAe;YACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;SACnC,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAoC;IACrE,MAAM,OAAO,GAAG,CAAC,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,UAAU,IAAI,EAAE,CAA4B,CAAC;IACjG,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,CAAa,CAAC;IACvE,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,WAAW,IAAI,EAAE,CAAW,CAAC;IAErF,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QACjD,WAAW,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,0CAA0C;QAC3E,cAAc,EAAG,OAAO,CAAC,cAAyB,IAAI,EAAE;QACxD,gBAAgB,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI;QAC7C,cAAc,EAAE,IAAI;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillShield — Runtime Monitor + Kill Switch
|
|
3
|
+
*
|
|
4
|
+
* Real-time monitoring of skill execution. Watches stdout/stderr
|
|
5
|
+
* for threat patterns, tracks resource consumption, and kills the
|
|
6
|
+
* process if anomalies are detected.
|
|
7
|
+
*
|
|
8
|
+
* This is the core differentiator: Snyk scans before install,
|
|
9
|
+
* SkillShield watches DURING execution.
|
|
10
|
+
*/
|
|
11
|
+
import { ChildProcess } from 'child_process';
|
|
12
|
+
import { type ThreatCategory, type SeverityLevel } from '../guard/patterns.js';
|
|
13
|
+
export interface MonitorPolicy {
|
|
14
|
+
/** Max execution time in ms (kill switch) */
|
|
15
|
+
maxExecutionTime: number;
|
|
16
|
+
/** Max memory in MB (kill switch) */
|
|
17
|
+
maxMemoryMB: number;
|
|
18
|
+
/** Max output size in bytes (prevent output flooding) */
|
|
19
|
+
maxOutputBytes: number;
|
|
20
|
+
/** Severity threshold to trigger kill (CRITICAL = kill immediately) */
|
|
21
|
+
killOnSeverity: SeverityLevel;
|
|
22
|
+
/** Re-scan output for threats in real-time */
|
|
23
|
+
enableOutputScanning: boolean;
|
|
24
|
+
/** Max violations before kill */
|
|
25
|
+
maxViolations: number;
|
|
26
|
+
/** Categories that trigger immediate kill */
|
|
27
|
+
criticalCategories: ThreatCategory[];
|
|
28
|
+
}
|
|
29
|
+
export interface RuntimeEvent {
|
|
30
|
+
timestamp: string;
|
|
31
|
+
type: 'STDOUT' | 'STDERR' | 'THREAT_DETECTED' | 'RESOURCE_LIMIT' | 'KILL_SWITCH' | 'ANOMALY' | 'EXIT';
|
|
32
|
+
severity: SeverityLevel;
|
|
33
|
+
details: string;
|
|
34
|
+
data?: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface MonitorReport {
|
|
37
|
+
startTime: string;
|
|
38
|
+
endTime?: string;
|
|
39
|
+
durationMs: number;
|
|
40
|
+
events: RuntimeEvent[];
|
|
41
|
+
threatsDetected: number;
|
|
42
|
+
killed: boolean;
|
|
43
|
+
killReason?: string;
|
|
44
|
+
resourceUsage: {
|
|
45
|
+
peakMemoryMB: number;
|
|
46
|
+
totalOutputBytes: number;
|
|
47
|
+
cpuTimeMs: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare class RuntimeMonitor {
|
|
51
|
+
private policy;
|
|
52
|
+
private events;
|
|
53
|
+
private startTime;
|
|
54
|
+
private outputBytes;
|
|
55
|
+
private threatsDetected;
|
|
56
|
+
private killed;
|
|
57
|
+
private killReason?;
|
|
58
|
+
private process?;
|
|
59
|
+
private killTimer?;
|
|
60
|
+
private memoryCheckInterval?;
|
|
61
|
+
/** Subset of patterns optimized for real-time output scanning */
|
|
62
|
+
private runtimePatterns;
|
|
63
|
+
constructor(policy: MonitorPolicy);
|
|
64
|
+
/**
|
|
65
|
+
* Attach the monitor to a running child process.
|
|
66
|
+
*/
|
|
67
|
+
attach(childProcess: ChildProcess): void;
|
|
68
|
+
/**
|
|
69
|
+
* Process output from the skill and check for threats.
|
|
70
|
+
*/
|
|
71
|
+
private onOutput;
|
|
72
|
+
/**
|
|
73
|
+
* Scan skill output for threat patterns in real-time.
|
|
74
|
+
* This catches skills that generate malicious output (e.g., writing
|
|
75
|
+
* shell commands to stdout that another tool might execute).
|
|
76
|
+
*/
|
|
77
|
+
private scanOutput;
|
|
78
|
+
/**
|
|
79
|
+
* Check process memory usage.
|
|
80
|
+
*/
|
|
81
|
+
private checkMemory;
|
|
82
|
+
/**
|
|
83
|
+
* Kill the child process — the kill switch.
|
|
84
|
+
*/
|
|
85
|
+
killProcess(reason: string, details: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Clean up timers and intervals.
|
|
88
|
+
*/
|
|
89
|
+
private cleanup;
|
|
90
|
+
/**
|
|
91
|
+
* Compare severity levels. Returns positive if a >= b.
|
|
92
|
+
*/
|
|
93
|
+
private compareSeverity;
|
|
94
|
+
private recordEvent;
|
|
95
|
+
/**
|
|
96
|
+
* Generate the final monitoring report.
|
|
97
|
+
*/
|
|
98
|
+
getReport(): MonitorReport;
|
|
99
|
+
isKilled(): boolean;
|
|
100
|
+
getEventCount(): number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Default monitor policy — strict but reasonable for developer use.
|
|
104
|
+
*/
|
|
105
|
+
export declare function getDefaultMonitorPolicy(): MonitorPolicy;
|
|
106
|
+
//# sourceMappingURL=runtime-mon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AC;QACzB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAe;IAC/B,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,OAAO,CAAC,mBAAmB,CAAC,CAAiB;IAE7C,iEAAiE;IACjE,OAAO,CAAC,eAAe,CAAqB;gBAEhC,MAAM,EAAE,aAAa;IAQjC;;OAEG;IACH,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAyCxC;;OAEG;IACH,OAAO,CAAC,QAAQ;IAahB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IA+ClB;;OAEG;IACH,OAAO,CAAC,WAAW;IAmBnB;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IA0BlD;;OAEG;IACH,OAAO,CAAC,OAAO;IAWf;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,SAAS,IAAI,aAAa;IAkB1B,QAAQ,IAAI,OAAO;IAInB,aAAa,IAAI,MAAM;CAGxB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,aAAa,CAevD"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SkillShield — Runtime Monitor + Kill Switch
|
|
3
|
+
*
|
|
4
|
+
* Real-time monitoring of skill execution. Watches stdout/stderr
|
|
5
|
+
* for threat patterns, tracks resource consumption, and kills the
|
|
6
|
+
* process if anomalies are detected.
|
|
7
|
+
*
|
|
8
|
+
* This is the core differentiator: Snyk scans before install,
|
|
9
|
+
* SkillShield watches DURING execution.
|
|
10
|
+
*/
|
|
11
|
+
import { MALICIOUS_PATTERNS } from '../guard/patterns.js';
|
|
12
|
+
export class RuntimeMonitor {
|
|
13
|
+
constructor(policy) {
|
|
14
|
+
this.events = [];
|
|
15
|
+
this.startTime = 0;
|
|
16
|
+
this.outputBytes = 0;
|
|
17
|
+
this.threatsDetected = 0;
|
|
18
|
+
this.killed = false;
|
|
19
|
+
this.policy = policy;
|
|
20
|
+
// Select high-severity patterns for real-time scanning (keep it fast)
|
|
21
|
+
this.runtimePatterns = MALICIOUS_PATTERNS.filter((p) => p.severity === 'CRITICAL' || p.severity === 'HIGH');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Attach the monitor to a running child process.
|
|
25
|
+
*/
|
|
26
|
+
attach(childProcess) {
|
|
27
|
+
this.process = childProcess;
|
|
28
|
+
this.startTime = Date.now();
|
|
29
|
+
this.killed = false;
|
|
30
|
+
// Start the kill timer (max execution time)
|
|
31
|
+
this.killTimer = setTimeout(() => {
|
|
32
|
+
this.killProcess('TIMEOUT', `Execution exceeded ${this.policy.maxExecutionTime}ms limit`);
|
|
33
|
+
}, this.policy.maxExecutionTime);
|
|
34
|
+
// Monitor stdout
|
|
35
|
+
childProcess.stdout?.on('data', (data) => {
|
|
36
|
+
const text = data.toString();
|
|
37
|
+
this.outputBytes += data.length;
|
|
38
|
+
this.onOutput('STDOUT', text);
|
|
39
|
+
});
|
|
40
|
+
// Monitor stderr
|
|
41
|
+
childProcess.stderr?.on('data', (data) => {
|
|
42
|
+
const text = data.toString();
|
|
43
|
+
this.outputBytes += data.length;
|
|
44
|
+
this.onOutput('STDERR', text);
|
|
45
|
+
});
|
|
46
|
+
// Monitor exit
|
|
47
|
+
childProcess.on('exit', (code, signal) => {
|
|
48
|
+
this.recordEvent({
|
|
49
|
+
type: 'EXIT',
|
|
50
|
+
severity: 'LOW',
|
|
51
|
+
details: `Process exited with code ${code}, signal ${signal}`,
|
|
52
|
+
data: { code, signal },
|
|
53
|
+
});
|
|
54
|
+
this.cleanup();
|
|
55
|
+
});
|
|
56
|
+
// Memory monitoring (check every 2 seconds)
|
|
57
|
+
this.memoryCheckInterval = setInterval(() => {
|
|
58
|
+
this.checkMemory();
|
|
59
|
+
}, 2000);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Process output from the skill and check for threats.
|
|
63
|
+
*/
|
|
64
|
+
onOutput(stream, text) {
|
|
65
|
+
// Check output size
|
|
66
|
+
if (this.outputBytes > this.policy.maxOutputBytes) {
|
|
67
|
+
this.killProcess('OUTPUT_FLOOD', `Output exceeded ${this.policy.maxOutputBytes} bytes — possible output flooding attack`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Real-time threat scanning on output
|
|
71
|
+
if (this.policy.enableOutputScanning) {
|
|
72
|
+
this.scanOutput(text, stream);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Scan skill output for threat patterns in real-time.
|
|
77
|
+
* This catches skills that generate malicious output (e.g., writing
|
|
78
|
+
* shell commands to stdout that another tool might execute).
|
|
79
|
+
*/
|
|
80
|
+
scanOutput(text, stream) {
|
|
81
|
+
for (const pattern of this.runtimePatterns) {
|
|
82
|
+
// Reset regex state for global patterns
|
|
83
|
+
pattern.pattern.lastIndex = 0;
|
|
84
|
+
const match = pattern.pattern.exec(text);
|
|
85
|
+
if (match) {
|
|
86
|
+
this.threatsDetected++;
|
|
87
|
+
this.recordEvent({
|
|
88
|
+
type: 'THREAT_DETECTED',
|
|
89
|
+
severity: pattern.severity,
|
|
90
|
+
details: `[${stream}] ${pattern.description} — Evidence: "${match[0].substring(0, 100)}"`,
|
|
91
|
+
data: {
|
|
92
|
+
patternId: pattern.id,
|
|
93
|
+
category: pattern.category,
|
|
94
|
+
evidence: match[0].substring(0, 200),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
// Kill immediately if critical category
|
|
98
|
+
if (this.policy.criticalCategories.includes(pattern.category)) {
|
|
99
|
+
this.killProcess('CRITICAL_THREAT', `Critical threat detected in output: ${pattern.category} — ${pattern.description}`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Kill if severity exceeds threshold
|
|
103
|
+
if (this.compareSeverity(pattern.severity, this.policy.killOnSeverity) >= 0) {
|
|
104
|
+
this.killProcess('SEVERITY_THRESHOLD', `Threat severity ${pattern.severity} exceeds kill threshold ${this.policy.killOnSeverity}`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Kill if too many violations
|
|
108
|
+
if (this.threatsDetected >= this.policy.maxViolations) {
|
|
109
|
+
this.killProcess('MAX_VIOLATIONS', `${this.threatsDetected} violations detected (limit: ${this.policy.maxViolations})`);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check process memory usage.
|
|
117
|
+
*/
|
|
118
|
+
checkMemory() {
|
|
119
|
+
if (!this.process || !this.process.pid)
|
|
120
|
+
return;
|
|
121
|
+
try {
|
|
122
|
+
// Use process.memoryUsage() for the parent — child memory is harder
|
|
123
|
+
// For child process, we estimate from output + known overhead
|
|
124
|
+
const memUsage = process.memoryUsage();
|
|
125
|
+
const heapMB = Math.round(memUsage.heapUsed / 1024 / 1024);
|
|
126
|
+
if (heapMB > this.policy.maxMemoryMB) {
|
|
127
|
+
this.killProcess('MEMORY_LIMIT', `Memory usage ${heapMB}MB exceeds limit ${this.policy.maxMemoryMB}MB`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
// Ignore memory check errors
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Kill the child process — the kill switch.
|
|
136
|
+
*/
|
|
137
|
+
killProcess(reason, details) {
|
|
138
|
+
if (this.killed)
|
|
139
|
+
return;
|
|
140
|
+
this.killed = true;
|
|
141
|
+
this.killReason = `${reason}: ${details}`;
|
|
142
|
+
this.recordEvent({
|
|
143
|
+
type: 'KILL_SWITCH',
|
|
144
|
+
severity: 'CRITICAL',
|
|
145
|
+
details: `🛑 KILL SWITCH ACTIVATED — ${reason}: ${details}`,
|
|
146
|
+
});
|
|
147
|
+
if (this.process && !this.process.killed) {
|
|
148
|
+
// First try SIGTERM for graceful shutdown
|
|
149
|
+
this.process.kill('SIGTERM');
|
|
150
|
+
// Force kill after 3 seconds if still running
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
if (this.process && !this.process.killed) {
|
|
153
|
+
this.process.kill('SIGKILL');
|
|
154
|
+
}
|
|
155
|
+
}, 3000);
|
|
156
|
+
}
|
|
157
|
+
this.cleanup();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Clean up timers and intervals.
|
|
161
|
+
*/
|
|
162
|
+
cleanup() {
|
|
163
|
+
if (this.killTimer) {
|
|
164
|
+
clearTimeout(this.killTimer);
|
|
165
|
+
this.killTimer = undefined;
|
|
166
|
+
}
|
|
167
|
+
if (this.memoryCheckInterval) {
|
|
168
|
+
clearInterval(this.memoryCheckInterval);
|
|
169
|
+
this.memoryCheckInterval = undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Compare severity levels. Returns positive if a >= b.
|
|
174
|
+
*/
|
|
175
|
+
compareSeverity(a, b) {
|
|
176
|
+
const order = {
|
|
177
|
+
CRITICAL: 4,
|
|
178
|
+
HIGH: 3,
|
|
179
|
+
MEDIUM: 2,
|
|
180
|
+
LOW: 1,
|
|
181
|
+
};
|
|
182
|
+
return order[a] - order[b];
|
|
183
|
+
}
|
|
184
|
+
recordEvent(partial) {
|
|
185
|
+
this.events.push({ ...partial, timestamp: new Date().toISOString() });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Generate the final monitoring report.
|
|
189
|
+
*/
|
|
190
|
+
getReport() {
|
|
191
|
+
const endTime = Date.now();
|
|
192
|
+
return {
|
|
193
|
+
startTime: new Date(this.startTime).toISOString(),
|
|
194
|
+
endTime: new Date(endTime).toISOString(),
|
|
195
|
+
durationMs: endTime - this.startTime,
|
|
196
|
+
events: [...this.events],
|
|
197
|
+
threatsDetected: this.threatsDetected,
|
|
198
|
+
killed: this.killed,
|
|
199
|
+
killReason: this.killReason,
|
|
200
|
+
resourceUsage: {
|
|
201
|
+
peakMemoryMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024),
|
|
202
|
+
totalOutputBytes: this.outputBytes,
|
|
203
|
+
cpuTimeMs: endTime - this.startTime,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
isKilled() {
|
|
208
|
+
return this.killed;
|
|
209
|
+
}
|
|
210
|
+
getEventCount() {
|
|
211
|
+
return this.events.length;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Default monitor policy — strict but reasonable for developer use.
|
|
216
|
+
*/
|
|
217
|
+
export function getDefaultMonitorPolicy() {
|
|
218
|
+
return {
|
|
219
|
+
maxExecutionTime: 60000, // 60 seconds
|
|
220
|
+
maxMemoryMB: 512, // 512MB
|
|
221
|
+
maxOutputBytes: 10 * 1024 * 1024, // 10MB output
|
|
222
|
+
killOnSeverity: 'CRITICAL',
|
|
223
|
+
enableOutputScanning: true,
|
|
224
|
+
maxViolations: 5,
|
|
225
|
+
criticalCategories: [
|
|
226
|
+
'MEMORY_POISONING',
|
|
227
|
+
'CREDENTIAL_THEFT',
|
|
228
|
+
'MALWARE',
|
|
229
|
+
'DATA_EXFILTRATION',
|
|
230
|
+
],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=runtime-monitor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-monitor.js","sourceRoot":"","sources":["../../src/shield/runtime-monitor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO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6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skillshield",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Runtime security for AI Agent Skills — Scan, sandbox & enforce. Detect prompt injection, memory poisoning, supply chain attacks. 72+ patterns, 14 categories. The firewall Snyk and Cisco don't build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|