Skip to content

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

    model-supply-chain-v1

    View as Markdown

    22 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 huggingface, transformers

    Hugging Face download pins revision= to a branch or tag name (e.g. “main”), which the repo owner can move at any time. Pin to the 40-character commit SHA instead.

    Confidence P1: dangerous in context. 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-829 CWE-494 LLM03 ASI04

    Fix: Resolve the reviewed commit once (huggingface_hub.HfApi().model_info(repo).sha) and pass that 40-hex SHA as revision=. Record it in config, bump it deliberately, and prefer safetensors weights with trust_remote_code left off.

    References: https://huggingface.co/docs/huggingface_hub/guides/download · https://huggingface.co/docs/transformers/main_classes/model

    seceng.modelsc.hf-from-pretrained-missing-revision

    Section titled “seceng.modelsc.hf-from-pretrained-missing-revision”

    warning python huggingface, transformers

    from_pretrained loads a Hub repo id with no revision=, so the weights resolve to whatever the default branch currently holds. Pin a reviewed 40-hex commit SHA.

    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

    Fix: Pass revision=<40-hex commit SHA> (and local_files_only=True in production once the snapshot is cached or baked into the image). Treat a repo-id literal without a pin as a floating dependency.

    References: https://huggingface.co/docs/huggingface_hub/guides/download · https://huggingface.co/docs/transformers/main_classes/model

    seceng.modelsc.hf-hub-download-missing-revision

    Section titled “seceng.modelsc.hf-hub-download-missing-revision”

    warning python huggingface

    hf_hub_download/snapshot_download fetches a repo with no revision=; the artifact floats with the default branch. Pin a 40-hex commit SHA.

    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

    Fix: Pass revision=<40-hex commit SHA>. For fully offline deploys download once in CI, verify, and bake the snapshot into the image or artifact store.

    References: https://huggingface.co/docs/huggingface_hub/guides/download

    seceng.modelsc.hf-inference-client-user-model

    Section titled “seceng.modelsc.hf-inference-client-user-model”

    error python data-flow rule huggingface, flask, fastapi

    Request-controlled value selects the model for huggingface_hub.InferenceClient. The model argument also accepts a URL, so callers can steer traffic (and your token) to an arbitrary endpoint or an unreviewed model. Map user choices to an allow-list of model ids.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-918 CWE-829 LLM03 ASI04 ASI03

    Fix: Never pass request data as model=. Keep a server-side dict of permitted model ids/endpoints, look the user’s choice up in it, and reject unknown keys. Do not attach a Hub token to requests whose destination the caller can choose.

    References: https://huggingface.co/docs/huggingface_hub/guides/inference

    Try it: a snippet that triggers this rule

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

    api/generate.py
    from fastapi import FastAPI
    from huggingface_hub import InferenceClient
    app = FastAPI()
    @app.post("/generate")
    def generate(model: str, prompt: str):
    client = InferenceClient(model=model)
    return {"text": client.text_generation(prompt, max_new_tokens=128)}

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.hf-inference-client-user-model at line 9 (error, proof 2). 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.modelsc.transformers-user-controlled-model-id

    Section titled “seceng.modelsc.transformers-user-controlled-model-id”

    error python data-flow rule huggingface, transformers, flask, fastapi

    Request-controlled value is used as the Hugging Face model id (pipeline, from_pretrained, hf_hub_download, snapshot_download). An attacker can load any public repo, including one with pickled weights or custom code. Resolve ids through a server-side allow-list.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-829 CWE-502 LLM03 ASI04 ASI05

    Fix: Do not forward user input as a repo id or path. Look the choice up in a fixed mapping of reviewed models pinned by commit SHA, keep trust_remote_code off, and load safetensors only.

    References: https://huggingface.co/docs/transformers/main_classes/pipelines · https://huggingface.co/docs/hub/security-pickle

    seceng.modelsc.model-file-user-controlled-path

    Section titled “seceng.modelsc.model-file-user-controlled-path”

    error python data-flow rule llama-cpp, gguf, safetensors, flask, fastapi

    Request-controlled path reaches a local model loader (llama_cpp.Llama, LlamaCpp, safetensors load, GGUFReader). Callers can point the server at arbitrary files on disk or at attacker-supplied weights. Resolve a model name through an allow-list inside a fixed models directory.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-22 CWE-73 LLM03 ASI04

    Fix: Accept a model key, not a path. Map it to a file under a fixed directory (resolve and verify the result stays inside it), and verify a pinned SHA-256 of the file before loading.

    References: https://llama-cpp-python.readthedocs.io/en/latest/api-reference/ · https://huggingface.co/docs/safetensors/index

    seceng.modelsc.langsmith-pull-prompt-unpinned

    Section titled “seceng.modelsc.langsmith-pull-prompt-unpinned”

    warning python langsmith, langchain

    pull_prompt("name") fetches the latest version of a LangSmith prompt. Anyone with write access to the prompt can change what your application sends to the model; pin name:commit_hash.

    Confidence P1: dangerous in context. 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-829 LLM03 LLM01 ASI04 ASI01

    Fix: Pull by commit: client.pull_prompt(“owner/name:<commit_hash>”). Promote new commits through review, and store the hash in configuration.

    References: https://docs.langchain.com/langsmith/manage-prompts-programmatically

    seceng.modelsc.langchain-hub-pull-literal-unpinned

    Section titled “seceng.modelsc.langchain-hub-pull-literal-unpinned”

    warning python langchain, langsmith

    hub.pull("owner/prompt") has no :commit suffix, so the newest published prompt is used. A prompt edit upstream changes your agent’s instructions without a code change; pin the commit hash.

    Confidence P1: dangerous in context. 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-829 LLM03 LLM01 ASI04 ASI01

    Fix: Use hub.pull(“owner/prompt:<commit_hash>”) and keep the hash in version control; review prompt diffs before bumping.

    References: https://docs.langchain.com/oss/python/langchain/overview · https://docs.langchain.com/langsmith/manage-prompts-programmatically

    Try it: a snippet that triggers this rule

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

    agent/prompts.py
    from langchain import hub
    from langchain_openai import ChatOpenAI
    llm = ChatOpenAI(model="gpt-4o-mini")
    def build_chain():
    prompt = hub.pull("acme-team/support-triage")
    return prompt | llm

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.langchain-hub-pull-literal-unpinned at line 8 (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.

    warning python ollama

    Ollama model is pulled as latest (explicitly or by omitting the tag). The tag is mutable, so a rebuilt image or a repulled model can silently change the weights. Pin an explicit tag, ideally a digest recorded at review time.

    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

    Fix: Pull name:&lt;specific-tag&gt; and record the resulting digest (ollama show –modelfile / /api/tags) in your deployment manifest; avoid pulling at request time.

    References: https://github.com/ollama/ollama/blob/main/docs/api.md#pull-a-model · https://github.com/ollama/ollama-python

    error python data-flow rule ollama, flask, fastapi

    Request-controlled value names the model passed to Ollama’s pull. Callers can make the server download arbitrary (including oversized or attacker-hosted host/ns/model) artifacts. Allow-list model names.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-829 CWE-770 LLM03 LLM10 ASI04

    Fix: Pull only models from a server-side allow-list, pinned to a tag. Do not expose model management (pull/create/copy) to end users.

    References: https://github.com/ollama/ollama/blob/main/docs/api.md#pull-a-model

    Try it: a snippet that triggers this rule

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

    api/models.py
    import ollama
    from fastapi import FastAPI
    app = FastAPI()
    @app.post("/models/pull")
    def pull_model(name: str):
    ollama.pull(name)
    return {"status": "pulled", "model": name}

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.ollama-pull-user-model at line 9 (error, proof 2). 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.modelsc.model-download-without-hash-check

    Section titled “seceng.modelsc.model-download-without-hash-check”

    warning python requests, gguf, llama-cpp

    Model weights (.gguf, .bin, .safetensors, .ckpt, …) are downloaded over HTTP in a function that never computes a digest. The file can be swapped upstream or in transit; verify a pinned SHA-256 before loading.

    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-494 CWE-345 LLM03 ASI04

    Fix: Hash the downloaded bytes with hashlib.sha256 and compare to a digest pinned in your repo (use hmac.compare_digest) before writing to the model directory or loading.

    References: https://docs.python.org/3/library/hashlib.html · https://huggingface.co/docs/hub/security

    seceng.modelsc.mcp-stdio-npx-unpinned-python

    Section titled “seceng.modelsc.mcp-stdio-npx-unpinned-python”

    warning python mcp, npm

    MCP stdio server is launched via npx -y &lt;package&gt; (or uvx) with no version, so every start executes whatever the registry currently serves as that package. Pin package@x.y.z (or an integrity-checked local install).

    Confidence P1: dangerous in context. 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-829 CWE-494 LLM03 ASI04 ASI02

    Fix: Pin the exact version (npx -y @scope/server@1.2.3, uvx pkg==1.2.3) or install it at build time from a lockfile and launch the local binary.

    References: https://modelcontextprotocol.io/specification/2026-07-28/basic/transports · https://docs.npmjs.com/cli/commands/npx

    seceng.modelsc.langchainjs-hub-pull-unpinned

    Section titled “seceng.modelsc.langchainjs-hub-pull-unpinned”

    warning typescript, javascript langchain, langsmith

    hub.pull("owner/prompt") (langchain/hub) has no :commit suffix, so the newest published prompt is used. Pin the commit hash.

    Confidence P1: dangerous in context. 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-829 LLM03 LLM01 ASI04 ASI01

    Fix: Use hub.pull(“owner/prompt:<commit_hash>”) and keep the hash in version control.

    References: https://docs.langchain.com/oss/javascript/langchain/overview

    error typescript, javascript data-flow rule ollama, express, nextjs

    Request-controlled value names the model passed to ollama.pull. Callers can make the server download arbitrary artifacts; allow-list model names and pin tags.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-829 CWE-770 LLM03 LLM10 ASI04

    Fix: Pull only models from a server-side allow-list pinned to a tag; do not expose model management to end users.

    References: https://github.com/ollama/ollama-js#pull

    seceng.modelsc.transformersjs-user-controlled-model-id

    Section titled “seceng.modelsc.transformersjs-user-controlled-model-id”

    error typescript, javascript data-flow rule transformers-js, huggingface, express, nextjs

    Request-controlled value is the model id for Transformers.js pipeline/from_pretrained, letting callers load any Hub repo. Resolve ids through an allow-list.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

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

    CWE-829 LLM03 ASI04

    Fix: Map user choices to a fixed list of reviewed model ids pinned with the revision option.

    References: https://huggingface.co/docs/transformers.js/api/pipelines

    Try it: a snippet that triggers this rule

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

    server/embed.js
    import express from "express";
    import { pipeline } from "@xenova/transformers";
    const app = express();
    app.use(express.json());
    app.post("/embed", async (req, res) => {
    const modelId = req.body.model;
    const extractor = await pipeline("feature-extraction", modelId);
    const out = await extractor(req.body.text, { pooling: "mean" });
    res.json({ dims: out.dims });
    });
    app.listen(3000);

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.transformersjs-user-controlled-model-id at line 9 (error, proof 2). 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 typescript, javascript mcp, npm

    MCP stdio server is launched via npx -y &lt;package&gt; with no version, so each start runs whatever the registry currently serves. Pin package@x.y.z.

    Confidence P1: dangerous in context. 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-829 CWE-494 LLM03 ASI04 ASI02

    Fix: Pin the exact version (npx -y @scope/server@1.2.3) or install from a lockfile at build time and run the local binary.

    References: https://modelcontextprotocol.io/specification/2026-07-28/basic/transports · https://docs.npmjs.com/cli/commands/npx

    seceng.modelsc.dockerfile-ai-server-base-image-floating

    Section titled “seceng.modelsc.dockerfile-ai-server-base-image-floating”

    warning dockerfile docker, vllm, ollama

    Dockerfile base image for an AI serving stack (vLLM, Ollama, TGI, Open WebUI, LiteLLM) uses :latest/:main/:nightly or no tag. The build is not reproducible and an upstream push changes what you ship. Pin a version tag or digest.

    Confidence P1: dangerous in context. 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-829 CWE-1357 LLM03 ASI04

    Fix: Use FROM image:<version>@sha256:<digest>; update via Renovate/Dependabot with review.

    References: https://docs.docker.com/build/building/best-practices/#pin-base-image-versions

    seceng.modelsc.dockerfile-pip-unpinned-agent-framework

    Section titled “seceng.modelsc.dockerfile-pip-unpinned-agent-framework”

    warning dockerfile docker, python, langchain, openai

    pip install in a Dockerfile installs an LLM/agent framework with no version specifier. Each rebuild pulls whatever is newest (including a hijacked or breaking release). Pin == versions or install from a hashed lockfile.

    Confidence P1: dangerous in context. 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-829 CWE-1357 LLM03 ASI04

    Fix: Install from a lockfile: pip install –require-hashes -r requirements.lock (pip-compile –generate-hashes / uv pip compile), or at minimum pin pkg==x.y.z.

    References: https://pip.pypa.io/en/stable/topics/secure-installs/

    seceng.modelsc.dockerfile-npx-npm-global-unpinned-mcp

    Section titled “seceng.modelsc.dockerfile-npx-npm-global-unpinned-mcp”

    warning dockerfile docker, mcp, npm

    Dockerfile runs an MCP server through npx -y or npm install -g without a version. The container fetches whatever the registry serves at build or start time. Pin package@x.y.z.

    Confidence P1: dangerous in context. 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-829 CWE-494 LLM03 ASI04 ASI02

    Fix: npm install -g @scope/server@1.2.3 at build time (ideally from a lockfile with integrity hashes), then run the installed binary rather than npx -y.

    References: https://docs.npmjs.com/cli/commands/npm-install · https://modelcontextprotocol.io/specification/2026-07-28/basic/transports

    seceng.modelsc.dockerfile-ollama-pull-latest

    Section titled “seceng.modelsc.dockerfile-ollama-pull-latest”

    warning dockerfile docker, ollama

    Dockerfile pulls an Ollama model with latest or no tag. The tag moves, so rebuilds ship different weights. Pin an explicit tag.

    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

    Fix: Use ollama pull name:&lt;specific-tag&gt; and record the digest in the image labels.

    References: https://docs.ollama.com/faq

    seceng.modelsc.compose-ai-image-latest-or-untagged

    Section titled “seceng.modelsc.compose-ai-image-latest-or-untagged”

    warning yaml docker-compose, kubernetes, vllm, ollama, litellm

    AI serving image (vLLM, Ollama, TGI, Open WebUI, LiteLLM) in compose/Kubernetes YAML uses :latest/:main/:nightly or no tag. Deployments are not reproducible and an upstream push changes the running code. Pin a version tag or digest.

    Confidence P1: dangerous in context. 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-829 CWE-1357 LLM03 ASI04

    Fix: Reference image:<version>@sha256:<digest>. Update through a reviewed bump (Renovate/Dependabot).

    References: https://docs.docker.com/reference/compose-file/services/#image · https://kubernetes.io/docs/concepts/containers/images/#image-names

    Try it: a snippet that triggers this rule

    Written for this page, not taken from any project. Save it as docker-compose.yml and scan it with keryn scan docker-compose.yml --verbose; the finding below appears.

    docker-compose.yml
    services:
    llm:
    image: ollama/ollama:latest
    ports:
    - "11434:11434"
    volumes:
    - ollama-data:/root/.ollama
    app:
    build: .
    environment:
    OLLAMA_HOST: http://llm:11434
    depends_on:
    - llm
    volumes:
    ollama-data: {}

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.compose-ai-image-latest-or-untagged at line 3 (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.modelsc.package-json-script-npx-unpinned-mcp

    Section titled “seceng.modelsc.package-json-script-npx-unpinned-mcp”

    warning json npm, mcp

    package.json script runs an MCP server with npx -y/npm i -g and no version. Each run executes whatever the registry currently serves. Pin package@x.y.z or add it to devDependencies with a lockfile.

    Confidence P1: dangerous in context. 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-829 CWE-494 LLM03 ASI04 ASI02

    Fix: Add the server to dependencies with an exact version, commit the lockfile, and invoke the local binary (npx –no-install server).

    References: https://docs.npmjs.com/cli/commands/npx · https://modelcontextprotocol.io/specification/2026-07-28/basic/transports

    Try it: a snippet that triggers this rule

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

    package.json
    {
    "name": "docs-assistant",
    "version": "0.4.1",
    "private": true,
    "scripts": {
    "build": "tsc -p .",
    "mcp:files": "npx -y @modelcontextprotocol/server-filesystem ./docs",
    "start": "node dist/index.js"
    },
    "dependencies": {
    "zod": "3.23.8"
    }
    }

    Checked with Keryn’s browser engine when this page was built: it reports seceng.modelsc.package-json-script-npx-unpinned-mcp 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 shows what does.