Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): document SSRF range scope and complete embedded-form tests

Alfredo Lopez3f6e91b229b9
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 9feb4321f..57caa3f41 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.472",
+ "version": "0.1.473",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.472",
+ "version": "0.1.473",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index 07681f4d1..d7bab3a4f 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.472",
+ "version": "0.1.473",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/core/net/ssrf.ts b/mcp-host/src/core/net/ssrf.ts
index 16a6542b5..19d44e02a 100644
--- a/mcp-host/src/core/net/ssrf.ts
+++ b/mcp-host/src/core/net/ssrf.ts
@@ -134,10 +134,13 @@ function isPrivateIpv4Octets(octets: readonly number[]): boolean {
}
/**
- * Canonical non-public IPv4 prefixes. Mirrors the IPv4 exclusions in
- * deploy/base/public-egress-exceptions.yaml (rule-level egress exceptions) and
- * the IANA range list used by mcp-servers/web-search's fetch destination
- * validator; keep the lists aligned when one changes.
+ * Non-public IPv4 prefixes required by the SSRF hardening scope. This is the
+ * issue-required subset of the IPv4 exclusions in
+ * deploy/base/public-egress-exceptions.yaml and the IANA range list used by
+ * mcp-servers/web-search's fetch destination validator. Those policies also
+ * exclude 192.31.196/24, 192.52.193/24, 192.88.99/24, and 192.175.48/24,
+ * which are deliberately out of scope here; the three policies keep
+ * distinct ranges by design.
*/
const NON_PUBLIC_IPV4_PREFIXES: readonly (readonly [address: string, prefix: number])[] = [
['0.0.0.0', 8], // "This network"
diff --git a/mcp-host/src/core/tools/__tests__/shellAndHttp.test.ts b/mcp-host/src/core/tools/__tests__/shellAndHttp.test.ts
index 3217b8664..67a8b08e4 100644
--- a/mcp-host/src/core/tools/__tests__/shellAndHttp.test.ts
+++ b/mcp-host/src/core/tools/__tests__/shellAndHttp.test.ts
@@ -242,22 +242,32 @@ describe('HttpRequestTool', () => {
expect(isPrivateIp('2002:808:808::')).toBe(true) // 6to4 form of 8.8.8.8
})
- it('should block new special-purpose IPv4 through mapped/compatible IPv6 forms', () => {
- // IPv4-mapped, dotted quad.
- expect(isPrivateIp('::ffff:100.64.0.1')).toBe(true)
- expect(isPrivateIp('::ffff:198.18.0.1')).toBe(true)
- expect(isPrivateIp('::ffff:224.0.0.1')).toBe(true)
- expect(isPrivateIp('::ffff:240.0.0.1')).toBe(true)
- expect(isPrivateIp('::ffff:192.0.2.1')).toBe(true)
- expect(isPrivateIp('::ffff:203.0.113.1')).toBe(true)
- // IPv4-mapped, hexadecimal.
- expect(isPrivateIp('::ffff:6440:1')).toBe(true) // 100.64.0.1
- expect(isPrivateIp('::ffff:c612:1')).toBe(true) // 198.18.0.1
- expect(isPrivateIp('::ffff:808:808')).toBe(false) // Public 8.8.8.8
- // IPv4-compatible, dotted quad.
- expect(isPrivateIp('::100.64.0.1')).toBe(true)
- expect(isPrivateIp('::198.18.0.1')).toBe(true)
- expect(isPrivateIp('::8.8.8.8')).toBe(false) // Public control
+ const NEW_SPECIAL_PURPOSE_IPV4: readonly (readonly [string, string])[] = [
+ ['100.64.0.1', '6440:1'],
+ ['198.18.0.1', 'c612:1'],
+ ['224.0.0.1', 'e000:1'],
+ ['240.0.0.1', 'f000:1'],
+ ['192.0.0.1', 'c000:1'],
+ ['192.0.2.1', 'c000:201'],
+ ['198.51.100.1', 'c633:6401'],
+ ['203.0.113.1', 'cb00:7101'],
+ ]
+
+ it.each(NEW_SPECIAL_PURPOSE_IPV4)(
+ 'should block %s (%s) through every IPv4-mapped/compatible representation',
+ (dotted: string, hex: string) => {
+ expect(isPrivateIp(`::ffff:${dotted}`)).toBe(true)
+ expect(isPrivateIp(`::ffff:${hex}`)).toBe(true)
+ expect(isPrivateIp(`::${dotted}`)).toBe(true)
+ expect(isPrivateIp(`::${hex}`)).toBe(true)
+ }
+ )
+
+ it('should keep public IPv4 public through mapped/compatible representations', () => {
+ expect(isPrivateIp('::ffff:8.8.8.8')).toBe(false)
+ expect(isPrivateIp('::ffff:808:808')).toBe(false)
+ expect(isPrivateIp('::8.8.8.8')).toBe(false)
+ expect(isPrivateIp('::808:808')).toBe(false)
})
it('should keep hostnames and non-IP strings outside the private classifier', () => {