Skip to content

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

    llm03-supply-chain-hardening-v2

    View as Markdown

    9 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.

    seceng.llm03.transformers-unpinned-revision-contextual

    Section titled “seceng.llm03.transformers-unpinned-revision-contextual”

    warning python huggingface

    HuggingFace or Transformers model is loaded without a pinned revision. Remote model weights can change without review.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-829 CWE-494 LLM03 ASI04

    Also reported under the older id seceng.llm03.transformers-unpinned-revision.

    seceng.llm03.trust-remote-code-without-revision

    Section titled “seceng.llm03.trust-remote-code-without-revision”

    warning python llm03-supply-chain-hardening

    Model loading enables trust_remote_code=True without a pinned revision. This can execute attacker-controlled model repository code.

    Confidence 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.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-94 CWE-829 LLM03 ASI05 ASI04

    Also reported under the older id seceng.modelintegrity.trust-remote-code-without-revision.

    warning python llm03-supply-chain-hardening

    Model artifact is loaded with pickle-backed deserialization without weights_only=True or safetensors. This can enable arbitrary code execution.

    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: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM03 ASI05 ASI04

    seceng.llm03.unsafe-model-file-extension-load

    Section titled “seceng.llm03.unsafe-model-file-extension-load”

    warning python browser-extension

    Pickle-like model artifact extension is loaded dynamically. Validate provenance and prefer safetensors or pinned immutable artifacts.

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

    Edge inspected: depends_on something relies on a component it does not verify.

    CWE-502 LLM03 ASI04

    Try it: a snippet that triggers this rule

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

    ml/serve.py
    import torch
    from .net import Classifier
    def load_classifier():
    model = Classifier(hidden=256)
    state = torch.load("checkpoints/classifier-final.pt", map_location="cpu")
    model.load_state_dict(state)
    model.eval()
    return model

    Checked with Keryn’s browser engine when this page was built: it reports seceng.llm03.unsafe-model-file-extension-load at line 8 (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.llm03.huggingface-hardcoded-token-login

    Section titled “seceng.llm03.huggingface-hardcoded-token-login”

    warning python huggingface

    Hardcoded HuggingFace token is passed to login(). This can expose model registry privileges and enable supply-chain compromise.

    Confidence 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.

    Edge inspected: grants authority is given or left unchecked.

    CWE-798 CWE-522 LLM03 ASI03

    Try it: a snippet that triggers this rule

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

    ml/hub_setup.py
    from huggingface_hub import login, snapshot_download
    def prepare(repo="acme-labs/tiny-classifier"):
    login(token="hf_EXAMPLEnotARealToken0000")
    return snapshot_download(repo_id=repo, local_dir="./models")

    Checked with Keryn’s browser engine when this page was built: it reports seceng.llm03.huggingface-hardcoded-token-login at line 5 (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 python llm03-supply-chain-hardening

    Application installs packages at runtime. This can enable dependency confusion, arbitrary package execution, or model pipeline compromise.

    Confidence P2: a heuristic or a posture check: confirm by reading the code. False-positive risk medium: the pattern is legitimate in many programs, so check each hit.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-829 LLM03 ASI04

    seceng.llm03.embedding-http-transport-contextual

    Section titled “seceng.llm03.embedding-http-transport-contextual”

    warning python, javascript, typescript llm03-supply-chain-hardening

    Non-TLS HTTP transport is configured for a model, embedding, vector, or AI provider endpoint. Sensitive prompts or embeddings may traverse plaintext.

    Confidence 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.

    Edge inspected: depends_on something relies on a component it does not verify.

    CWE-319 LLM03 LLM08 ASI06 ASI04

    seceng.llm03.remote-model-url-without-integrity

    Section titled “seceng.llm03.remote-model-url-without-integrity”

    warning python, javascript, typescript llm03-supply-chain-hardening

    Remote model or checkpoint URL is downloaded without visible checksum or signature verification.

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

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-494 LLM03 ASI04 ASI06

    Try it: a snippet that triggers this rule

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

    ml/fetch_weights.py
    import requests
    MODEL_URL = "https://downloads.example.org/models/sentiment-v3.safetensors"
    def download(dest="sentiment.safetensors"):
    r = requests.get(MODEL_URL, timeout=60)
    r.raise_for_status()
    with open(dest, "wb") as fh:
    fh.write(r.content)
    return dest

    Checked with Keryn’s browser engine when this page was built: it reports seceng.llm03.remote-model-url-without-integrity at line 7 (warning, proof 0). 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.llm03.modelscan-missing-before-load

    Section titled “seceng.llm03.modelscan-missing-before-load”

    info python llm03-supply-chain-hardening

    Model artifact is loaded without a visible model-scan or safetensors verification step in the surrounding code.

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

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-693 LLM03 ASI04