# llm03-supply-chain-hardening-v2

> llm03-supply-chain-hardening-v2: 9 Keryn rules for python, javascript, typescript (8 warning, 1 info).

Source: https://keryn.dev/rules/llm03-supply-chain-hardening-v2/

9 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.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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-829](https://keryn.dev/taxonomies/cwe/#cwe-829-inclusion-of-functionality-from-untrusted-control-sphere) [CWE-494](https://keryn.dev/taxonomies/cwe/#cwe-494-download-of-code-without-integrity-check) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

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

## 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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-94](https://keryn.dev/taxonomies/cwe/#cwe-94-code-injection) [CWE-829](https://keryn.dev/taxonomies/cwe/#cwe-829-inclusion-of-functionality-from-untrusted-control-sphere) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

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

## seceng.llm03.unsafe-model-deserialization

`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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-502](https://keryn.dev/taxonomies/cwe/#cwe-502-deserialization-of-untrusted-data) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI05](https://keryn.dev/taxonomies/owasp-agentic/#asi05-unexpected-code-execution) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

## 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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify.

[CWE-502](https://keryn.dev/taxonomies/cwe/#cwe-502-deserialization-of-untrusted-data) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

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

```python
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](https://keryn.dev/playground/) shows what does.

## 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](https://keryn.dev/docs/edges/edge-kinds/#grants) authority is given or left unchecked.

[CWE-798](https://keryn.dev/taxonomies/cwe/#cwe-798-use-of-hard-coded-credentials) [CWE-522](https://keryn.dev/taxonomies/cwe/#cwe-522-insufficiently-protected-credentials) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [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 `ml/hub_setup.py` and scan it with `keryn scan ml --verbose`; the finding below appears.

```python
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](https://keryn.dev/playground/) shows what does.

## seceng.llm03.runtime-pip-install

`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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-829](https://keryn.dev/taxonomies/cwe/#cwe-829-inclusion-of-functionality-from-untrusted-control-sphere) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

## 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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify.

[CWE-319](https://keryn.dev/rules/?cwe=CWE-319) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [LLM08](https://keryn.dev/taxonomies/owasp-llm/#llm08-vector-and-embedding-weaknesses) [ASI06](https://keryn.dev/taxonomies/owasp-agentic/#asi06-memory-and-context-poisoning) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

## 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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-494](https://keryn.dev/taxonomies/cwe/#cwe-494-download-of-code-without-integrity-check) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities) [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 `ml/fetch_weights.py` and scan it with `keryn scan ml --verbose`; the finding below appears.

```python
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](https://keryn.dev/playground/) shows what does.

## 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](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-693](https://keryn.dev/rules/?cwe=CWE-693) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)
