diff --git a/packages/core/src/context.ts b/packages/core/src/context.ts index a682e6794c..1c106bc23f 100644 --- a/packages/core/src/context.ts +++ b/packages/core/src/context.ts @@ -35,6 +35,12 @@ export const composeContext = ({ template: string; templatingEngine?: "handlebars"; }) => { + + // Sanitize the template by only allowing specific patterns + if (!/^[^{]*{{[\s\w]+}}[^}]*$/.test(template)) { + throw new Error("Invalid template format. Only simple variable substitutions are allowed."); + } + if (templatingEngine === "handlebars") { const templateFunction = handlebars.compile(template); return templateFunction(state);