TExcelTAD
Home › Security Research: Fuzzing, Vulnerability Discovery, Kernel, Browser & AI Security › AI Security: OWASP LLM Top 10, Model Supply Chain and Governance

AI Security: OWASP LLM Top 10, Model Supply Chain and Governance

Machine-learning systems are software, so everything in this course applies to them: their parsers have memory bugs, their services have injection flaws, their dependencies have advisories. They also add risks that ordinary software doesn't have. A model's behaviour is learned from data an attacker may influence; a language model treats every piece of text in its context as potential instructions; a model file can be a program; and a model's answers leak information about its training data. AI security research studies these risks with the same discipline as the rest of this course: mechanism, detection, defence, on toy systems. This lesson maps the field; the next three go into prompt injection, poisoning and adversarial attacks.

The ML track already introduces several of these threats in Security of ML Systems (adversarial examples, poisoning, membership inference, extraction, pickle files) and the LLM course in Privacy & Security (prompt injection, defence in depth). Read them first; this section goes deeper into mechanisms and detection.

The OWASP Top 10 for LLM Applications (2025)

OWASP's list for applications built on large language models is the common vocabulary for LLM risks. The 2025 edition:

ID Risk In one line
LLM01 Prompt Injection input (direct, or hidden in content the model reads) changes the model's behaviour against the developer's intent
LLM02 Sensitive Information Disclosure the model reveals personal data, secrets or proprietary information from its context or training
LLM03 Supply Chain compromised models, datasets, adapters, libraries or hosting
LLM04 Data and Model Poisoning manipulated training or fine-tuning data plants biases or backdoors
LLM05 Improper Output Handling model output used without validation: XSS, SQL, shell commands built from it
LLM06 Excessive Agency the model can call tools with more permissions or autonomy than its task needs
LLM07 System Prompt Leakage secrets or security logic placed in the system prompt are exposed
LLM08 Vector and Embedding Weaknesses RAG stores: poisoned documents, cross-tenant leaks, embedding inversion
LLM09 Misinformation confident, wrong output trusted without verification
LLM10 Unbounded Consumption uncontrolled inference costs, denial of service, model extraction through mass queries

Two observations guide the rest of the section. First, most entries are classic security principles applied to a new component: least privilege (LLM06), output encoding (LLM05), secrets management (LLM07), rate limiting (LLM10), supply-chain integrity (LLM03). Second, the model itself cannot be trusted to enforce a boundary: defences belong in the code around it. MITRE ATLAS complements the list with a catalogue of adversary tactics and techniques against ML systems, in the style of ATT&CK.

The model supply chain

A model arrives as files: weights, a tokenizer, configuration, sometimes code. The classic risk is the pickle format: Python's pickle can encode "call this function with these arguments", and torch.load of an untrusted checkpoint (with full unpickling allowed) or pickle.load of a model file runs whatever the file says. Insecure Deserialization explains the mechanism for web apps; Pickle and joblib for models.

The example creates two pickled "model files", one of which calls print when loaded (a harmless stand-in for any function), and never loads either. It scans them with pickletools, which decodes the opcodes without executing them, and flags anything that imports or calls. Then it writes and reads a file in the layout of safetensors (an 8-byte header length, a JSON header with names, types, shapes and offsets, and raw bytes), a format that can only hold data. It runs in your browser:

python · try it yourself
import json, pickle, pickletools, struct

# 1. Two pickled "model files". The second one runs a function when loaded: here a harmless print.
weights = {"layer1": [0.5, -1.25], "bias": 0.1}
class Surprise:
    def __reduce__(self):                        # pickle stores "call print(...)" instead of data
        return (print, ("this ran while loading the model",))
files = {"clean.pkl": pickle.dumps(weights, protocol=4),
         "surprise.pkl": pickle.dumps({"weights": weights, "x": Surprise()}, protocol=4)}

# 2. Scan WITHOUT loading: list the opcodes that import or call something.
ALLOWED = set()                                  # a weights file needs no imports at all
def scan(data):
    findings, strings = [], []
    for op, arg, pos in pickletools.genops(data):
        if op.name in ("SHORT_BINUNICODE", "BINUNICODE", "UNICODE"):
            strings.append(arg)
        if op.name in ("GLOBAL", "STACK_GLOBAL"):
            target = arg if op.name == "GLOBAL" else ".".join(strings[-2:])
            if target not in ALLOWED:
                findings.append(f"imports {target} (offset {pos})")
        if op.name in ("REDUCE", "BUILD", "INST", "OBJ", "NEWOBJ"):
            findings.append(f"{op.name} calls a callable (offset {pos})")
    return findings

for name, data in files.items():
    print(f"{name}: {scan(data) or 'no imports or calls: plain data'}")

# 3. A safetensors-style file: an 8-byte header length, a JSON header, raw little-endian bytes.
def save_st(tensors):
    header, blob = {}, b""
    for name, values in tensors.items():
        raw = struct.pack(f"<{len(values)}f", *values)
        header[name] = {"dtype": "F32", "shape": [len(values)], "data_offsets": [len(blob), len(blob) + len(raw)]}
        blob += raw
    h = json.dumps(header).encode()
    return struct.pack("<Q", len(h)) + h + blob

def load_st(data):
    n = struct.unpack("<Q", data[:8])[0]
    header = json.loads(data[8:8 + n])            # data only: parsing JSON cannot run code
    out = {}
    for name, info in header.items():
        a, b = info["data_offsets"]
        out[name] = list(struct.unpack(f"<{(b - a) // 4}f", data[8 + n + a:8 + n + b]))
    return out

