# llm05-output-to-html

> llm05-output-to-html: 4 Keryn rules for javascript, typescript, generic (4 warning).

Source: https://keryn.dev/rules/llm05-output-to-html/

4 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do 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.react-dangerously-set-inner-html

`warning` javascript, typescript react

Model-controlled, retrieved, or tool-controlled content may be rendered through dangerouslySetInnerHTML. Confirm whether the source is trusted and sanitized.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-79](https://keryn.dev/taxonomies/cwe/#cwe-79-cross-site-scripting) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution)

**Fix:** Render untrusted output as React text children. If rich HTML is required, pass it through a maintained HTML sanitizer before assigning it to dangerouslySetInnerHTML.

**References:** [https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html](https://react.dev/reference/react-dom/components/common#dangerously-setting-the-inner-html)

Also reported under the older id `seceng.react.ai-dangerously-set-inner-html`.

## seceng.llm05.inner-html-assignment

`warning` javascript, typescript llm05-output-to-html

Assignment to innerHTML or outerHTML may render model, retrieved, or tool output as executable HTML. Confirm sanitizer use and source trust.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another; it crosses the [`model->code`](https://keryn.dev/docs/edges/trust-boundaries/#model-to-code) boundary (model output reaching code, a shell, a query or a page).

[CWE-79](https://keryn.dev/taxonomies/cwe/#cwe-79-cross-site-scripting) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution)

**Fix:** Use textContent for plain text. If rich HTML is required, sanitize it before assigning it to innerHTML or outerHTML.

**References:** [https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security_considerations](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML#security_considerations)

## seceng.llm05.marked-html-enabled

`warning` javascript, typescript llm05-output-to-html

Markdown rendering appears to allow raw HTML. If model or retrieved content reaches this renderer, this can become XSS.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [writes](https://keryn.dev/docs/edges/edge-kinds/#writes) one thing writes to another.

[CWE-79](https://keryn.dev/taxonomies/cwe/#cwe-79-cross-site-scripting) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning)

**Fix:** Sanitize the HTML produced by Marked before inserting it into the document. Apply the sanitizer after Markdown rendering so it also checks the markup emitted by the renderer.

**References:** [https://marked.js.org/#usage](https://marked.js.org/#usage)

## seceng.llm05.vue-v-html

`warning` generic llm05-output-to-html

Vue v-html renders raw HTML. Confirm model, retrieved, or tool output cannot reach this sink without sanitization.

Confidence **P1**: dangerous in context. False-positive risk **high**: it finds a lead to confirm, so expect benign hits.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another.

[CWE-79](https://keryn.dev/taxonomies/cwe/#cwe-79-cross-site-scripting) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution)

**Fix:** Render untrusted output with Vue text interpolation. If rich HTML is required, sanitize it before passing it to v-html.

**References:** [https://vuejs.org/guide/best-practices/security.html#html-injection](https://vuejs.org/guide/best-practices/security.html#html-injection)
