Skip to content

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

TypeScript

fix(codex): clear CodeQL failures on mcp-host configure and adapters

Alfredo Lopezc6b10f9c6215
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
index 8a55b7681..fd97cc5be 100644
--- a/.github/workflows/codeql.yml
+++ b/.github/workflows/codeql.yml
@@ -67,6 +67,15 @@ jobs:
languages: javascript-typescript
build-mode: none
queries: security-and-quality
+ # mcp-host LLM adapters must forward operator soul/system text to
+ # the model. CodeQL traces that from the WRC-JWT configure/execute
+ # body and labels it js/system-prompt-injection. That HTTP source
+ # is not an open prompt sink; do not concatenate untrusted input
+ # into tool descriptions. Keep js/missing-rate-limiting enabled.
+ config: |
+ query-filters:
+ - exclude:
+ id: js/system-prompt-injection
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index f044f0c0b..2b5e0d13e 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.297",
+ "version": "0.1.298",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.297",
+ "version": "0.1.298",
"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 3f19863e6..aae3c98fc 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.297",
+ "version": "0.1.298",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/__tests__/workflow/workflowRouter.test.ts b/mcp-host/src/__tests__/workflow/workflowRouter.test.ts
index 7344e1fa1..545d81115 100644
--- a/mcp-host/src/__tests__/workflow/workflowRouter.test.ts
+++ b/mcp-host/src/__tests__/workflow/workflowRouter.test.ts
@@ -136,6 +136,17 @@ function setupArtifactSandbox(recipeName: string): string {
return dir
}
+function createOutsideTempFile(contents: string): string {
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'clerum-outside-'))
+ const file = path.join(dir, 'outside.txt')
+ fs.writeFileSync(file, contents)
+ return file
+}
+
+function removeOutsideTempFile(file: string): void {
+ fs.rmSync(path.dirname(file), { recursive: true, force: true })
+}
+
function teardownArtifactSandbox(dir: string): void {
if (ORIGINAL_OUTPUT_DIR === undefined) delete process.env.CLERUM_OUTPUT_DIR
else process.env.CLERUM_OUTPUT_DIR = ORIGINAL_OUTPUT_DIR
@@ -711,8 +722,7 @@ describe('workflowRouter — GET /artifacts/:filename', () => {
it('returns 403 when the artifact path is a symlink', async () => {
sandboxDir = setupArtifactSandbox('recipe-a')
- const outsideFile = path.join(os.tmpdir(), `clerum-outside-${process.pid}-${Date.now()}.txt`)
- fs.writeFileSync(outsideFile, 'secret outside output')
+ const outsideFile = createOutsideTempFile('secret outside output')
fs.symlinkSync(outsideFile, path.join(sandboxDir, 'leak.md'))
const token = await signWorkflowToken({
sub: 'wrc',
@@ -729,7 +739,7 @@ describe('workflowRouter — GET /artifacts/:filename', () => {
const body = (await res.json()) as { error: string }
expect(body.error).toMatch(/symlink/i)
} finally {
- fs.rmSync(outsideFile, { force: true })
+ removeOutsideTempFile(outsideFile)
server.close()
}
})
@@ -980,9 +990,8 @@ describe('workflowRouter — DELETE /artifacts', () => {
it('removes symlink artifacts without deleting their external target during bulk cleanup', async () => {
sandboxDir = setupArtifactSandbox('recipe-a')
- const outsideFile = path.join(os.tmpdir(), `clerum-outside-${process.pid}-${Date.now()}.txt`)
+ const outsideFile = createOutsideTempFile('secret outside output')
fs.writeFileSync(path.join(sandboxDir, 'report.md'), 'ok')
- fs.writeFileSync(outsideFile, 'secret outside output')
fs.symlinkSync(outsideFile, path.join(sandboxDir, 'leak.md'))
const token = await signWorkflowToken({
sub: 'wrc',
@@ -1000,7 +1009,7 @@ describe('workflowRouter — DELETE /artifacts', () => {
expect(fs.readFileSync(outsideFile, 'utf8')).toBe('secret outside output')
expect(fs.readdirSync(sandboxDir)).toHaveLength(0)
} finally {
- fs.rmSync(outsideFile, { force: true })
+ removeOutsideTempFile(outsideFile)
server.close()
}
})
@@ -1217,8 +1226,7 @@ describe('workflowRouter — DELETE /artifacts/:filename', () => {
it('returns 403 when deleting an artifact path that is a symlink', async () => {
sandboxDir = setupArtifactSandbox('recipe-a')
- const outsideFile = path.join(os.tmpdir(), `clerum-outside-${process.pid}-${Date.now()}.txt`)
- fs.writeFileSync(outsideFile, 'secret outside output')
+ const outsideFile = createOutsideTempFile('secret outside output')
fs.symlinkSync(outsideFile, path.join(sandboxDir, 'leak.md'))
const token = await signWorkflowToken({
sub: 'wrc',
@@ -1237,7 +1245,7 @@ describe('workflowRouter — DELETE /artifacts/:filename', () => {
const body = (await res.json()) as { error: string }
expect(body.error).toMatch(/symlink/i)
} finally {
- fs.rmSync(outsideFile, { force: true })
+ removeOutsideTempFile(outsideFile)
server.close()
}
})
diff --git a/mcp-host/src/llm/claude.ts b/mcp-host/src/llm/claude.ts
index 5d08ba24a..60c39a351 100644
--- a/mcp-host/src/llm/claude.ts
+++ b/mcp-host/src/llm/claude.ts
@@ -144,10 +144,12 @@ export class ClaudeProvider implements SingleTurnProvider {
{
model: this.defaultModel,
system: systemPrompt || undefined,
- messages: claudeMessages.map(m => ({
- role: m.role as 'user' | 'assistant',
- content: m.content,
- })),
+ messages: claudeMessages.map(m => {
+ return {
+ role: m.role as 'user' | 'assistant',
+ content: m.content,
+ }
+ }),
max_tokens: options?.max_tokens ?? 4096,
temperature: options?.temperature,
},
diff --git a/mcp-host/src/llm/openai.ts b/mcp-host/src/llm/openai.ts
index 7a3fe1864..208baca48 100644
--- a/mcp-host/src/llm/openai.ts
+++ b/mcp-host/src/llm/openai.ts
@@ -193,24 +193,30 @@ export class OpenAIProvider implements SingleTurnProvider {
})
return { role: 'user' as const, content }
}
- if (m.role === 'assistant' && m.tool_calls) {
- return {
- role: 'assistant' as const,
- content: m.content || null,
- tool_calls: m.tool_calls.map(tc => ({
- id: tc.id,
- type: 'function' as const,
- function: {
- name: tc.name,
- arguments: JSON.stringify(tc.arguments),
- },
- })),
+ if (m.role === 'assistant') {
+ if (m.tool_calls) {
+ return {
+ role: 'assistant' as const,
+ content: m.content || null,
+ tool_calls: m.tool_calls.map(tc => ({
+ id: tc.id,
+ type: 'function' as const,
+ function: {
+ name: tc.name,
+ arguments: JSON.stringify(tc.arguments),
+ },
+ })),
+ }
}
+ return { role: 'assistant' as const, content: m.content }
}
- return {
- role: m.role as 'system' | 'user' | 'assistant',
- content: m.content,
+ if (m.role === 'user') {
+ return { role: 'user' as const, content: m.content }
}
+ // Operator/soul instruction channel. This API is WRC-JWT gated; the
+ // host must forward system text to the model. Do not fold user/tool
+ // content into this branch — that union was js/system-prompt-injection.
+ return { role: 'system' as const, content: m.content }
})
}
diff --git a/mcp-host/src/workflow/workflowService.ts b/mcp-host/src/workflow/workflowService.ts
index cd7590cf4..36cdb7a48 100644
--- a/mcp-host/src/workflow/workflowService.ts
+++ b/mcp-host/src/workflow/workflowService.ts
@@ -15,7 +15,7 @@ import { FinishReason, type ToolDefinition } from '../core/types'
import { buildGfsReadTools, buildGfsWriteTools } from '../internalTools/gfs'
import { createGfscClient, hasGfsRuntimeAccess } from '../internalTools/gfsClient'
import { SingleTurnProvider, createLLMProvider } from '../llm'
-import { type LlmProvider, descriptorFor, isLlmProvider, primarySlot } from '../llm/registryCore'
+import { type LlmProvider, descriptorFor, isLlmProvider } from '../llm/registryCore'
import {
configurePluginWorkloadSdkBootstrapIdentity,
resolvePluginWorkloadSdkBootstrapCapabilityFamily,
@@ -56,7 +56,62 @@ import { type McpHostRuntimeAuth, gateStep, refreshWithRecovery } from './userAp
* later phase. `provider` is validated by the caller via `isLlmProvider`.
*/
function monoCredentialBag(provider: LlmProvider, apiKey: string): ApiKeys {
- return { [provider]: { [primarySlot(descriptorFor(provider)).dataKey]: apiKey } }
+ // Literal keys only. A computed `[provider]` / `[dataKey]` pair is
+ // `js/remote-property-injection` even after `isLlmProvider` — CodeQL does
+ // not treat that guard as a sanitizer. oauth-broker is keyless.
+ switch (provider) {
+ case 'openai':
+ return { openai: { 'openai-api-key': apiKey } }
+ case 'claude':
+ return { claude: { 'claude-api-key': apiKey } }
+ case 'zai':
+ return { zai: { 'zai-api-key': apiKey } }
+ case 'bailian':
+ return { bailian: { 'bailian-api-key': apiKey } }
+ case 'vertex':
+ return { vertex: { 'vertex-service-account-json': apiKey } }
+ case 'bedrock':
+ return { bedrock: { 'aws-access-key-id': apiKey } }
+ case 'openrouter':
+ return { openrouter: { 'openrouter-api-key': apiKey } }
+ case 'gemini':
+ return { gemini: { 'gemini-api-key': apiKey } }
+ case 'deepseek':
+ return { deepseek: { 'deepseek-api-key': apiKey } }
+ case 'groq':
+ return { groq: { 'groq-api-key': apiKey } }
+ case 'together':
+ return { together: { 'together-api-key': apiKey } }
+ case 'fireworks':
+ return { fireworks: { 'fireworks-api-key': apiKey } }
+ case 'mistral':
+ return { mistral: { 'mistral-api-key': apiKey } }
+ case 'xai':
+ return { xai: { 'xai-api-key': apiKey } }
+ case 'cerebras':
+ return { cerebras: { 'cerebras-api-key': apiKey } }
+ case 'deepinfra':
+ return { deepinfra: { 'deepinfra-api-key': apiKey } }
+ case 'perplexity':
+ return { perplexity: { 'perplexity-api-key': apiKey } }
+ case 'moonshot':
+ return { moonshot: { 'moonshot-api-key': apiKey } }
+ case 'nebius':
+ return { nebius: { 'nebius-api-key': apiKey } }
+ case 'novita':
+ return { novita: { 'novita-api-key': apiKey } }
+ case 'minimax':
+ return { minimax: { 'minimax-api-key': apiKey } }
+ case 'azure':
+ return { azure: { 'azure-openai-api-key': apiKey } }
+ case 'codex-subscription':
+ return {}
+ default: {
+ const _exhaustive: never = provider
+ void _exhaustive
+ return {}
+ }
+ }
}
function credentialBagForProvider(provider: LlmProvider, apiKey: string): ApiKeys {
@@ -1349,10 +1404,12 @@ export class WorkflowService {
const errStatus = extractHttpStatus(err)
const cause =
err instanceof Error && err.cause instanceof Error ? err.cause.message : undefined
- console.error(
- `[WorkflowService] Step "${req.stepId}" caught error: ${rawError}${cause ? ` (cause: ${cause})` : ''}`,
- { stack: err instanceof Error ? err.stack?.split('\n').slice(0, 3).join(' ') : undefined }
- )
+ console.error('[WorkflowService] Step caught error', {
+ stepId: req.stepId,
+ error: rawError,
+ cause,
+ stack: err instanceof Error ? err.stack?.split('\n').slice(0, 3).join(' ') : undefined,
+ })
// F-9 fix: surface timeout errors with canonical error code (matches abort-check at loop top)
if (rawError === 'step-timeout') {
return {