llm-output-taint-js-v1
25 rules · Keryn Software Licence · rules 0.8.0 · all packs
How to read a rule
- Severity
- How bad the finding is if it is real:
errorfails a default gate,warningandinfodo not. - Confidence
- P0 exploitable as written; P1 dangerous in context; P2 a heuristic or a posture check: confirm by reading the code.
- False-positive risk
- low: an exact API or flag, so hits are almost always real; medium: the pattern is legitimate in many programs, so check each hit; high: it finds a lead to confirm, so expect benign hits.
- Edge
- The relationship the finding sits on. reaches: content or traffic gets to a thing; calls: one thing invokes another; reads: one thing reads from another; writes: one thing writes to another; sends: data leaves for another party; grants: authority is given or left unchecked; depends_on: something relies on a component it does not verify; trusts: one party believes another without evidence. The boundary it crosses, when there is one: user->prompt (untrusted input reaching a prompt); model->code (model output reaching code, a shell, a query or a page); secret->outside (a secret leaving the trusted side); supply-chain (code, models or prompts pulled in from outside).
- Taxonomy chips
- References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.
seceng.llm05.taint.model-output-to-eval-js
Section titled “seceng.llm05.taint.model-output-to-eval-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node
Model output (completion text, tool-call arguments or tool execute input) reaches a JavaScript code-execution sink (eval, Function, vm, string timers, eval Worker, vm2). A prompt-injected response becomes code running with the server’s privileges; interpret a fixed, allow-listed operation instead of executing generated code, or run it in an isolated sandbox process.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Never evaluate model output as code. Map the model’s answer onto a fixed set of operations (validate it with a z.enum/allow-list) and execute those yourself. If generated code must run, run it in a separate, network-less, resource-limited sandbox (container, isolate service), not node:vm, which is not a security boundary.
References: https://developers.openai.com/api/reference/resources/chat · https://platform.claude.com/docs/en/api/messages · https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text · https://nodejs.org/api/vm.html · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/transform.js and scan it with keryn scan src --verbose; the finding below appears.
import OpenAI from "openai";
const client = new OpenAI();
export async function transformRows(rows, instruction) { const response = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [ { role: "system", content: "Write the body of a JavaScript function taking `rows`." }, { role: "user", content: instruction }, ], }); const body = response.choices[0].message.content; const fn = new Function("rows", body); return fn(rows);}Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-eval-js at line 14 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-child-process-js
Section titled “seceng.llm05.taint.model-output-to-child-process-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node, execa
Model output reaches a child-process command (exec/execSync, spawn/execFile command or argv with shell:true, execa/execaCommand, Bun.spawn, Deno.Command). Prompt injection turns this into OS command execution; allow-list the program, pass a fixed argv without a shell, and quote arguments with shell-quote if a shell is unavoidable.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Do not build command strings from model output. Choose the executable from a constant allow-list, pass model-chosen values as separate argv entries to execFile/spawn without shell: true, validate them with a zod enum or regex, and require human approval for state-changing commands. If a shell string is unavoidable, quote every model-derived token with shell-quote’s quote().
References: https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://developers.openai.com/api/docs/guides/function-calling · https://nodejs.org/api/child_process.html · https://github.com/sindresorhus/execa · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/gitAssistant.js and scan it with keryn scan src --verbose; the finding below appears.
import { execSync } from "node:child_process";import OpenAI from "openai";
const client = new OpenAI();
export async function applyGitSuggestion(task, cwd) { const completion = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [ { role: "system", content: "Answer with a single git command." }, { role: "user", content: task }, ], }); const suggestion = completion.choices[0].message.content ?? ""; return execSync(suggestion, { cwd, encoding: "utf8" });}Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-child-process-js at line 15 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-shell-quote-missing-js
Section titled “seceng.llm05.taint.model-output-to-shell-quote-missing-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node, shelljs, shell-quote
Model output is placed inside a script string that a shell parses (sh -c, bash -c, cmd /c, powershell -Command, shelljs shell.exec) without shell-quote. Metacharacters in a prompt-injected value (;, $( ), backticks) run arbitrary commands; quote every model-derived token with shell-quote’s quote() or drop the shell and pass argv directly.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-78 CWE-88 LLM05 ASI05 ASI02
Fix: Avoid -c script strings entirely: call the target program with execFile/spawn and an argv array. Where a shell pipeline is required, build it from constants and insert model-derived values only through shell-quote’s quote([value]) (or an equivalent escaper), after validating them against an allow-list.
References: https://github.com/ljharb/shell-quote · https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows · https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-mcp-stdio-command-js
Section titled “seceng.llm05.taint.model-output-to-mcp-stdio-command-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, mcp
Model output chooses the command or arguments of an MCP stdio server launch (StdioClientTransport, Experimental_StdioMCPTransport, MultiServerMCPClient). The client spawns that process locally, so a prompt-injected server definition is arbitrary command execution; launch only servers from a reviewed, pinned allow-list.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-78 CWE-829 LLM05 ASI05 ASI04
Fix: Never let a model or a model-produced config pick which local MCP server binary to run. Resolve server names to a constant table of reviewed command/args pairs (pinned package versions), validate the model’s choice with a z.enum or allow-list, and require human approval before adding a new server.
References: https://modelcontextprotocol.io/docs/develop/build-client · https://github.com/modelcontextprotocol/typescript-sdk · https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-require-import-js
Section titled “seceng.llm05.taint.model-output-to-require-import-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node
Model output is used as a module specifier for require(), dynamic import(), createRequire or new Worker(path). An injected specifier loads attacker-chosen code (a local file, data: URL or installed package); map the model’s choice onto a constant table of modules instead.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Keep module loading static. If the model selects a plugin or handler, validate the name against an allow-list (or z.enum) and look it up in a constant object of already-imported modules; never pass model output to require/import/Worker.
References: https://nodejs.org/api/esm.html#import-expressions · https://nodejs.org/api/modules.html#requireid · https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-template-engine-js
Section titled “seceng.llm05.taint.model-output-to-template-engine-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, ejs, handlebars, pug, lodash, nunjucks
Model output is compiled as a server-side template (ejs, Handlebars, pug, lodash _.template, nunjucks/eta renderString, doT, liquidjs). Template syntax in a prompt-injected response executes code on the server (SSTI); keep templates static and pass model output only as template data.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Load templates from files you control and pass the model output as a context variable (escaped by the engine). If users or models must choose a template, select it by name from an allow-list; never compile generated template source.
References: https://ejs.co/#docs · https://handlebarsjs.com/api-reference/compilation.html · https://lodash.com/docs/#template · https://mozilla.github.io/nunjucks/api.html#renderstring · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-browser-eval-js
Section titled “seceng.llm05.taint.model-output-to-browser-eval-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, puppeteer, playwright, chrome-extension
Model output is executed as script in an automated or extension-controlled browser (Puppeteer/Playwright evaluate, addScriptTag, addInitScript, setContent, $eval; chrome.tabs.executeScript code). The browser often holds authenticated sessions, so injected script acts as the user; pass a fixed function and send model output only as its serialised argument.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-94 CWE-79 LLM05 ASI05 ASI02
Fix: Call page.evaluate with a function literal you wrote and pass model data as an argument (page.evaluate((q) => ..., value)), never a string. Do not inject model output via addScriptTag/addInitScript/setContent; for browser agents, restrict actions to a typed command set validated with zod.
References: https://pptr.dev/api/puppeteer.page.evaluate · https://playwright.dev/docs/evaluating · https://developer.chrome.com/docs/extensions/reference/api/scripting · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-sql-js
Section titled “seceng.llm05.taint.model-output-to-sql-js”error javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, prisma, knex, drizzle, pg, mysql2, sequelize, better-sqlite3
Model output is concatenated into a raw SQL string ($queryRawUnsafe/$executeRawUnsafe, knex.raw/whereRaw, drizzle sql.raw, pg/mysql2 query or execute, postgres.js unsafe, Sequelize literal/query, better-sqlite3 prepare/exec). A prompt-injected value rewrites the query; use bound parameters ($1/?) or Prisma.sql/knex bindings instead.
Confidence P0: exploitable as written. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Pass model-derived values only as bound parameters (client.query("... $1", [value]), Prisma tagged $queryRaw, knex ? bindings, drizzle sql template). Text-to-SQL agents must run on a read-only, least-privilege connection with an allow-listed table set; identifiers chosen by the model must come from an allow-list.
References: https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/raw-queries · https://knexjs.org/guide/raw.html · https://orm.drizzle.team/docs/sql · https://node-postgres.com/features/queries · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/db/ask.js and scan it with keryn scan src --verbose; the finding below appears.
import OpenAI from "openai";import { Pool } from "pg";
const openai = new OpenAI();const pool = new Pool({ connectionString: process.env.DATABASE_URL });
export async function askOrders(question) { const res = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [ { role: "system", content: "Return one read-only PostgreSQL query for the orders table." }, { role: "user", content: question }, ], }); const query = res.choices[0].message.content.trim(); const { rows } = await pool.query(query); return rows;}Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-sql-js at line 16 (error, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-nosql-js
Section titled “seceng.llm05.taint.model-output-to-nosql-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, mongodb, mongoose
Model output (parsed JSON, generateObject result or tool-call arguments) is used as a MongoDB/Mongoose filter, update document or $where. Injected operators such as $ne, $regex, $where or $set widen the query or rewrite records; build the filter from typed, coerced fields.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Never pass a model-produced object straight to the driver. Build the filter yourself from scalar fields coerced with String()/Number()/new ObjectId(), validate with a zod schema that rejects $-prefixed keys, enable Mongoose sanitizeFilter, or strip operators with mongo-sanitize.
References: https://www.mongodb.com/docs/drivers/node/current/crud/query/retrieve/ · https://mongoosejs.com/docs/api/query.html#Query.prototype.sanitizeFilter() · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-url-fetch-js
Section titled “seceng.llm05.taint.model-output-to-url-fetch-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node, axios, got, undici
Model output becomes the URL of a server-side HTTP request (fetch, axios, got, undici, ky, http/https, WebSocket, page.goto). A prompt-injected URL reaches internal services or cloud metadata endpoints (SSRF) or exfiltrates data in the query string; parse with new URL() and allow-list the hostname first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Parse the model-supplied URL with new URL(), require https, check url.hostname against a constant allow-list, and send the request through an egress proxy that blocks private and link-local ranges. When only a path segment is model-controlled, keep the origin constant and encode the segment with encodeURIComponent.
References: https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname · https://axios.rest/pages/advanced/api-reference · https://undici.nodejs.org/#/docs/api/Dispatcher · https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/enrich.js and scan it with keryn scan src --verbose; the finding below appears.
import OpenAI from "openai";
const client = new OpenAI();
export async function fetchCompanyProfile(company) { const r = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: `Give the main website URL for ${company}. URL only.` }], }); const url = r.choices[0].message.content.trim(); const page = await fetch(url); return page.text();}Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-url-fetch-js at line 11 (warning, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-fs-path-js
Section titled “seceng.llm05.taint.model-output-to-fs-path-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node, express
Model output forms a filesystem path (fs read/write/unlink/rm/createReadStream, path.join segment, res.sendFile/download, Bun.file, Deno file APIs). ../ or absolute paths in a prompt-injected value read secrets or overwrite files outside the intended directory; resolve the path and check it stays under the root.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Resolve with path.resolve(ROOT, value) and refuse unless the result startsWith(ROOT + path.sep), or reduce the value to path.basename(). Prefer identifiers that map to stored paths over model-chosen paths, and give file tools a dedicated, least-privilege working directory.
References: https://nodejs.org/api/path.html#pathresolvepaths · https://nodejs.org/api/fs.html · https://expressjs.com/en/api/#res.sendFile · https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-html-dom-js
Section titled “seceng.llm05.taint.model-output-to-html-dom-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, dom
Model output is written into the DOM as HTML (innerHTML/outerHTML, insertAdjacentHTML, document.write, srcdoc, setHTMLUnsafe, createContextualFragment). Markup in a prompt-injected response runs script in the user’s session (XSS) or exfiltrates data through image URLs; sanitize with DOMPurify or render as text.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Render model text with textContent / createTextNode. When HTML or rendered markdown is required, pass it through DOMPurify.sanitize() (with a strict allow-list that drops remote images if exfiltration matters) immediately before insertion, or escape it with escape-html.
References: https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security_considerations · https://github.com/cure53/DOMPurify · https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-react-html-js
Section titled “seceng.llm05.taint.model-output-to-react-html-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, react, nextjs
Model output is rendered through React dangerouslySetInnerHTML (JSX attribute or createElement props). React’s escaping is bypassed, so prompt-injected markup executes as XSS in the chat UI; sanitize with DOMPurify or render the text as children.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Render model output as React children (escaped by default) or through a markdown renderer without raw-HTML support. If HTML is unavoidable, wrap the value in DOMPurify.sanitize() at the point of use.
References: https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html · https://github.com/cure53/DOMPurify · https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/components/Summary.tsx and scan it with keryn scan src --verbose; the finding below appears.
import OpenAI from "openai";
const client = new OpenAI();
export default async function Summary({ article }: { article: string }) { const response = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: `Summarize as HTML paragraphs: ${article}` }], }); const html = response.choices[0].message.content ?? "";
return <div className="summary" dangerouslySetInnerHTML={{ __html: html }} />;}Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-react-html-js at line 12 (warning, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-server-html-response-js
Section titled “seceng.llm05.taint.model-output-to-server-html-response-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, express, hono, nextjs, fastify
Model output is returned as an HTML response (Express res.send of a string, Hono c.html, Fetch new Response with text/html, res.type(“html”).send). Prompt-injected markup becomes XSS on your origin; escape or sanitize it, or return JSON.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Return model output as JSON (res.json) or text/plain, and let the client render it as text. If the server must emit HTML, escape the value with escape-html or sanitize it with DOMPurify/sanitize-html before interpolation.
References: https://expressjs.com/en/api/#res.send · https://hono.dev/docs/api/context#html · https://developer.mozilla.org/en-US/docs/Web/API/Response/Response · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-redirect-js
Section titled “seceng.llm05.taint.model-output-to-redirect-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, express, nextjs, dom
Model output decides a redirect or navigation target (res.redirect, Response/NextResponse.redirect, next/navigation redirect, router.push, window.location, location.assign/replace, window.open). A prompt-injected URL sends users to phishing pages, runs javascript: URLs or leaks data in the query string; allow-list the destination.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Map model choices to a constant table of routes, or parse with new URL() and require an allow-listed hostname/origin and an http(s) protocol before redirecting; encode model-derived parameters with encodeURIComponent.
References: https://expressjs.com/en/api/#res.redirect · https://nextjs.org/docs/app/api-reference/functions/redirect · https://developer.mozilla.org/en-US/docs/Web/API/Location/assign · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
Try it: a snippet that triggers this rule
Written for this page, not taken from any project. Save it as src/routes/next.js and scan it with keryn scan src --verbose; the finding below appears.
import express from "express";import OpenAI from "openai";
const app = express();const client = new OpenAI();
app.get("/help/go", async (req, res) => { const completion = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: `Which docs URL answers: ${req.query.q}` }], }); const target = completion.choices[0].message.content.trim(); res.redirect(target);});
export default app;Checked with Keryn’s browser engine when this page was built: it reports seceng.llm05.taint.model-output-to-redirect-js at line 13 (warning, proof 2). The rule’s own logic is not published, so it cannot run in this tab; the pack list in the playground shows what does.
seceng.llm05.taint.model-output-to-url-attribute-js
Section titled “seceng.llm05.taint.model-output-to-url-attribute-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, dom
Model output is assigned to a URL-bearing DOM property or attribute (src, href, action, formAction, setAttribute href/src/action/formaction/xlink:href). javascript: URLs execute script and remote src values exfiltrate conversation data; check the parsed protocol and host first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Parse the value with new URL(value, location.origin), allow only https: (and optionally a host allow-list), and assign url.href. Encode model-derived query parameters with encodeURIComponent.
References: https://developer.mozilla.org/en-US/docs/Web/API/URL/protocol · https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-process-env-js
Section titled “seceng.llm05.taint.model-output-to-process-env-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node
Model output is written into process.env or into the env of a spawned process. Model-chosen variables such as NODE_OPTIONS, LD_PRELOAD, PATH, HTTP_PROXY or credentials redirect code loading and traffic for the rest of the process; allow-list both names and values.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-15 CWE-454 LLM05 ASI05 ASI02
Fix: Do not mutate process.env from model output. Pass configuration explicitly; when a tool must set environment for a child process, build env from a constant allow-list of variable names with values validated by zod, and never forward NODE_OPTIONS, PATH, LD_* or proxy variables from the model.
References: https://nodejs.org/api/process.html#processenv · https://nodejs.org/api/cli.html#node_optionsoptions · https://nodejs.org/api/child_process.html#child_processspawncommand-args-options · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-regex-js
Section titled “seceng.llm05.taint.model-output-to-regex-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, node
Model output is compiled into a regular expression (new RegExp, String match/search/matchAll with a string pattern). A prompt-injected pattern causes catastrophic backtracking (ReDoS) that blocks the event loop, or widens a validation regex; escape the value or use a literal search.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Escape model-derived text with escape-string-regexp, lodash _.escapeRegExp or RegExp.escape before building a pattern, or use String.prototype.includes/indexOf for literal matching. If the model must author a pattern, run it with a linear-time engine (re2) and a timeout.
References: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp · https://github.com/sindresorhus/escape-string-regexp · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-prototype-pollution-js
Section titled “seceng.llm05.taint.model-output-to-prototype-pollution-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, lodash, deepmerge
Model-produced keys or objects are deep-merged or path-assigned (lodash merge/defaultsDeep/set/setWith, deepmerge, obj[a][b] = v). A __proto__ or constructor.prototype key in a prompt-injected JSON object pollutes Object.prototype for the whole process; validate the shape first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Parse model JSON with a strict zod object schema (unknown keys stripped) before merging, restrict path keys to an allow-list, and use Object.create(null) or Map for model-keyed stores.
References: https://lodash.com/docs/#merge · https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto · https://zod.dev/api#objects · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-dynamic-dispatch-js
Section titled “seceng.llm05.taint.model-output-to-dynamic-dispatch-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit
A model-chosen name selects which function or method to call (handlers[name](...), this[name](), globalThis[name]()). Without an own-property allow-list the model can invoke undeclared tools, inherited methods or globals; check the name against the declared tool set first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
Fix: Dispatch tool calls through a Map or a null-prototype object of declared tools and refuse names that fail Object.hasOwn(TOOLS, name) or an allow-list check (or z.enum of tool names) before invoking them.
References: https://developers.openai.com/api/docs/guides/function-calling · https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview · https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm05.taint.model-output-to-memory-write-js
Section titled “seceng.llm05.taint.model-output-to-memory-write-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, ollama, mastra, genkit, pinecone, chroma, langgraph, mem0
Model output is persisted into retrieval or long-term agent memory (vector store addDocuments/fromTexts, Pinecone/Chroma upsert/add, LangGraph store.put, mem0 memory.add). An injected instruction stored here is replayed into future prompts and other sessions (memory poisoning); validate and attribute it before writing.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-20 CWE-1287 LLM05 LLM08 ASI06
Fix: Validate model-generated memories with a zod schema (type, length, no instruction-like content), tag them with source, user and tenant metadata, keep them in a per-user namespace, and prefer storing user-confirmed facts over raw model output.
References: https://docs.langchain.com/oss/javascript/langchain/overview · https://docs.pinecone.io/reference/api/2026-07/data-plane/upsert · https://langchain-ai.github.io/langgraphjs/concepts/persistence/#memory-store · https://genai.owasp.org/llmrisk/llm052025-improper-output-handling/
seceng.llm01.taint.request-to-system-prompt-js
Section titled “seceng.llm01.taint.request-to-system-prompt-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, mastra, express, nextjs, hono
HTTP request data (Express req.body/query/params/headers, Next.js request.json()/searchParams/formData, Hono c.req) is interpolated into the system/developer prompt (role “system”, system: option, Anthropic system, instructions, SystemMessage, systemInstruction). The caller then writes the highest-priority instructions and can override every guardrail; keep user input in the user turn.
Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).
Fix: Keep the system prompt constant (or assembled only from server-side configuration). Put request data in a user message, clearly delimited, and if the caller may pick a persona or mode, validate the choice with z.enum / an allow-list and map it to a server-defined prompt.
References: https://developers.openai.com/api/docs/guides/text#message-roles-and-instruction-following · https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role · https://ai-sdk.dev/docs/foundations/prompts#system-prompts · https://genai.owasp.org/llmrisk/llm01-prompt-injection/
seceng.llm01.taint.retrieved-content-to-system-prompt-js
Section titled “seceng.llm01.taint.retrieved-content-to-system-prompt-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, mastra, mcp
Untrusted retrieved content (fetched web pages, axios/got responses, vector-store or retriever documents, loader output, browser page text, MCP tool results/resources) is placed in the system/developer prompt. Instructions hidden in that content gain system priority (indirect prompt injection); pass it as delimited data in a user or tool message instead.
Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.
Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).
CWE-77 CWE-1427 LLM01 ASI01 ASI06
Fix: Keep retrieved documents and tool output out of the system prompt. Insert them into a user or tool message wrapped in explicit delimiters with a note that they are untrusted data, strip or flag instruction-like text, and restrict which tools can run after untrusted content has been read.
References: https://developers.openai.com/api/docs/guides/text#message-roles-and-instruction-following · https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role · https://ai-sdk.dev/docs/foundations/prompts#system-prompts · https://genai.owasp.org/llmrisk/llm01-prompt-injection/ · https://docs.langchain.com/oss/javascript/langchain/overview
seceng.llm01.taint.model-output-to-system-prompt-js
Section titled “seceng.llm01.taint.model-output-to-system-prompt-js”warning javascript, typescript data-flow rule openai, anthropic, vercel-ai-sdk, langchain, google-genai, aws-bedrock, mastra
One model’s output (completion text, structured object or tool-call arguments) becomes the system/developer prompt of another model call or agent. A prompt-injected answer is promoted to top-priority instructions and propagates through the agent chain; pass it as a user/assistant message or validate it first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).
CWE-77 CWE-1427 LLM01 LLM05 ASI01 ASI07
Fix: Keep system prompts authored by you. When an orchestrator delegates to a sub-agent, select the sub-agent’s instructions from a constant table (validated with z.enum) and pass the orchestrator’s text as a user message.
References: https://developers.openai.com/api/docs/guides/text#message-roles-and-instruction-following · https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role · https://ai-sdk.dev/docs/foundations/prompts#system-prompts · https://genai.owasp.org/llmrisk/llm01-prompt-injection/
seceng.llm01.taint.tool-result-to-tool-args-js
Section titled “seceng.llm01.taint.tool-result-to-tool-args-js”warning javascript, typescript data-flow rule mcp, vercel-ai-sdk, langchain, mastra
The result of one tool call (MCP callTool/readResource output, a tool’s execute/invoke result) is fed directly as the name or arguments of another tool call. Content returned by an attacker-influenced tool then drives the next action without the model or user in the loop; validate it against the next tool’s schema first.
Confidence P1: dangerous in context. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.
Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).
CWE-20 CWE-74 LLM01 LLM06 ASI02 ASI01
Fix: Parse each tool result with the receiving tool’s zod schema (or an allow-list of tool names) before chaining, keep cross-tool chains declarative, and require human approval when untrusted tool output selects a state-changing tool.
References: https://modelcontextprotocol.io/docs/develop/build-client · https://modelcontextprotocol.io/specification/2025-06-18/server/tools · https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling · https://genai.owasp.org/llmrisk/llm01-prompt-injection/