agentshield-sdk 13.5.0 → 14.2.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/CHANGELOG.md CHANGED
@@ -4,6 +4,198 @@ All notable changes to Agent Shield will be documented in this file.
4
4
 
5
5
  This project follows [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [14.2.0] - 2026-05-11
8
+
9
+ ### May 2026 Threat Response + Performance + DX
10
+
11
+ Response to threats disclosed between April 25 and May 11, 2026.
12
+
13
+ #### New Detection Patterns (4 patterns, 303 → 307)
14
+
15
+ - **TrustFall malicious project files** (2 patterns) — Adversa AI disclosed May 2026: malicious `.claude/`, `.cursor/`, `.windsurf/` config files with auto-execution hooks (`preCommand`, `onStart`, etc.) trigger one-keypress compromise of AI coding agents and exfiltrate CI env vars
16
+ - **Semantic Kernel RCE** — Microsoft Semantic Kernel (CVE-2026-25592 / CVE-2026-26030, disclosed May 7) allows prompt injection to invoke arbitrary kernel functions and achieve RCE on the host process
17
+ - **WebSocket cross-origin hijacking** — CVE-2026-44211 (Cline Kanban) and CVE-2026-32173 (Azure SRE Agent CVSS 8.6): WebSockets without origin validation let attackers inject prompts into running agent terminals
18
+
19
+ #### CVE Registry Expansion (33 → 44 CVEs)
20
+
21
+ - CVE-2026-25592 / CVE-2026-26030: Microsoft Semantic Kernel RCE (May 7)
22
+ - CVE-2026-42302: FastGPT agent-sandbox unauth RCE (CVSS 9.8, May 8)
23
+ - CVE-2026-44284: FastGPT MCP SSRF
24
+ - CVE-2026-42344: FastGPT DNS rebinding bypass
25
+ - CVE-2026-44211: Cline Kanban WebSocket Hijacking
26
+ - CVE-2026-32173: Azure SRE Agent unauth WebSocket (CVSS 8.6)
27
+ - CVE-2026-44400-403: 4× CrewAI Code Interpreter chain RCE/SSRF/file-read
28
+
29
+ #### Performance: LRU Cache (151x speedup on warm cache)
30
+
31
+ - Added 1000-entry LRU cache to `scanText()` keyed on `(source, sensitivity, text)`
32
+ - Cached scans complete in ~1μs vs ~190μs cold (151x speedup on short malicious inputs, 90x on benign)
33
+ - Eliminates duplicate work in RAG pipelines, batch processors, and middleware retry loops
34
+ - Inputs >2048 chars bypass the cache to avoid memory bloat
35
+ - Opt-out via `scanText(text, { useCache: false })`
36
+ - Result object includes `fromCache: true` when served from cache
37
+
38
+ #### Developer Experience
39
+
40
+ - New examples for the platforms developers actually deploy to in 2026:
41
+ - `examples/cloudflare-workers-ai.js` — Workers AI guardrail with input + output scanning
42
+ - `examples/nextjs-edge-middleware.js` — Next.js Edge middleware for `/api/chat/*` and `/api/agent/*` routes
43
+ - `examples/vercel-ai-sdk-guardrail.js` — Vercel AI SDK streaming chat guardrail
44
+ - All examples are self-contained and ready to copy-paste into a real app
45
+
46
+ #### Test Coverage
47
+
48
+ - New `test/test-v14.2-patterns.js` — 32 assertions covering LRU cache correctness, all 4 new patterns, all 11 new CVE entries, and 6 false-positive regression samples
49
+ - Total project assertions: ~3,200+ across all suites; v14.2 specific: 32
50
+
51
+ #### Known Limitations Documented
52
+
53
+ - Rust NAPI native scanner (`src/native-scanner.js`) is loaded but NOT wired into the JS hot path. Investigation revealed the Rust core has only 141 patterns vs JS's 307, so wiring it in blindly would silently lose 166 patterns of coverage. Use of the native scanner is gated on a future pattern-sync effort.
54
+
55
+ ## [14.1.0] - 2026-04-24
56
+
57
+ ### April 2026 Threat Response — Comment-and-Control, MCP CVE Wave, OAuth Supply Chain
58
+
59
+ Rapid security update responding to this week's active attacks: Vercel/Context.ai OAuth supply chain breach, "Comment and Control" zero-click credential theft from AI coding agents, 7 new MCP CVEs, Unit 42 MCP sampling attacks, and malicious LLM API routers.
60
+
61
+ #### New Detection Patterns (13 patterns, 290 → 303)
62
+
63
+ - **CI/CD Agent Injection** (`cicd_injection`) — detects prompt injection targeting AI coding agents via PR titles, issue comments, and review comments. Defends against the "Comment and Control" attack (April 2026) that exfiltrated credentials from Claude Code, Gemini CLI, and GitHub Copilot
64
+ - **Credential Exfiltration** (`credential_exfiltration`) — detects `/proc/[pid]/environ` reads (Copilot bypass technique), API key patterns in agent output (OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.), and OAuth/bearer token exfiltration with provider-specific prefixes (ya29, ghp_, sk-, xox-, AKIA)
65
+ - **OAuth Flow Manipulation** (`credential_exfiltration`) — detects grant_type/redirect_uri/client_secret manipulation targeting token theft, inspired by the Vercel/Context.ai supply chain breach
66
+ - **MCP Sampling Injection** (`mcp_sampling_injection`) — detects hidden instructions injected via MCP sampling/createMessage requests (Unit 42 research, April 2026)
67
+ - **LLM Router Tampering** (`llm_router_tampering`) — detects OPENAI_BASE_URL/ANTHROPIC_BASE_URL overrides pointing to untrusted endpoints (arXiv 2604.08407: 9 of 28 paid routers actively malicious)
68
+ - **MCP STDIO Command Injection** (`mcp_command_injection`) — detects `npx -c` command injection via MCP STDIO transport (CVE-2026-30623, 200K+ servers affected)
69
+
70
+ #### CVE Registry Update (26 → 33 CVEs)
71
+
72
+ - CVE-2026-40933: Flowise MCP Adapters RCE (CVSS 9.9)
73
+ - CVE-2026-41264: Flowise CSV Agent prompt injection to RCE
74
+ - CVE-2026-33626: LMDeploy SSRF (exploited within 12 hours of disclosure)
75
+ - CVE-2026-33032: nginx-ui MCP auth bypass (CVSS 9.8, actively exploited)
76
+ - CVE-2026-20205: Splunk MCP Server cleartext token logging (CVSS 7.2)
77
+ - CVE-2026-33946: MCP Ruby SDK session fixation
78
+ - CVE-2026-5603: magento2-dev-mcp command injection
79
+
80
+ #### MCPGuard Security Hardening
81
+
82
+ - **Tool name squatting detection** — `registerServer()` now detects and warns when a new MCP server registers a tool name already owned by another server (MCPShield arXiv:2604.05969 "Server Spoofing" vector)
83
+ - **Context flooding defense** — `interceptToolOutput()` flags tool outputs exceeding `maxToolOutputSize` (default 100KB) to prevent context window exhaustion attacks
84
+ - **Recursive tool invocation depth limit** — blocks tool call chains exceeding `maxCallDepth` (default 5) to prevent reentrancy attacks and unbounded recursive loops
85
+
86
+ #### Supply Chain Scanner Enhancements
87
+
88
+ - **Consent phishing detection** — flags tools whose description implies read-only but whose schema contains write/network parameters (OWASP ASI09 Human-Agent Trust Exploitation)
89
+
90
+ #### Integration Updates
91
+
92
+ - `shieldGoogleADKJS()` — new wrapper for Google ADK TypeScript/JavaScript SDK (GA April 2026)
93
+ - GPT-5.5 model risk profile added to MCP Guard (critical susceptibility, elevated sandbox escape surface)
94
+
95
+ #### Test Coverage Expansion (+416 assertions)
96
+
97
+ - `test-v14.1-patterns.js` — 61 assertions: all 5 new categories, 12 FP guards, ADK-JS integration, CVE registry
98
+ - `test-pattern-categories.js` — 66 assertions: detection test for every 51 pattern categories + 15 benign guards
99
+ - `test-supply-chain-cves.js` — 228 assertions: all 33 CVEs, 9 blocklist entries, injection/SSRF/poisoning patterns, consent phishing, SARIF/Markdown output
100
+ - Total new assertions this release: 355
101
+
102
+ ## [14.0.0] - 2026-04-16
103
+
104
+ ### Major Release — Platform Parity + Framework Integrations
105
+
106
+ Agent Shield v14 closes the gap with Microsoft's Agent Governance Toolkit while maintaining our zero-dependency, local-first architecture.
107
+
108
+ #### OpenAI Agents SDK Integration (April 2026 Release)
109
+
110
+ - `shieldOpenAIAgent()` — drop-in guardrails for `@openai/agents` (Node) and `openai-agents` (Python)
111
+ - Input, output, and tool guardrails that work with the SDK's native Guardrail primitive
112
+ - Handles all OpenAI SDK input shapes: string, message array, content parts
113
+ - Node: 34 integration tests. Python: 15 integration tests.
114
+ - Example at `examples/openai-agents-sdk.js`
115
+
116
+ #### Framework Parity (CrewAI, Google ADK, MS Agent Framework)
117
+
118
+ - `shieldCrewAI()` — task-level input/output scanning for CrewAI workflows
119
+ - `shieldGoogleADK()` — tool call, tool result, and generation prompt scanning for Google ADK
120
+ - `shieldMSAgentFramework()` — async middleware for Microsoft Agent Framework pipeline
121
+ - 36 integration tests across all three frameworks
122
+
123
+ #### Rust Core NAPI Binding
124
+
125
+ - Native Rust scanner bridge (`src/native-scanner.js`) loads compiled NAPI module when available
126
+ - Falls back silently to pure-JS scanner when not compiled
127
+ - Build: `cd rust-core && cargo build --release --features node`
128
+ - `scanText`, `scanBatch`, `getPatterns` exposed via NAPI-RS
129
+
130
+ #### Python + Go SDK Pattern Sync
131
+
132
+ - Python SDK: 141 → 179 patterns (+38), 10 new categories
133
+ - Go SDK: 141 → 179 patterns (+38), 10 new categories
134
+ - All v13.4-v13.6 patterns ported: XSS, SVG, encoding chain, steganographic, mcp.json, offensive agent, cloud IAM, structured data, memory poisoning, prompt extraction
135
+
136
+ #### Plugin VM Sandbox + Signature Verification
137
+
138
+ - `IsolatedPluginSandbox` — real `vm` module isolation, not just error catching
139
+ - Plugins cannot access `process`, `fs`, `net`, `child_process`, `require`
140
+ - Preemptive timeout via `vm.Script` (kills infinite loops)
141
+ - Prototype pollution contained (realm-isolated built-ins)
142
+ - `PluginVerifier` with HMAC-SHA256 signature validation
143
+ - `PluginManifest` schema validation with capability declarations
144
+ - 58 sandbox tests passing
145
+
146
+ #### Performance
147
+
148
+ - Long benign fast path: 15.7ms → 112μs p99 (140x faster) via attack-indicator prefilter
149
+ - Honest latency benchmark at `benchmark/latency-honest.js` with p50/p95/p99/p99.9
150
+ - ReDoS audit: 0 risky patterns across all detectors (all <0.4ms worst case)
151
+ - Pattern quality audit: 120 active / 177 defensive patterns, 0 false positives
152
+
153
+ #### Security Hardening
154
+
155
+ - Express middleware: 1MB default body-size limit
156
+ - Multi-tenant: `tenantVerifier` + `strictAuth` options, `withAuth()` helper
157
+ - Microsoft Agent Governance Toolkit parity audit at `research/ms-agent-toolkit-parity.md`
158
+
159
+ #### Developer Experience
160
+
161
+ - `GETTING_STARTED.md` — 5-minute path from install to protected agent
162
+ - All framework examples in one place: Anthropic, OpenAI, OpenAI Agents SDK, LangChain, Express, MCP, CrewAI, Google ADK, MS Agent Framework
163
+
164
+ ## [13.6.0] - 2026-04-16
165
+
166
+ ### Performance Leap + Security Hardening
167
+
168
+ Path A polish pass — close security scan gaps, honest performance work, real audits.
169
+
170
+ #### Performance
171
+
172
+ - **Fast path for long clean text**: 15.7ms p99 → **112μs p99** on 5KB benign documents. 140x speedup.
173
+ - Added `PRIMARY_ATTACK_INDICATORS` prefilter — a single cheap regex matching only attack-specific phrases (not common English like "eval" or "token").
174
+ - If text is long, contains no attack phrases, no non-ASCII, and no obfuscation chars → skip the full pattern + normalization pipeline.
175
+ - Zero recall loss: full red team (617 attacks) still 100%, shield score still 100/100.
176
+ - **Honest latency benchmark** (`benchmark/latency-honest.js`): real p50/p95/p99/p99.9/max numbers instead of averages.
177
+ - Best-case p99: 112μs
178
+ - Mean p99: 1.18ms
179
+ - Worst-case p99: 3.62ms (long malicious — full pattern set runs)
180
+ - Microsoft Agent Governance Toolkit claims <0.1ms p99. We're 36.2x that in worst case, faster on short inputs.
181
+
182
+ #### Security
183
+
184
+ - **Plugin VM sandbox** (`IsolatedPluginSandbox`): real isolation using Node `vm` module.
185
+ - Blocks `process`, `require` (whitelisted only), `fs`/`net`/`http`/`child_process`, `new Function()`.
186
+ - Prototype pollution contained — each sandbox has realm-isolated built-ins.
187
+ - Preemptive timeout via `vm.Script` (kills infinite loops).
188
+ - HMAC-SHA256 plugin signing + `PluginVerifier` + `PluginManifest` schema validation.
189
+ - 58 new tests covering sandbox escape attempts, signature verification, manifest validation.
190
+ - **Express middleware body-size limits**: `options.maxBodySize` (1MB default) with raw-stream enforcement.
191
+ - **Multi-tenant auth validation**: `options.tenantVerifier` + `options.strictAuth` + `withAuth()` helper.
192
+
193
+ #### Quality & Parity
194
+
195
+ - **ReDoS audit**: every pattern tested against adversarial inputs. **0 risky patterns** — worst case 0.4ms per pattern evaluation.
196
+ - **Pattern quality audit**: 120 active patterns doing the work, 177 dead patterns (defensive, never false-positive on benchmark corpus).
197
+ - Python SDK (282 patterns) and Go SDK (141 patterns) pattern-sync deferred to v14.
198
+
7
199
  ## [13.5.0] - 2026-04-16
8
200
 
9
201
  ### Detection Hardening + Security Scan Remediation
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Agent Shield
2
2
 
3
- [![npm](https://img.shields.io/badge/npm-v13.5.0-blue)](https://www.npmjs.com/package/agentshield-sdk)
3
+ [![npm](https://img.shields.io/badge/npm-v14.0.0-blue)](https://www.npmjs.com/package/agentshield-sdk)
4
4
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
5
5
  [![dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](#)
6
6
  [![node](https://img.shields.io/badge/node-%3E%3D16-blue)](#)
@@ -75,6 +75,17 @@ const client = shieldAnthropicClient(new Anthropic(), { blockOnThreat: true });
75
75
  const { shieldOpenAIClient } = require('agentshield-sdk');
76
76
  const client = shieldOpenAIClient(new OpenAI(), { blockOnThreat: true });
77
77
 
78
+ // OpenAI Agents SDK (@openai/agents, April 2026)
79
+ const { Agent, run } = require('@openai/agents');
80
+ const { shieldOpenAIAgent } = require('agentshield-sdk');
81
+ const { inputGuardrail, outputGuardrail, toolGuardrail } = shieldOpenAIAgent({ blockOnThreat: true });
82
+ const agent = new Agent({
83
+ name: 'Assistant',
84
+ instructions: 'You are a helpful assistant',
85
+ inputGuardrails: [inputGuardrail],
86
+ outputGuardrails: [outputGuardrail]
87
+ });
88
+
78
89
  // LangChain
79
90
  const { ShieldCallbackHandler } = require('agentshield-sdk');
80
91
  const chain = new LLMChain({ llm, prompt, callbacks: [new ShieldCallbackHandler()] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentshield-sdk",
3
- "version": "13.5.0",
3
+ "version": "14.2.0",
4
4
  "description": "SOTA AI agent security SDK. F1 1.000 on BIPIA/HackAPrompt/MCPTox/Multilingual benchmarks. 400+ exports, 100+ modules. Zero dependencies, runs locally.",
5
5
  "main": "src/main.js",
6
6
  "types": "types/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "sideEffects": false,
34
34
  "scripts": {
35
- "test": "node test/test.js && node test/test-modules.js && node test/test-new-features.js && node test/test-mcp-guard.js && node test/test-supply-chain-scanner.js && node test/test-owasp-agentic.js && node test/test-redteam-cli.js && node test/test-drift-monitor.js && node test/test-micro-model.js && node test/test-level5.js && node test/test-sota.js && node test/test-cross-turn.js && node test/test-v12.js && node test/test-traps.js && node test/test-deepmind.js && node test/test-render-differential.js && node test/test-sybil.js && node test/test-side-channel.js",
35
+ "test": "node test/test.js && node test/test-modules.js && node test/test-new-features.js && node test/test-mcp-guard.js && node test/test-supply-chain-scanner.js && node test/test-owasp-agentic.js && node test/test-redteam-cli.js && node test/test-drift-monitor.js && node test/test-micro-model.js && node test/test-level5.js && node test/test-sota.js && node test/test-cross-turn.js && node test/test-v12.js && node test/test-traps.js && node test/test-deepmind.js && node test/test-render-differential.js && node test/test-sybil.js && node test/test-side-channel.js && node test/test-plugin-sandbox.js && node test/test-openai-agents-sdk.js && node test/test-framework-integrations.js",
36
36
  "test:new-products": "node test/test-mcp-guard.js && node test/test-supply-chain-scanner.js && node test/test-owasp-agentic.js && node test/test-redteam-cli.js && node test/test-drift-monitor.js && node test/test-micro-model.js",
37
37
  "test:all": "node test/test-all-40-features.js",
38
38
  "test:mcp": "node test/test-mcp-security.js",