Skip to content

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

TypeScript

fix(tools): bound http_request via shared requestPinned (§8.1)

Andy Pavia4aec10f92218
diff --git a/docs/features/mcp-host-guardrails/mcp-host-guardrails-spec-v3.md b/docs/features/mcp-host-guardrails/mcp-host-guardrails-spec-v3.md
index 814134cb8..8035e1622 100644
--- a/docs/features/mcp-host-guardrails/mcp-host-guardrails-spec-v3.md
+++ b/docs/features/mcp-host-guardrails/mcp-host-guardrails-spec-v3.md
@@ -1458,7 +1458,10 @@ which a guardrail `allow` never bypasses.
LONG`); (3) `RemoteLlmHook` races every dial against a **hard per-hook deadline** so a never-settling
transport still yields `unavailable` → `failMode`; and (4) `main.ts` installs `uncaughtException`/
`unhandledRejection` guards so a stray listener throw is logged, not a silent exit. A fully-silent peer,
- connection-refused/DNS/5xx/malformed-JSON, and the SSRF pinning were already handled.
+ connection-refused/DNS/5xx/malformed-JSON, and the SSRF pinning were already handled. The native
+ `http_request` tool shares `requestPinned` and had the same latent weakness — it now passes an absolute
+ deadline (`AbortSignal`) and a byte ceiling (10 MiB, above its 50 KB display-truncation) so the same
+ trickle/flood bounds apply there too.
- **Content projection & content/egress gate — RESOLVED (§8.4/§8.7).** Earlier the install gate classified
only `moderate`/`postCallSuccess` as content-bearing while the runtime handed the full
`ToolCompletionRequest` (messages) to `pre_call`/`on_error` with no projection, so a low/mid-trust
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index fa326f009..b57a314ef 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.257",
+ "version": "0.1.258",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.257",
+ "version": "0.1.258",
"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 114a97755..100b6aafb 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.257",
+ "version": "0.1.258",
"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/tools/__tests__/httpRequestBounds.test.ts b/mcp-host/src/core/tools/__tests__/httpRequestBounds.test.ts
new file mode 100644
index 000000000..69faca910
--- /dev/null
+++ b/mcp-host/src/core/tools/__tests__/httpRequestBounds.test.ts
@@ -0,0 +1,36 @@
+/**
+ * http_request transport bounds (finding 3, shared `requestPinned`): the tool
+ * MUST pass an absolute-deadline `signal` and a `maxBytes` ceiling, so a
+ * trickling/flooding server can't hang or OOM the tool. Guards against the
+ * wiring being silently dropped (the finding's original root cause).
+ */
+import { describe, expect, it, vi } from 'vitest'
+import { HttpRequestTool } from '../httpRequest'
+
+const requestPinnedSpy = vi.fn((_opts: unknown) => Promise.resolve({ statusCode: 200, body: 'ok' }))
+
+vi.mock('../../net/ssrf', () => ({
+ requestPinned: (opts: unknown) => requestPinnedSpy(opts),
+ resolvePinnedPublicIp: vi.fn(async () => '93.184.216.34'), // public IP → guard passes
+ isPrivateIp: () => false,
+ SsrfBlockedError: class SsrfBlockedError extends Error {},
+}))
+
+describe('http_request transport bounds (finding 3)', () => {
+ it('passes an absolute-deadline signal + byte cap to requestPinned', async () => {
+ const tool = new HttpRequestTool(['example.com'])
+ const res = await tool.execute({ url: 'https://example.com/' })
+
+ expect(res.is_error).toBe(false)
+ expect(requestPinnedSpy).toHaveBeenCalledTimes(1)
+ const opts = requestPinnedSpy.mock.calls[0][0] as {
+ signal?: unknown
+ maxBytes?: number
+ timeoutMs?: number
+ }
+ expect(opts.signal).toBeInstanceOf(AbortSignal) // absolute deadline (not socket-idle)
+ expect(typeof opts.maxBytes).toBe('number')
+ expect(opts.maxBytes as number).toBeGreaterThan(50000) // above the display-truncation threshold
+ expect(opts.timeoutMs).toBe(30000)
+ })
+})
diff --git a/mcp-host/src/core/tools/httpRequest.ts b/mcp-host/src/core/tools/httpRequest.ts
index af81b97ce..3ec545b8d 100644
--- a/mcp-host/src/core/tools/httpRequest.ts
+++ b/mcp-host/src/core/tools/httpRequest.ts
@@ -8,6 +8,14 @@ import { ToolOutput } from '../types'
// hook fetcher.
export { isPrivateIp } from '../net/ssrf'
+// Transport bounds (shared requestPinned, §8.1). The timeout is enforced as an
+// ABSOLUTE deadline via AbortSignal — Node's socket `timeout` alone is an idle
+// timer a trickling server resets forever. The byte ceiling is a safety cap far
+// above the 50 KB display-truncation below, so normal responses are unaffected;
+// only a multi-MB flood is rejected (destroyed mid-stream, never fully buffered).
+const HTTP_REQUEST_TIMEOUT_MS = 30000
+const HTTP_REQUEST_MAX_BYTES = 10 * 1024 * 1024 // 10 MiB
+
export class HttpRequestTool implements Tool {
constructor(private readonly allowlist: string[]) {}
@@ -103,7 +111,9 @@ export class HttpRequestTool implements Tool {
headers,
body,
pinnedIp,
- timeoutMs: 30000,
+ timeoutMs: HTTP_REQUEST_TIMEOUT_MS,
+ signal: AbortSignal.timeout(HTTP_REQUEST_TIMEOUT_MS),
+ maxBytes: HTTP_REQUEST_MAX_BYTES,
})
const truncated =
responseBody.length > 50000