# llm03-supply-chain

> llm03-supply-chain: 5 Keryn rules for python, javascript, typescript (1 error, 3 warning, 1 info).

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

5 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.python-pip-install-in-code

`warning` python llm03-supply-chain

Running 'pip install' from within code without version pinning. This is a significant supply chain risk.

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-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)

**Try it: a snippet that triggers this rule**

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

```python
import importlib
import os

def ensure(module: str, package: str):
    try:
        return importlib.import_module(module)
    except ImportError:
        os.system("pip install " + package)
        return importlib.import_module(module)
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.llm03.python-pip-install-in-code` 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](https://keryn.dev/playground/) shows what does.

## seceng.llm03.js-ts-npm-install-in-code

`error` javascript, typescript llm03-supply-chain

Running 'npm install' from within code. This is a significant supply chain risk.

Confidence **P1**: dangerous in context. 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-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)

**Try it: a snippet that triggers this rule**

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

```js
const { exec } = require("child_process");

function installPlugin(name) {
  const child = exec("npm install " + name);
  child.stdout.pipe(process.stdout);
  child.on("exit", (code) => {
    if (code !== 0) console.error(`install of ${name} failed`);
  });
}

installPlugin(process.argv[2]);
```

Checked with Keryn's browser engine when this page was built: it reports `seceng.llm03.js-ts-npm-install-in-code` at line 4 (error, 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.dynamic-model-download

`warning` python, javascript, typescript huggingface

Dynamic model weight download detected from a URL. Prefer local, verified model files or pinned HuggingFace revisions.

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)

## seceng.llm03.insecure-pickle-load

`warning` python pytorch

Use of unsafe loading with torch.load() or joblib.load(). Models saved as pickles can execute arbitrary code during loading. Set 'weights\_only=True' for PyTorch or use safer formats like Safetensors.

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) [ASI04](https://keryn.dev/taxonomies/owasp-agentic/#asi04-agentic-supply-chain-vulnerabilities)

## seceng.llm03.prefer-safetensors

`info` python llm03-supply-chain

Loading model weights from potentially unsafe formats (.bin, .pt). Prefer using the .safetensors format to mitigate arbitrary code execution risks.

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.

[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)
