Skip to content

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

TypeScript

fix(rpc-proxy): refuse a task cancel without the caller subject

Alfredo Lopezf0dab25a6e1e
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.ts
index d34efae13..6dfc90bc9 100644
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@ -9,7 +9,7 @@ export type ReleaseManifest = {
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.10.0',
externalRestApiVersion: '0.1.85',
- rpcProxyVersion: '0.1.108',
+ rpcProxyVersion: '0.1.109',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
}
diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.json
index 7971bd037..0ca2dd80e 100644
--- a/rpc-proxy/package-lock.json
+++ b/rpc-proxy/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.108",
+ "version": "0.1.109",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-rpc-proxy",
- "version": "0.1.108",
+ "version": "0.1.109",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --git a/rpc-proxy/package.json b/rpc-proxy/package.json
index 7b4fc06b2..209252ae1 100644
--- a/rpc-proxy/package.json
+++ b/rpc-proxy/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.108",
+ "version": "0.1.109",
"description": "External-facing RPC proxy for tenant-scoped MCP access",
"main": "dist/main.js",
"engines": {
diff --git a/rpc-proxy/src/services/__tests__/mcpHostRestService.test.ts b/rpc-proxy/src/services/__tests__/mcpHostRestService.test.ts
index 80906ad1d..d984099bc 100644
--- a/rpc-proxy/src/services/__tests__/mcpHostRestService.test.ts
+++ b/rpc-proxy/src/services/__tests__/mcpHostRestService.test.ts
@@ -169,6 +169,27 @@ describe('forwardCancelToHost aborts only through the caller signal', () => {
vi.useRealTimers()
}
})
+
+ // mcp-host checks cancel ownership against this userId, so a missing caller
+ // subject must fail here instead of being replaced by a stand-in identity.
+ it('forwards the caller subject and refuses an empty one before any request', async () => {
+ const fetchMock = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementation(async () => new Response(null, { status: 204 }))
+ try {
+ await forwardCancelToHost(HOST, 'task-1', 'user-1', new AbortController().signal)
+ // Control and liveness witness: a real subject reaches the upstream body.
+ expect(fetchMock).toHaveBeenCalledTimes(1)
+ expect(JSON.parse(String(fetchMock.mock.calls[0]![1]?.body))).toEqual({ userId: 'user-1' })
+
+ await expect(
+ forwardCancelToHost(HOST, 'task-1', '', new AbortController().signal)
+ ).rejects.toThrow('task cancel requires the caller subject')
+ expect(fetchMock).toHaveBeenCalledTimes(1)
+ } finally {
+ fetchMock.mockRestore()
+ }
+ })
})
const baseUpstream = {
diff --git a/rpc-proxy/src/services/mcpHostRestService.ts b/rpc-proxy/src/services/mcpHostRestService.ts
index c28b6afff..d4b6623f9 100644
--- a/rpc-proxy/src/services/mcpHostRestService.ts
+++ b/rpc-proxy/src/services/mcpHostRestService.ts
@@ -253,13 +253,14 @@ export type CancelUpstreamResult = {
export async function forwardCancelToHost(
host: ResolvedServerConnection,
taskId: string,
- userId: string | undefined,
+ userId: string,
signal: AbortSignal
): Promise<CancelUpstreamResult> {
+ // mcp-host applies its ownership check to this userId, so it must be the
+ // caller's own subject; a stand-in identity would be checked instead.
+ if (!userId) throw new Error('task cancel requires the caller subject')
const baseUrl = host.url.replace(/\/+$/, '')
- // Mirrors the approve/deny pattern: always forward userId so mcp-host can
- // apply the ownership check. Falls back to 'desktop-app' when absent.
- const upstreamBody = { userId: userId || 'desktop-app' }
+ const upstreamBody = { userId }
const response = await fetch(`${baseUrl}/v1/runtime/tasks/${encodeURIComponent(taskId)}/cancel`, {
method: 'POST',
headers: {