Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(security): eliminate workflow template ReDoS
Josuédb6bef826a5c
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex f70bce446..844a7a064 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.714",+ "version": "0.1.715","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.714",+ "version": "0.1.715","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex d6b80060c..5d49e9968 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.714",+ "version": "0.1.715","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/routes/admin/recipes.ts b/control-api/src/routes/admin/recipes.tsindex 6f6d74d12..b241e738f 100644--- a/control-api/src/routes/admin/recipes.ts+++ b/control-api/src/routes/admin/recipes.ts@@ -1,6 +1,9 @@import { Router } from 'express'import { isWorkflowRecipeDefaultAllowedCapability } from '@clerum/workflow-recipe-capability-policy'-import { EVENFIRE_REGISTRY_PULL_SECRET_NAME } from '@clerum/workflow-runtime-core'+import {+ EVENFIRE_REGISTRY_PULL_SECRET_NAME,+ scanTemplateReferences,+} from '@clerum/workflow-runtime-core'import { config } from '../../config.js'import { asyncHandler } from '../../http/asyncHandler.js'import { CONTENT_TYPES } from '../../http/contentTypes.js'@@ -112,7 +115,6 @@ const JWT_LIKE_RE = /^[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}\.[A-Za-z0-9_-]{16,}const SECRET_LIKE_VALUE_RE = /^(sk-[A-Za-z0-9_-]{8,}|pat[A-Za-z0-9_-]{8,})$/const URL_WITH_PASSWORD_RE = /^[a-z][a-z0-9+.-]*:\/\/[^/\s:@]+:([^@\s]+)@/iconst INPUT_TEMPLATE_ONLY_RE = /^\{\{\s*inputs\.[A-Za-z0-9_.-]+\s*\}\}$/-const TEMPLATE_RE = /\{\{([^}]+)\}\}/g// Pre-persistence mirror of workflow-recipes/src/reconciler/templateEngine.ts.// Keep in parity with the WRC runtime guard; WRC remains the final source of truth.const BLOCKED_TEMPLATE_KEYS = new Set([@@ -364,8 +366,8 @@ function validateTemplateString(context: Parameters<typeof validateTemplateRef>[1]): ValidationError[] {const errors: ValidationError[] = []- for (const match of value.matchAll(TEMPLATE_RE)) {- const reason = validateTemplateRef(match[1], context)+ for (const match of scanTemplateReferences(value)) {+ const reason = validateTemplateRef(match.body, context)if (!reason) continueerrors.push({field,diff --git a/control-api/test/routes.adminRecipes.test.ts b/control-api/test/routes.adminRecipes.test.tsindex c9c55b1e9..ff0da4f83 100644--- a/control-api/test/routes.adminRecipes.test.ts+++ b/control-api/test/routes.adminRecipes.test.ts@@ -1,6 +1,7 @@import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'import express, { type Express, Response as ExpressResponse, NextFunction, Request } from 'express'import jwt from 'jsonwebtoken'+import { spawnSync } from 'node:child_process'import http from 'node:http'import request from 'supertest'import { config } from '../src/config.js'@@ -244,6 +245,51 @@ describe.sequential('routes/admin/recipes', () => {await closeTestServer(server)})+ it('CodeQL 427 bounds malformed template scanning', async () => {+ if (process.env.TEMPLATE_REDOS_CHILD !== '1') {+ const child = spawnSync(+ process.execPath,+ [+ 'node_modules/vitest/vitest.mjs',+ 'run',+ 'test/routes.adminRecipes.test.ts',+ '--pool=threads',+ '--maxWorkers=1',+ '-t',+ 'CodeQL 427 bounds malformed template scanning',+ ],+ {+ env: { ...process.env, TEMPLATE_REDOS_CHILD: '1' },+ encoding: 'utf8',+ timeout: 15_000,+ killSignal: 'SIGKILL',+ }+ )+ expect(child.stdout).toContain('TEMPLATE_SCAN_STARTED')+ expect(+ child.error,+ 'recipe validation must finish within the generous CPU deadline'+ ).toBeUndefined()+ expect(child.status, child.stdout + child.stderr).toBe(0)+ return+ }+ const value = '{{{{|'.repeat(200_000)+ const largeApp = express()+ largeApp.use(express.json({ limit: config.jsonBodyLimit }))+ largeApp.use(createAdminRecipesRouter(gateway as never))+ process.stdout.write('TEMPLATE_SCAN_STARTED\n')+ const res = await request(largeApp)+ .post('/admin/recipes/validate')+ .send({+ ...VALID_RECIPE,+ spec: {+ workloads: [{ ...VALID_RECIPE.spec.workloads[0], env: [{ name: 'NOTE', value }] }],+ },+ })+ .expect(200)+ expect(res.body.valid).toBe(true)+ }, 20_000)+// ── CRUD happy path ──────────────────────────────────────────────────────it('POST /admin/recipes — CRD always lands in sandbox-recipes (canonical) when metadata.namespace is omitted', async () => {diff --git a/packages/workflow-runtime-core/src/index.ts b/packages/workflow-runtime-core/src/index.tsindex bbcefe2bb..311be813f 100644--- a/packages/workflow-runtime-core/src/index.ts+++ b/packages/workflow-runtime-core/src/index.ts@@ -59,3 +59,6 @@ export {imageRefHost,isPlatformRegistryImage,} from './registry-image'++export { scanTemplateReferences, replaceTemplateReferences } from './templateReferences'+export type { TemplateReference } from './templateReferences'diff --git a/packages/workflow-runtime-core/src/injection/prompt.ts b/packages/workflow-runtime-core/src/injection/prompt.tsindex d283c13c6..14f51bc83 100644--- a/packages/workflow-runtime-core/src/injection/prompt.ts+++ b/packages/workflow-runtime-core/src/injection/prompt.ts@@ -1,4 +1,5 @@import type { StepSpec } from '../config-loader/types'+import { replaceTemplateReferences } from '../templateReferences'export const DEFAULT_PREVIOUS_OUTPUT_PROMPT_MAX_CHARS = 8192export const MIN_PREVIOUS_OUTPUT_PROMPT_MAX_CHARS = 1024@@ -37,7 +38,7 @@ export function renderPrompt(context: PromptContext,previousOutputMaxChars = RUNTIME_PREVIOUS_OUTPUT_PROMPT_MAX_CHARS): string {- return template.replace(/\{\{([^}]+)\}\}/g, (_match, key: string) => {+ return replaceTemplateReferences(template, (key: string) => {const trimmed = key.trim()// {{workflow:name}}diff --git a/packages/workflow-runtime-core/src/templateReferences.ts b/packages/workflow-runtime-core/src/templateReferences.tsnew file mode 100644index 000000000..47c9c622f--- /dev/null+++ b/packages/workflow-runtime-core/src/templateReferences.ts@@ -0,0 +1,43 @@+export interface TemplateReference {+ start: number+ end: number+ body: string+}++/**+ * Scan the legacy {{nonempty-body-without-}} syntax without backtracking.+ * Backslashes are literal; nested opening braces remain part of the body.+ * Each search advances past the region it inspected, including malformed closes.+ * Thus even unmatched opening delimiters take O(input length) work.+ */+export function* scanTemplateReferences(value: string): Generator<TemplateReference> {+ let cursor = 0+ while (cursor < value.length) {+ const start = value.indexOf('{{', cursor)+ if (start === -1) return+ const close = value.indexOf('}', start + 2)+ if (close === -1) return+ if (close === start + 2 || value[close + 1] !== '}') {+ cursor = close + 1+ continue+ }+ const end = close + 2+ yield { start, end, body: value.slice(start + 2, close) }+ cursor = end+ }+}++/** Replace references once, preserving literal text and callback results verbatim. */+export function replaceTemplateReferences(+ value: string,+ resolve: (body: string) => string+): string {+ const parts: string[] = []+ let cursor = 0+ for (const ref of scanTemplateReferences(value)) {+ parts.push(value.slice(cursor, ref.start), resolve(ref.body))+ cursor = ref.end+ }+ parts.push(value.slice(cursor))+ return parts.join('')+}diff --git a/packages/workflow-runtime-core/tests/unit/injection.test.ts b/packages/workflow-runtime-core/tests/unit/injection.test.tsindex d2da6caa9..b6a0a69d8 100644--- a/packages/workflow-runtime-core/tests/unit/injection.test.ts+++ b/packages/workflow-runtime-core/tests/unit/injection.test.ts@@ -1,4 +1,5 @@import { afterEach, describe, expect, it, vi } from 'vitest'+import { spawnSync } from 'node:child_process'import { requestModelInjection } from '../../src/injection/model'import { getPreviousOutputPromptMaxChars, renderPrompt } from '../../src/injection/prompt'import { loadSoul } from '../../src/injection/soul'@@ -6,6 +7,38 @@ import { createStaticRuntimeTokenProvider } from '../../src/runtime-token-providimport { AUTH_RETRY_DELAY_MS } from '../../src/status-reporter/authRetry'describe('renderPrompt()', () => {+ it('CodeQL 427 bounds malformed template scanning', () => {+ if (process.env.TEMPLATE_REDOS_CHILD === '1') {+ const value = '{{{{|'.repeat(200_000)+ process.stdout.write('TEMPLATE_SCAN_STARTED\n')+ expect(renderPrompt(value, { step: { id: 'x' } as any, previousOutputs: {} })).toBe(value)+ return+ }+ const child = spawnSync(+ process.execPath,+ [+ 'node_modules/vitest/vitest.mjs',+ 'run',+ 'tests/unit/injection.test.ts',+ '--pool=threads',+ '--maxWorkers=1',+ '-t',+ 'CodeQL 427 bounds malformed template scanning',+ ],+ {+ env: { ...process.env, TEMPLATE_REDOS_CHILD: '1' },+ encoding: 'utf8',+ timeout: 15_000,+ killSignal: 'SIGKILL',+ }+ )+ expect(child.stdout).toContain('TEMPLATE_SCAN_STARTED')+ expect(+ child.error,+ 'prompt rendering must finish within the generous CPU deadline'+ ).toBeUndefined()+ expect(child.status, child.stdout + child.stderr).toBe(0)+ }, 20_000)afterEach(() => {delete process.env.CLERUM_WORKFLOW_PREVIOUS_OUTPUT_PROMPT_MAX_CHARS})diff --git a/packages/workflow-runtime-core/tests/unit/templateReferences.test.ts b/packages/workflow-runtime-core/tests/unit/templateReferences.test.tsnew file mode 100644index 000000000..23a8319df--- /dev/null+++ b/packages/workflow-runtime-core/tests/unit/templateReferences.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it } from 'vitest'+import { replaceTemplateReferences, scanTemplateReferences } from '../../src/templateReferences'++describe('template reference scanner', () => {+ it('preserves the legacy delimiter contract on bounded generated inputs', () => {+ const cases = [+ '{{inputs.name}}',+ '{{computed.name}}{{db:host}}{{db:port}}',+ 'literal {{ resource:FIELD }} trailing',+ '\\{{name}}',+ '{{}}',+ '{{ }}',+ '{{',+ '{{body}',+ '{{body}x}}',+ '{{{{body}}',+ '{{a}}}{{b}}',+ ]+ let seed = 427+ const tokens = ['{{', '}}', '{', '}', 'name', ' ', '\\', ':', 'x']+ for (let i = 0; i < 10000; i++) {+ let value = ''+ for (let j = 0; j < 12; j++) {+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0+ value += tokens[seed % tokens.length]+ }+ cases.push(value)+ }+ for (const value of cases) {+ const expected = [...value.matchAll(/\{\{([^}]+)\}\}/g)].map(match => ({+ start: match.index,+ end: match.index + match[0].length,+ body: match[1],+ }))+ expect([...scanTemplateReferences(value)], value).toEqual(expected)+ expect(+ replaceTemplateReferences(value, body => `[${body}]`),+ value+ ).toBe(value.replace(/\{\{([^}]+)\}\}/g, (_match, body) => `[${body}]`))+ }+ })++ it('does not rescan replacements or interpret replacement dollar sequences', () => {+ expect(replaceTemplateReferences('a{{x}}{{y}}b', () => '{{z}}$&')).toBe('a{{z}}$&{{z}}$&b')+ })++ it('preserves large malformed text and advances through many adjacent references', () => {+ const malformed = '{{{{|'.repeat(200_000)+ expect([...scanTemplateReferences(malformed)]).toEqual([])+ expect(replaceTemplateReferences(malformed, () => 'unexpected')).toBe(malformed)+ expect([...scanTemplateReferences('{{x}}'.repeat(100_000))]).toHaveLength(100_000)+ })+})diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex 90496da1a..70f2708e1 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.460",+ "version": "0.1.461","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.460",+ "version": "0.1.461","license": "SEE LICENSE IN LICENSE","dependencies": {"@aws-sdk/client-s3": "^3.1009.0",diff --git a/workflow-recipes/package.json b/workflow-recipes/package.jsonindex ac7b81a9a..51dbd71f3 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.460",+ "version": "0.1.461","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/reconciler/internalDependencies.templateCompatibility.test.ts b/workflow-recipes/src/reconciler/internalDependencies.templateCompatibility.test.tsnew file mode 100644index 000000000..3c4a969bc--- /dev/null+++ b/workflow-recipes/src/reconciler/internalDependencies.templateCompatibility.test.ts@@ -0,0 +1,40 @@+import { describe, expect, it } from 'vitest'+import { extractUnresolvedWorkloadTemplateReferences } from './internalDependencies'++describe('workload template delimiter compatibility', () => {+ it('preserves the legacy workload subset including nested-opening recovery', () => {+ const cases = [+ '{{db:host}}',+ '{{ db : port }}',+ '{{db:host}}{{api:port}}',+ '\\{{db:host}}',+ '{{invalid:{{db:host}}',+ '{{{{db:host}}',+ '{{:host}}',+ '{{ :host}}',+ '{{db:host}',+ '{{}}',+ '{{db:host }}',+ '{{x:y:host}}',+ '{{inputs.name}}',+ '{{db:host}}literal{{api:port}}',+ ]+ let seed = 427+ const tokens = ['{{', '}}', '}', ':', 'db', 'host', 'port', ' ', '\\', 'x']+ for (let i = 0; i < 5000; i++) {+ let value = ''+ for (let j = 0; j < 12; j++) {+ seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0+ value += tokens[seed % tokens.length]+ }+ cases.push(value)+ }+ // Small bounded reference inputs only: never run the old regex on the attack fixture.+ for (const value of cases) {+ const expected = [...value.matchAll(/\{\{\s*([^}:]+)\s*:\s*(host|port)\s*\}\}/g)]+ .map(match => ({ workloadId: match[1].trim(), field: match[2] }))+ .filter(ref => Boolean(ref.workloadId))+ expect(extractUnresolvedWorkloadTemplateReferences(value), value).toEqual(expected)+ }+ })+})diff --git a/workflow-recipes/src/reconciler/internalDependencies.test.ts b/workflow-recipes/src/reconciler/internalDependencies.test.tsindex 582c1d12e..8fd9a5c72 100644--- a/workflow-recipes/src/reconciler/internalDependencies.test.ts+++ b/workflow-recipes/src/reconciler/internalDependencies.test.ts@@ -1,4 +1,5 @@import { describe, expect, it } from 'vitest'+import { spawnSync } from 'node:child_process'import type { CronJobDef, DeploymentDef, WorkflowRecipeCRD, WorkloadDef } from '../types'import { evaluateInternalDependencies } from './internalDependencies'import { resolveWorkloadTemplates } from './workloadTemplates'@@ -44,6 +45,42 @@ function resolveNamespaceForTest(r: WorkflowRecipeCRD, workload: WorkloadDef): s}describe('evaluateInternalDependencies', () => {+ it('CodeQL 427 bounds malformed template scanning', () => {+ if (process.env.TEMPLATE_REDOS_CHILD === '1') {+ const r = recipe([+ deployment('api', 8080, {+ env: [{ name: 'NOTE', value: '{{{{|'.repeat(200_000) }],+ }),+ ])+ process.stdout.write('TEMPLATE_SCAN_STARTED\n')+ expect(evaluate(r)).toEqual({ issues: [], dependencies: [] })+ return+ }+ const child = spawnSync(+ process.execPath,+ [+ 'node_modules/vitest/vitest.mjs',+ 'run',+ 'src/reconciler/internalDependencies.test.ts',+ '--pool=threads',+ '--maxWorkers=1',+ '-t',+ 'CodeQL 427 bounds malformed template scanning',+ ],+ {+ env: { ...process.env, TEMPLATE_REDOS_CHILD: '1' },+ encoding: 'utf8',+ timeout: 15_000,+ killSignal: 'SIGKILL',+ }+ )+ expect(child.stdout).toContain('TEMPLATE_SCAN_STARTED')+ expect(+ child.error,+ 'dependency detection must finish within the generous CPU deadline'+ ).toBeUndefined()+ expect(child.status, child.stdout + child.stderr).toBe(0)+ }, 20_000)it('infers LeadForge-like api, worker, and cron dependencies from resolved workload hosts', () => {const r = recipe([deployment('api', 8080, {diff --git a/workflow-recipes/src/reconciler/internalDependencies.ts b/workflow-recipes/src/reconciler/internalDependencies.tsindex 8077247ee..ed191ea83 100644--- a/workflow-recipes/src/reconciler/internalDependencies.ts+++ b/workflow-recipes/src/reconciler/internalDependencies.ts@@ -1,3 +1,4 @@+import { scanTemplateReferences } from '@clerum/workflow-runtime-core'import type { EgressBindingDef, WorkflowRecipeCRD, WorkloadDef } from '../types'import { parseClusterLocalFqdn, resolveWorkloadRuntimeResourceName } from './resourceBuilder'@@ -48,7 +49,6 @@ interface ClusterLocalHostReference {const CLUSTER_LOCAL_HOST_REFERENCE_RE =/([a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.svc\.cluster\.local\.?)(?::([0-9]{1,5}))?/gi-const UNRESOLVED_WORKLOAD_TEMPLATE_RE = /\{\{\s*([^}:]+)\s*:\s*(host|port)\s*\}\}/gfunction isStdioTransport(workload: WorkloadDef): boolean {return workload.transport?.type === 'stdio'@@ -81,12 +81,25 @@ function extractClusterLocalHostReferences(value: string): ClusterLocalHostRefer}))}-function extractUnresolvedWorkloadTemplateReferences(+export function extractUnresolvedWorkloadTemplateReferences(value: string): Array<{ workloadId: string; field: string }> {- return [...value.matchAll(UNRESOLVED_WORKLOAD_TEMPLATE_RE)]- .map(match => ({ workloadId: match[1].trim(), field: match[2] }))- .filter(ref => Boolean(ref.workloadId))+ const refs: Array<{ workloadId: string; field: string }> = []+ for (const { body } of scanTemplateReferences(value)) {+ const colon = body.lastIndexOf(':')+ if (colon <= 0) continue+ const field = body.slice(colon + 1).trim()+ if (field !== 'host' && field !== 'port') continue+ // The legacy workload-only syntax forbids colons in the identifier. If an+ // outer opening fails that rule, it can still match a later nested opening.+ const previousColon = body.lastIndexOf(':', colon - 1)+ const nestedOpening = previousColon === -1 ? -1 : body.indexOf('{{', previousColon + 1)+ if (previousColon !== -1 && (nestedOpening === -1 || nestedOpening >= colon)) continue+ const start = previousColon === -1 ? 0 : nestedOpening + 2+ const workloadId = body.slice(start, colon).trim()+ if (workloadId) refs.push({ workloadId, field })+ }+ return refs}function dependencyKey(dep: Omit<InternalDependency, 'fields'>): string {diff --git a/workflow-recipes/src/reconciler/templateEngine.test.ts b/workflow-recipes/src/reconciler/templateEngine.test.tsindex af01fda5d..43cc86894 100644--- a/workflow-recipes/src/reconciler/templateEngine.test.ts+++ b/workflow-recipes/src/reconciler/templateEngine.test.ts@@ -1,4 +1,5 @@import { describe, expect, it } from 'vitest'+import { spawnSync } from 'node:child_process'import {type TemplateContext,TemplateInjectionError,@@ -23,6 +24,38 @@ function makeContext(overrides: Partial<TemplateContext> = {}): TemplateContext}describe('templateEngine.resolve', () => {+ it('CodeQL 427 bounds malformed template scanning', () => {+ if (process.env.TEMPLATE_REDOS_CHILD === '1') {+ const value = '{{{{|'.repeat(200_000)+ process.stdout.write('TEMPLATE_SCAN_STARTED\n')+ expect(resolve(value, makeContext())).toBe(value)+ return+ }+ const child = spawnSync(+ process.execPath,+ [+ 'node_modules/vitest/vitest.mjs',+ 'run',+ 'src/reconciler/templateEngine.test.ts',+ '--pool=threads',+ '--maxWorkers=1',+ '-t',+ 'CodeQL 427 bounds malformed template scanning',+ ],+ {+ env: { ...process.env, TEMPLATE_REDOS_CHILD: '1' },+ encoding: 'utf8',+ timeout: 15_000,+ killSignal: 'SIGKILL',+ }+ )+ expect(child.stdout).toContain('TEMPLATE_SCAN_STARTED')+ expect(+ child.error,+ 'interpolation must finish within the generous CPU deadline'+ ).toBeUndefined()+ expect(child.status, child.stdout + child.stderr).toBe(0)+ }, 20_000)// ─── Basic Syntax (2.6a-e) ─────────────────────────────────────────it('should resolve inputs.name (2.6a)', () => {@@ -129,3 +162,16 @@ describe('templateEngine.resolve', () => {expect(() => resolve('{{inputs.name}}', { inputs: undefined })).toThrow(UnresolvedTemplateError)})})++describe('template delimiter consumer semantics', () => {+ it('preserves literal backslashes, adjacent references and malformed delimiters', () => {+ expect(resolve('before\\{{ inputs.name }}{{db:port}}after', makeContext())).toBe(+ 'before\\redis5432after'+ )+ for (const value of ['plain', '{{', '{{}}', '{{inputs.name}', '{{inputs.name}x}}']) {+ expect(resolve(value, makeContext())).toBe(value)+ }+ expect(() => resolve('{{ }}', makeContext())).toThrow(UnresolvedTemplateError)+ expect(() => resolve('{{{{inputs.name}}', makeContext())).toThrow(UnresolvedTemplateError)+ })+})diff --git a/workflow-recipes/src/reconciler/templateEngine.ts b/workflow-recipes/src/reconciler/templateEngine.tsindex 5d2c719e8..1a6702d9f 100644--- a/workflow-recipes/src/reconciler/templateEngine.ts+++ b/workflow-recipes/src/reconciler/templateEngine.ts@@ -1,3 +1,5 @@+import { replaceTemplateReferences } from '@clerum/workflow-runtime-core'+/*** Custom error for unresolved template references.*/@@ -50,7 +52,7 @@ export interface TemplateContext {* - {{computed.name}} → computed value*/export function resolve(template: string, context: TemplateContext): string {- return template.replace(/\{\{([^}]+)\}\}/g, (_match, ref: string) => {+ return replaceTemplateReferences(template, (ref: string) => {const trimmed = ref.trim()// Check for injection attempts