Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    llm07-system-prompt-leakage

    View as Markdown

    5 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: 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.

    warning python llm07-system-prompt-leakage

    Environment variable likely containing a system prompt is being returned in a response. This can lead to system prompt leakage.

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

    Edge inspected: sends data leaves for another party; it crosses the secret->outside boundary (a secret leaving the trusted side).

    CWE-200 LLM07 ASI01

    Try it: a snippet that triggers this rule

    Written for this page, not taken from any project. Save it as app/views.py and scan it with keryn scan app --verbose; the finding below appears.

    app/views.py
    import os
    from flask import Flask
    app = Flask(__name__)
    @app.get("/api/assistant")
    def assistant_info():
    return {"prompt": os.environ.get("ASSISTANT_SYSTEM_PROMPT"), "version": "2"}

    Checked with Keryn’s browser engine when this page was built: it reports seceng.llm07.env-var-prompt-in-response at line 9 (warning, proof 1). 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.llm07.env-var-prompt-in-response-js

    Section titled “seceng.llm07.env-var-prompt-in-response-js”

    warning javascript, typescript llm07-system-prompt-leakage

    Environment variable likely containing a system prompt is being returned in a response. This can lead to system prompt leakage.

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

    Edge inspected: sends data leaves for another party; it crosses the secret->outside boundary (a secret leaving the trusted side).

    CWE-200 LLM07 ASI01

    seceng.llm07.python-system-prompt-in-error

    Section titled “seceng.llm07.python-system-prompt-in-error”

    info python llm07-system-prompt-leakage

    System prompt or internal instructions appear to be included in an error message. This can leak sensitive steering instructions to attackers.

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

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-209 LLM07 ASI01

    info javascript, typescript llm07-system-prompt-leakage

    System prompt or internal instructions appear to be included in an error message. This can leak sensitive steering instructions to attackers.

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

    Edge inspected: reaches content or traffic gets to a thing; it crosses the user->prompt boundary (untrusted input reaching a prompt).

    CWE-209 LLM07 ASI01

    info python, javascript, typescript llm07-system-prompt-leakage

    System prompt appears to be logged. If logs are accessible or forwarded to insecure sinks, this is a leakage risk.

    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-532 LLM07 ASI01