Skip to content

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

TypeScript

fix(rpc-proxy): validate session identifiers

Alfredo Lopezd3cef3db69cc
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.ts
index 18182251e..e3307d2e2 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.112',
+ rpcProxyVersion: '0.1.113',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
}
diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.json
index 6e2967f85..c4fee10b4 100644
--- a/rpc-proxy/package-lock.json
+++ b/rpc-proxy/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.112",
+ "version": "0.1.113",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-rpc-proxy",
- "version": "0.1.112",
+ "version": "0.1.113",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --git a/rpc-proxy/package.json b/rpc-proxy/package.json
index ed2a02696..b0d3ec855 100644
--- a/rpc-proxy/package.json
+++ b/rpc-proxy/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.112",
+ "version": "0.1.113",
"description": "External-facing RPC proxy for tenant-scoped MCP access",
"main": "dist/main.js",
"engines": {
diff --git a/rpc-proxy/src/authToken.ts b/rpc-proxy/src/authToken.ts
index 27a567415..8f54f3759 100644
--- a/rpc-proxy/src/authToken.ts
+++ b/rpc-proxy/src/authToken.ts
@@ -34,6 +34,7 @@ export function verifyRpcToken(token: string): RpcAccessClaims | null {
!Array.isArray(payload?.scopes) ||
!Array.isArray(payload?.hostRefs) ||
typeof payload?.jti !== 'string' ||
+ payload.jti.trim().length === 0 ||
typeof payload?.iat !== 'number' ||
typeof payload?.exp !== 'number'
) {
diff --git a/rpc-proxy/test/approvalSubject.integration.test.ts b/rpc-proxy/test/approvalSubject.integration.test.ts
index 1a97f3677..d4fa54d64 100644
--- a/rpc-proxy/test/approvalSubject.integration.test.ts
+++ b/rpc-proxy/test/approvalSubject.integration.test.ts
@@ -67,6 +67,7 @@ const invalidSubjects = [
{ label: 'null', sub: null },
{ label: 'number', sub: 42 },
]
+const invalidSessionIds = invalidSubjects.map(({ label, sub }) => ({ label, jti: sub }))
const scopes = [
{ label: 'team', accessScope: 'team', teamId: 'diagnostic-team' },
{ label: 'user', accessScope: 'user', teamId: null },
@@ -146,6 +147,36 @@ describe('signed RPC service subject validation', () => {
})
})
+describe.each([
+ { label: 'user', claims: {} },
+ { label: 'service', claims: serviceClaims },
+])('$label RPC session identifier validation', ({ claims }) => {
+ it.each(invalidSessionIds)('rejects $label session identifier', ({ jti }) => {
+ expect(verifyRpcToken(fixture.sign({ ...claims, jti }))).toBeNull()
+ })
+ it('preserves a non-blank session identifier verbatim', () => {
+ expect(verifyRpcToken(fixture.sign({ ...claims, jti: ' diagnostic-session ' }))?.jti).toBe(
+ ' diagnostic-session '
+ )
+ })
+ describe.each(['approve', 'deny'])('%s session identifier authentication', action => {
+ it.each(invalidSessionIds)(
+ 'rejects $label session identifier before any Host side effect',
+ async ({ jti }) => {
+ const response = await request(makeApp())
+ .post(`/rpc/hosts/diagnostic-host/approvals/${action}`)
+ .set('authorization', `Bearer ${fixture.sign({ ...claims, jti })}`)
+ .send({ toolCallId: 'diagnostic-approval' })
+ expect(response.status).toBe(401)
+ expect(response.body).toEqual({ error: 'Unauthorized' })
+ expect(edges.resolveHostConnectionForUser.mock.calls.length).toBe(0)
+ expect(upstream.mock.calls.length).toBe(0)
+ expect(edges.requestHostWakeFromControlApi.mock.calls.length).toBe(0)
+ }
+ )
+ })
+})
+
describe.each(['approve', 'deny'])('%s service authentication contract', action => {
it('denies an authenticated service identity before any Host side effect', async () => {
const response = await request(makeApp())