st = save_st({"layer1": [0.5, -1.25], "bias": [0.1]})
print(f"safetensors-style file: {len(st)} bytes, loads as {load_st(st)}")
clean.pkl: no imports or calls: plain data
surprise.pkl: ['imports builtins.print (offset 98)', 'REDUCE calls a callable (offset 137)']
safetensors-style file: 151 bytes, loads as {'layer1': [0.5, -1.25], 'bias': [0.10000000149011612]}

The clean pickle contains only data opcodes. The other one imports builtins.print and calls it (REDUCE), which pickle.load would execute. A weights file has no reason to import anything, so an empty allow-list is the right policy; scanners used by model hubs apply the same idea with lists of dangerous imports. The safetensors-style file round-trips the numbers (the 0.1 comes back as its nearest 32-bit float) and parsing it is just JSON and struct: there is nothing to execute.

Supply-chain defences for models are those of Software Supply Chain Security plus a few of their own: prefer data-only formats (safetensors, ONNX for graphs), load PyTorch checkpoints with weights_only=True (the default of torch.load since PyTorch 2.6; never pass weights_only=False for an untrusted file), pin models by digest, not by name, verify signatures or provenance where the hub offers them, scan pickles before loading, never set trust_remote_code for a model you have not reviewed, and record models and datasets in an SBOM (an "AI-BOM").

Governance: NIST AI RMF and the EU AI Act

  • NIST AI Risk Management Framework (AI RMF 1.0, January 2023) is voluntary guidance organised in four functions: Govern (policies, roles, accountability), Map (context and risks of a system), Measure (test and track them) and Manage (prioritise and treat them). NIST's Generative AI Profile (NIST AI 600-1, July 2024) applies it to generative models, including security risks such as prompt injection and data poisoning.
  • The EU AI Act (Regulation (EU) 2024/1689) is law. It classifies AI systems by risk. For high-risk systems, Article 15 requires appropriate accuracy, robustness and cybersecurity, explicitly including resilience against data poisoning, model poisoning, adversarial examples and confidentiality attacks. Providers of general-purpose AI models with systemic risk must, under Article 55 and among other duties, evaluate their models including adversarial testing, assess and mitigate systemic risks, track and report serious incidents, and ensure adequate cybersecurity protection. Obligations apply in stages: the prohibitions from 2 February 2025, the general-purpose model duties from 2 August 2025, most other provisions from 2 August 2026. The high-risk obligations were moved back by the Digital Omnibus on AI (Regulation (EU) 2026/1744, in force since 27 July 2026): to 2 December 2027 for Annex III systems and to 2 August 2028 for AI in products regulated under Annex I. Check the current text and dates before relying on them.

For researchers, both frameworks matter in the same way as disclosure policies do: they create channels and duties for reporting vulnerabilities in AI systems, and they make adversarial testing an expected part of building them.

How AI-specific risks are detected

Red-team exercises and adversarial testing before release; automated test suites of known attack patterns run in CI (with harmless canary strings, not real harmful content); monitoring of tool calls, output filters and query volumes in production; scanning of model files and datasets on ingestion; and evaluation of models for memorisation and leakage. Each of the next lessons has a detection section for its own threat.

Pitfalls

  • Treating the model as the security boundary. Instructions in a system prompt are not access control.
  • Loading models like data. A .pkl, .pt or .bin file from the internet is code until proven otherwise.
  • Copying governance text instead of testing. A risk register without measurements is not "Measure".
  • Assuming a "safe" model makes a safe application. Most incidents are in the application around the model: tools, permissions, output handling.

Practice

1. Which OWASP LLM risk is a chatbot that can call delete_account(user_id) for any user id the model chooses?

LLM06 Excessive Agency (the tool has more power than the task needs), usually triggered through LLM01 Prompt Injection. Fix in code: the tool deletes only the signed-in user's account, and only after explicit confirmation.

2. Extend the scanner's allow-list so that a pickled NumPy array passes. What risk do you accept?

Allow the few globals NumPy needs to rebuild an array (numpy.core.multiarray._reconstruct, or numpy._core.multiarray._reconstruct for pickles written by NumPy 2, plus numpy.ndarray and numpy.dtype). You accept that those callables are invoked during loading; they are not dangerous on their own, but every allowed global widens the attack surface. A data-only format avoids the question.

3. Under the AI Act, which article sets cybersecurity requirements for high-risk AI systems, and which attacks does it name?

Article 15 (accuracy, robustness and cybersecurity). It names data poisoning, model poisoning, adversarial examples (model evasion), confidentiality attacks and model flaws as threats the technical solutions should address where appropriate.

Test yourself

Which entry is LLM01 in the OWASP Top 10 for LLM Applications 2025?

  1. Supply Chain
  2. Prompt Injection
  3. Unbounded Consumption
  4. Misinformation

How did the example decide that surprise.pkl was dangerous?

  1. It loaded the file
  2. It decoded the opcodes with pickletools and found an import of builtins.print and a REDUCE call
  3. It checked the file size
  4. It compared hashes

Why is a safetensors-style file safe to parse?

  1. It is encrypted
  2. It contains only a JSON header and raw numbers; nothing in the format can call a function
  3. It is signed
  4. It is small

What are the four functions of the NIST AI RMF?

  1. Identify, Protect, Detect, Respond
  2. Govern, Map, Measure, Manage
  3. Plan, Do, Check, Act
  4. Prevent, Detect, Correct, Recover