Skip to content

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

    gateway-credential-passthrough-v1

    View as Markdown

    3 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 javascript, typescript gateway-credential-passthrough

    An upstream API key or credential variable appears to be serialized into a gateway response. Gateway responses must never include raw provider keys — use virtual/project keys for callers instead.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.

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

    CWE-312 CWE-200 CWE-532 LLM02 ASI03

    warning python gateway-credential-passthrough

    An upstream API key from environment variables may appear in a Python API response body. Strip or mask credentials before returning any gateway response.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk high: it finds a lead to confirm, so expect benign hits.

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

    CWE-312 CWE-200 LLM02 ASI03

    Try it: a snippet that triggers this rule

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

    gateway/routes.py
    import json
    import os
    from flask import Flask, Response
    app = Flask(__name__)
    UPSTREAM = "https://llm.internal.example/v1"
    @app.get("/debug/upstream")
    def upstream_info():
    api_key = os.environ.get("OPENAI_API_KEY", "")
    api_key_view = json.dumps({"upstream": UPSTREAM, "key": api_key})
    return Response(api_key_view, mimetype="application/json")

    Checked with Keryn’s browser engine when this page was built: it reports seceng.gateway.python-key-in-response at line 12 (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.

    warning javascript, typescript, python gateway-credential-passthrough

    Logging statement may capture a raw API key variable. Redact credentials before any log call.

    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-532 CWE-312 LLM02 LLM05 ASI03

    Try it: a snippet that triggers this rule

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

    gateway/proxy.py
    import logging
    import os
    logger = logging.getLogger("gateway")
    def build_headers():
    api_key = os.environ["UPSTREAM_API_KEY"]
    logger.info("forwarding with api_key=%s", api_key)
    return {"Authorization": f"Bearer {api_key}", "Accept": "application/json"}

    Checked with Keryn’s browser engine when this page was built: it reports seceng.gateway.log-contains-api-key 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.