# llm02-sensitive-prompt-trace-logging

> llm02-sensitive-prompt-trace-logging: 5 Keryn rules for javascript, typescript, python, rust (4 warning, 1 info).

Source: https://keryn.dev/rules/llm02-sensitive-prompt-trace-logging/

5 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.llm02.prompt-message-logging

`warning` javascript, typescript, python llm02-sensitive-prompt-trace-logging

Prompt, messages, retrieved context, or tool result appears to be logged. Confirm redaction and access controls.

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

Edge inspected: [sends](https://keryn.dev/docs/edges/edge-kinds/#sends) data leaves for another party; it crosses the [`secret->outside`](https://keryn.dev/docs/edges/trust-boundaries/#secret-to-outside) boundary (a secret leaving the trusted side).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM07](https://keryn.dev/taxonomies/owasp-llm/#llm07-system-prompt-leakage) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `src/chat.js` and scan it with `keryn scan src --verbose`; the finding below appears.

```js
import OpenAI from "openai";

const client = new OpenAI();

export async function reply(messages) {
  console.log(messages);
  const out = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages,
  });
  return out.choices[0].message.content;
}
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.llm02.prompt-message-logging` at line 6 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.llm02.prompt-message-logging-rust

`warning` rust llm02-sensitive-prompt-trace-logging

Prompt, messages, retrieved context, or tool result appears to be logged. Confirm redaction and access controls.

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

Edge inspected: [sends](https://keryn.dev/docs/edges/edge-kinds/#sends) data leaves for another party; it crosses the [`secret->outside`](https://keryn.dev/docs/edges/trust-boundaries/#secret-to-outside) boundary (a secret leaving the trusted side).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM07](https://keryn.dev/taxonomies/owasp-llm/#llm07-system-prompt-leakage) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning) [ASI02](https://keryn.dev/taxonomies/owasp-agentic/#asi02-tool-misuse-and-exploitation)

## seceng.llm02.authorization-header-logging

`warning` javascript, typescript, python llm02-sensitive-prompt-trace-logging

Authorization headers or request headers may be logged. Confirm secrets are redacted.

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

Edge inspected: [grants](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

**Try it: a snippet that triggers this rule**

Written for this page, not taken from any project. Save it as `server/middleware.js` and scan it with `keryn scan server --verbose`; the finding below appears.

```js
const express = require("express");
const logger = require("./logger");

const app = express();

app.use((req, res, next) => {
  logger.info(req.headers);
  next();
});

app.get("/health", (req, res) => res.json({ ok: true }));

module.exports = app;
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.llm02.authorization-header-logging` at line 7 (warning, proof 1). The rule's own logic is not published, so it cannot run in this tab; the pack list in the [playground](https://keryn.dev/playground/) shows what does.

## seceng.llm02.authorization-header-logging-rust

`warning` rust llm02-sensitive-prompt-trace-logging

Authorization headers or request headers may be logged. Confirm secrets are redacted.

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

Edge inspected: [sends](https://keryn.dev/docs/edges/edge-kinds/#sends) data leaves for another party; it crosses the [`secret->outside`](https://keryn.dev/docs/edges/trust-boundaries/#secret-to-outside) boundary (a secret leaving the trusted side).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [ASI03](https://keryn.dev/taxonomies/owasp-agentic/#asi03-identity-and-privilege-abuse)

## seceng.llm02-system-prompt-in-client

`info` javascript, typescript, python llm02-sensitive-prompt-trace-logging

System or developer prompt string appears in source. Confirm this is not bundled client-side or exposed through debug output.

Confidence **P0**: exploitable as written. False-positive risk **high**: it finds a lead to confirm, so expect benign hits.

Edge inspected: [reaches](https://keryn.dev/docs/edges/edge-kinds/#reaches) content or traffic gets to a thing; it crosses the [`user->prompt`](https://keryn.dev/docs/edges/trust-boundaries/#user-to-prompt) boundary (untrusted input reaching a prompt).

[CWE-200](https://keryn.dev/taxonomies/cwe/#cwe-200-exposure-of-sensitive-information-to-an-unauthorized-actor) [LLM02](https://keryn.dev/taxonomies/owasp-llm/#llm02-sensitive-information-disclosure) [LLM07](https://keryn.dev/taxonomies/owasp-llm/#llm07-system-prompt-leakage) [ASI01](https://keryn.dev/taxonomies/owasp-agentic/#asi01-agent-goal-hijack)
