@mcp-guardian/server 1.3.3 → 1.3.5
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/README.md +26 -8
- package/SECURITY.md +131 -0
- package/default-policy.yaml +53 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
[](https://github.com/rudraneel93/mcp-guardian/actions/workflows/ci.yml)
|
|
11
11
|
|
|
12
|
-
> **Always use the latest version:** `npm install @mcp-guardian/server@latest` — current is **v1.3.
|
|
12
|
+
> **Always use the latest version:** `npm install @mcp-guardian/server@latest` — current is **v1.3.3**. See the [Changelog](./CHANGELOG.md) for full version history and [GitHub Releases](https://github.com/rudraneel93/mcp-guardian/releases) for per-version source tags.
|
|
13
13
|
|
|
14
14
|
MCP Guardian is a **security and governance proxy** for [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) infrastructure. It sits between AI clients and MCP servers, enforcing active security policies, tracking real token costs, and monitoring health — all while providing enterprise-grade observability and audit trails.
|
|
15
15
|
|
|
@@ -77,6 +77,14 @@ MCP Guardian provides:
|
|
|
77
77
|
- **DPoP (v1.0)** — RFC 9449 sender-constrained token support for replay-proof authentication
|
|
78
78
|
- **OpenTelemetry (v1.0)** — Distributed tracing across proxy and MCP servers via OTLP
|
|
79
79
|
- **HTTP/SSE proxy (v0.8.0)** — Full proxy support for remote HTTP/SSE-based MCP servers
|
|
80
|
+
- **Payload normalization (v1.2.0)** — Multi-stage decoder defeats URL/hex/unicode/HTML entity/shell obfuscation bypass attacks before regex evaluation
|
|
81
|
+
- **Semantic shell analysis (v1.2.0)** — AST-based tokenization detects command substitution, pipe chains, redirects, and 33 dangerous commands semantically
|
|
82
|
+
- **Dashboard authentication (v1.2.0)** — JWT session tokens, API key auth, CSRF protection, and rate-limited login for the web dashboard
|
|
83
|
+
- **mTLS zero-trust networking (v1.3.0)** — Mutual TLS with client certificates for proxy ↔ upstream MCP server communication
|
|
84
|
+
- **E2E proxy tests (v1.3.0)** — Real proxy spawns with `default-policy.yaml`, sends JSON-RPC, verifies block/pass/deny
|
|
85
|
+
- **Supply chain CI (v1.3.0)** — GitHub Actions pipeline with `npm audit --audit-level=high`, CycloneDX SBOM generation, and `.npmrc` enforcement
|
|
86
|
+
- **Operational runbooks (v1.3.0)** — 7 production runbooks covering circuit breaker, Redis, policy corruption, dashboard auth, latency, DB corruption, and token spikes with SLOs
|
|
87
|
+
- **Disaster recovery plan (v1.3.0)** — RTO/RPO for all state types, backup strategy, recovery drills, and rollback procedures
|
|
80
88
|
|
|
81
89
|
---
|
|
82
90
|
|
|
@@ -817,12 +825,16 @@ Token counting uses `tiktoken` with the `o200k_base` encoding (used by GPT-4o an
|
|
|
817
825
|
- [x] Command injection validation (10 suspicious patterns)
|
|
818
826
|
- [x] Active policy engine — YAML-based pass/block/flag with allowlists, regex, rate limiting, token budgets
|
|
819
827
|
- [x] Structured JSON logging (pino) for SIEM ingestion
|
|
820
|
-
- [x] STRIDE threat model (SECURITY.md)
|
|
821
|
-
- [x]
|
|
822
|
-
- [x]
|
|
828
|
+
- [x] STRIDE threat model (SECURITY.md) + formal THREAT_MODEL.md
|
|
829
|
+
- [x] Payload normalization — multi-stage encode/decode bypass defense
|
|
830
|
+
- [x] Semantic shell AST analysis — command substitution, pipe, and dangerous command detection
|
|
831
|
+
- [x] Dashboard authentication — JWT sessions, API keys, CSRF protection
|
|
832
|
+
- [x] mTLS zero-trust networking for proxy ↔ upstream communication
|
|
833
|
+
- [x] 168 tests across 16 suites (unit, fuzz, integration, E2E)
|
|
834
|
+
- [x] GitHub Actions CI (Node 18/20/22 matrix) + supply chain audit
|
|
823
835
|
- [x] Performance benchmarks (p50: 5ms baseline, +25.78ms proxy overhead, +0.15ms policy)
|
|
824
836
|
- [x] Helm chart + production deployment guide (K8s, fail-open/closed, sidecar pattern, scaling)
|
|
825
|
-
- [x] Published to npm as [`@mcp-guardian/server@1.
|
|
837
|
+
- [x] Published to npm as [`@mcp-guardian/server@1.3.3`](https://www.npmjs.com/package/@mcp-guardian/server)
|
|
826
838
|
- [x] OAuth 2.1 / OIDC proxy authentication (v0.5.0)
|
|
827
839
|
- [x] RBAC — scope & client-ID-based access control (v0.5.1)
|
|
828
840
|
- [x] Circuit breaker — 3-state protection for upstream servers (v0.5.2)
|
|
@@ -838,10 +850,16 @@ Token counting uses `tiktoken` with the `o200k_base` encoding (used by GPT-4o an
|
|
|
838
850
|
- [x] DPoP support — RFC 9449 sender-constrained tokens (v1.0)
|
|
839
851
|
- [x] OpenTelemetry tracing — distributed request tracking (v1.0)
|
|
840
852
|
- [x] HTTP/SSE proxy server — remote MCP transport support (v0.8.0)
|
|
841
|
-
- [
|
|
853
|
+
- [x] E2E proxy tests — real CLI spawn with policy file (v1.3.0)
|
|
854
|
+
- [x] Supply chain CI — npm audit, CycloneDX SBOM, npm provenance (v1.3.0)
|
|
855
|
+
- [x] Operational runbooks — 7 scenarios with SLOs (v1.3.0)
|
|
856
|
+
- [x] Disaster recovery plan — RTO/RPO, backup strategy, recovery drills (v1.3.0)
|
|
857
|
+
- [x] GitHub primary language corrected to TypeScript (v1.3.3)
|
|
858
|
+
- [x] npm keywords expanded to 22 terms for discoverability (v1.3.3)
|
|
859
|
+
- [ ] OPA/Rego policy integration
|
|
842
860
|
- [ ] Slack/Discord alerting
|
|
843
|
-
- [ ] Prometheus metrics endpoint
|
|
844
861
|
- [ ] Multi-user proxy
|
|
862
|
+
- [ ] Hosted SaaS version
|
|
845
863
|
|
|
846
864
|
---
|
|
847
865
|
|
|
@@ -849,4 +867,4 @@ Token counting uses `tiktoken` with the `o200k_base` encoding (used by GPT-4o an
|
|
|
849
867
|
|
|
850
868
|
MIT — see [LICENSE](LICENSE) for details.
|
|
851
869
|
|
|
852
|
-
**Built with TypeScript, @modelcontextprotocol/sdk, tiktoken, sql.js, commander, chalk, and
|
|
870
|
+
**Built with TypeScript, @modelcontextprotocol/sdk, tiktoken, sql.js, commander, chalk, zod, jose, pino, and prom-client.**
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Threat Model (STRIDE per MCP Interaction)
|
|
4
|
+
|
|
5
|
+
MCP Guardian's security posture is modeled against the STRIDE framework for each MCP interaction vector.
|
|
6
|
+
|
|
7
|
+
### 1. Spoofing (Identity Forgery)
|
|
8
|
+
|
|
9
|
+
| Threat | Mitigation |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Typo-squatted MCP server packages | Typo-squat detector with Levenshtein distance against 24 known official packages |
|
|
12
|
+
| Fake MCP server responding to health probes | TLS certificate validation for SSE/HTTP transports |
|
|
13
|
+
| Malicious server impersonating a trusted tool | Command validation flags non-standard executables |
|
|
14
|
+
|
|
15
|
+
### 2. Tampering (Data/Command Injection)
|
|
16
|
+
|
|
17
|
+
| Threat | Mitigation |
|
|
18
|
+
|---|---|
|
|
19
|
+
| Shell injection via tool arguments | Active policy engine blocks patterns (rm -rf, shell chaining, backtick substitution) |
|
|
20
|
+
| Encoded payload bypasses (URL, hex, unicode, HTML entities) | PayloadNormalizer (v1.2) — multi-stage decode before regex evaluation |
|
|
21
|
+
| Shell obfuscation (ANSI-C quoting, quote splitting, backslash escapes) | ShellTokenizer (v1.2) — semantic AST analysis of command structure |
|
|
22
|
+
| Path traversal | Active policy engine blocks ../ patterns |
|
|
23
|
+
| Supply chain compromise of MCP server package | CVE checker queries OSV.dev and NVD for known vulnerabilities |
|
|
24
|
+
|
|
25
|
+
### 3. Repudiation (Deniability)
|
|
26
|
+
|
|
27
|
+
| Threat | Mitigation |
|
|
28
|
+
|---|---|
|
|
29
|
+
| No audit trail for blocked/allowed tool calls | Structured JSON logging (pino) captures every policy_decision |
|
|
30
|
+
| Policy changes without audit | PolicyAuditor (v1.0.1) records every policy change with hash verification |
|
|
31
|
+
| Denied access attempts not recorded | tool_blocked events logged at WARN level for SIEM alerting |
|
|
32
|
+
|
|
33
|
+
### 4. Information Disclosure (Secrets/Data Leakage)
|
|
34
|
+
|
|
35
|
+
| Threat | Mitigation |
|
|
36
|
+
|---|---|
|
|
37
|
+
| Hardcoded API keys, tokens, passwords in MCP config | Secret scanner (6 regex patterns) |
|
|
38
|
+
| Unauthenticated dashboard access | DashboardAuth (v1.2) — JWT sessions, API keys, CSRF protection, rate-limited login |
|
|
39
|
+
| Unencrypted transport | Auth prober flags unencrypted transports |
|
|
40
|
+
| Sensitive data in generated reports | Reports use config names, not raw secrets |
|
|
41
|
+
|
|
42
|
+
### 5. Denial of Service (Availability)
|
|
43
|
+
|
|
44
|
+
| Threat | Mitigation |
|
|
45
|
+
|---|---|
|
|
46
|
+
| Token bombs | Token budget rule (maxTokens) flags/blocks oversized calls |
|
|
47
|
+
| Tool overload (>15 tools) | Health monitor detects overload; --fail-on-overload CLI flag |
|
|
48
|
+
| Rate abuse | Rate limiting rule (maxCallsPerMinute) per server+tool |
|
|
49
|
+
| API ban on CVE lookup services | Token-bucket rate limiter on OSV.dev (5 req/min) and NVD (20 req/min with key) |
|
|
50
|
+
|
|
51
|
+
### 6. Elevation of Privilege (Agent Hijacking)
|
|
52
|
+
|
|
53
|
+
| Threat | Mitigation |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Confused deputy attack | Tool allowlist/denylist in policy engine; argument pattern blocking |
|
|
56
|
+
| Agent tricked into calling dangerous tools | Default policy denies execute_command, bash, sh, eval, exec |
|
|
57
|
+
| Missing authentication on MCP servers | OAuth 2.1/OIDC JWT validation with RBAC (scopes, client IDs) |
|
|
58
|
+
|
|
59
|
+
## Supported Versions
|
|
60
|
+
|
|
61
|
+
| Version | Status | Security Updates |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| 1.0.x | ✅ Current | All updates |
|
|
64
|
+
| 0.7.x | ✅ Supported | Critical only |
|
|
65
|
+
| <0.7.0 | ❌ Unsupported | None |
|
|
66
|
+
|
|
67
|
+
## Reporting a Vulnerability
|
|
68
|
+
|
|
69
|
+
**Do not open a public issue for security vulnerabilities.**
|
|
70
|
+
|
|
71
|
+
Email **rudraneel93@gmail.com** with:
|
|
72
|
+
- Description of the vulnerability
|
|
73
|
+
- Steps to reproduce
|
|
74
|
+
- Affected version(s)
|
|
75
|
+
- Any proof-of-concept or crash data
|
|
76
|
+
|
|
77
|
+
Response timeline:
|
|
78
|
+
- **24 hours:** Acknowledgement
|
|
79
|
+
- **72 hours:** Initial assessment
|
|
80
|
+
- **7 days:** Patch or mitigation plan
|
|
81
|
+
|
|
82
|
+
## Incident Response
|
|
83
|
+
|
|
84
|
+
### Severity Classification
|
|
85
|
+
|
|
86
|
+
| Level | Example | Response |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| **Critical** | RCE via proxy, auth bypass, secret leak | Patch within 24 hours, CVE disclosure |
|
|
89
|
+
| **High** | Policy bypass, DoS vulnerability | Patch within 72 hours |
|
|
90
|
+
| **Medium** | Information disclosure, limited impact | Patch in next release |
|
|
91
|
+
| **Low** | Minor configuration issues | Documented workaround |
|
|
92
|
+
|
|
93
|
+
### Emergency Patch Process
|
|
94
|
+
|
|
95
|
+
1. **Isolate:** If a vulnerability is confirmed, immediately document the affected versions and attack vector
|
|
96
|
+
2. **Mitigate:** Provide a temporary workaround (policy rule, config change) within 24 hours
|
|
97
|
+
3. **Patch:** Release a fix with full test coverage
|
|
98
|
+
4. **Disclose:** Publish advisory in GitHub Security Advisories and npm audit
|
|
99
|
+
|
|
100
|
+
### Dependency Supply Chain
|
|
101
|
+
|
|
102
|
+
- All dependencies are pinned via `package-lock.json`
|
|
103
|
+
- CI pipeline runs `npm audit` on every commit
|
|
104
|
+
- Critical dependencies (`@modelcontextprotocol/sdk`, `jose`, `pg`) are reviewed on each major version bump
|
|
105
|
+
- OTel gRPC exporter removed (v1.0.1) due to critical CVE in protobufjs dependency chain
|
|
106
|
+
|
|
107
|
+
## Security Design Principles
|
|
108
|
+
|
|
109
|
+
1. **Least Privilege:** The policy engine denies by default when configured with allowlists
|
|
110
|
+
2. **Defense in Depth:** Static scanning (config audit) + runtime enforcement (proxy policy) + SIEM logging
|
|
111
|
+
3. **Fail Secure:** Graceful shutdown flushes DB before exit; blocked calls return explicit errors
|
|
112
|
+
4. **Auditability:** Every policy decision, block, and proxy event is logged as structured JSON. Policy changes are recorded via PolicyAuditor
|
|
113
|
+
5. **Zero Trust on Input:** All tool arguments are pattern-checked regardless of source
|
|
114
|
+
|
|
115
|
+
## Dependencies
|
|
116
|
+
|
|
117
|
+
MCP Guardian requires these critical dependencies:
|
|
118
|
+
|
|
119
|
+
| Dependency | Purpose | Security Notes |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `@modelcontextprotocol/sdk` | MCP protocol implementation | Keep updated to latest; CVE monitoring |
|
|
122
|
+
| `tiktoken` | Token counting (o200k_base encoding) | Pure JS, no native bindings |
|
|
123
|
+
| `sql.js` | SQLite storage | WASM-based, no native compilation |
|
|
124
|
+
| `pino` | Structured logging | High-performance JSON logger |
|
|
125
|
+
| `js-yaml` | YAML policy parsing | Policy files only |
|
|
126
|
+
| `jose` | JWT/JWK validation | OAuth 2.1/OIDC support |
|
|
127
|
+
| `ioredis` | Redis client | Session cache and rate limit store |
|
|
128
|
+
| `pg` | PostgreSQL client | Production DB backend |
|
|
129
|
+
| `prom-client` | Prometheus metrics | Monitoring |
|
|
130
|
+
|
|
131
|
+
Run `npm audit` regularly and update dependencies through Dependabot or similar tools.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
# MCP Guardian — Default Policy Configuration
|
|
3
|
+
# Use with: mcp-guardian proxy --policy ./default-policy.yaml
|
|
4
|
+
|
|
5
|
+
version: "1.0"
|
|
6
|
+
policy:
|
|
7
|
+
# Mode: audit (passive, log only), warn (block → flag), block (active enforcement)
|
|
8
|
+
mode: warn
|
|
9
|
+
|
|
10
|
+
rules:
|
|
11
|
+
# ── Block shell injection patterns ──────────────────────────
|
|
12
|
+
- name: "block-shell-injection"
|
|
13
|
+
description: "Block tool calls containing shell injection or command chaining"
|
|
14
|
+
action: block
|
|
15
|
+
patterns:
|
|
16
|
+
- "curl\\s|wget\\s" # Network download tools
|
|
17
|
+
- "rm\\s+-rf" # Destructive commands
|
|
18
|
+
- ";\\s*\\w" # Shell chaining
|
|
19
|
+
- "&&|\\|\\|" # Shell logical operators
|
|
20
|
+
- "\\$\\{" # Shell variable expansion
|
|
21
|
+
- "`[^`]+`" # Backtick command substitution
|
|
22
|
+
- "/etc/passwd|/etc/shadow" # Sensitive system files
|
|
23
|
+
|
|
24
|
+
# ── Block path traversal ─────────────────────────────────────
|
|
25
|
+
- name: "block-path-traversal"
|
|
26
|
+
description: "Block tool calls with path traversal attempts"
|
|
27
|
+
action: block
|
|
28
|
+
patterns:
|
|
29
|
+
- "\\.\\.\\/" # Path traversal
|
|
30
|
+
|
|
31
|
+
# ── Deny dangerous tools ─────────────────────────────────────
|
|
32
|
+
- name: "deny-dangerous-tools"
|
|
33
|
+
description: "Explicitly deny tools that can execute arbitrary code"
|
|
34
|
+
action: block
|
|
35
|
+
tools:
|
|
36
|
+
deny:
|
|
37
|
+
- "execute_command"
|
|
38
|
+
- "bash"
|
|
39
|
+
- "sh"
|
|
40
|
+
- "eval"
|
|
41
|
+
- "exec"
|
|
42
|
+
|
|
43
|
+
# ── Rate limit ───────────────────────────────────────────────
|
|
44
|
+
- name: "rate-limit-tool-calls"
|
|
45
|
+
description: "Limit tool calls to 120 per minute per server+tool"
|
|
46
|
+
action: flag
|
|
47
|
+
maxCallsPerMinute: 120
|
|
48
|
+
|
|
49
|
+
# ── Token budget ─────────────────────────────────────────────
|
|
50
|
+
- name: "token-budget"
|
|
51
|
+
description: "Flag tool calls exceeding 50K input tokens"
|
|
52
|
+
action: flag
|
|
53
|
+
maxTokens: 50000
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-guardian/server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Security, cost, and health audit for MCP infrastructure",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
|
-
"dist"
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"SECURITY.md",
|
|
11
|
+
"default-policy.yaml"
|
|
8
12
|
],
|
|
9
13
|
"bin": {
|
|
10
14
|
"mcp-guardian": "./dist/cli.js"
|