23  Recipe: serve a local model for scanning

Field Value
Tool ollama
Section Ops
Level medium
Time ~20 min + model download
Layer/Category OPS / o-04
Tags ops, serving, target-endpoint, ollama

23.1 Problem

ATTACK-layer scanners are requires-target: they fire requests at a model endpoint but never self-serve a model. The scan needs a target endpoint on the lab’s own infrastructure before it can run. The target: a real model, answering on a controlled port. Ollama is the manifest’s primary home for local LLM serving (category o-04, its documented tiny-test-model home). vLLM is the high-throughput alternative in o-02.

23.2 Solution

Serve a small model with Ollama, bound to loopback. Prove the endpoint is healthy before the scanner touches it:

# 1. Install-side: ollama is manifest-native (status native, safety
#    safe) — confirm the row from the manifest view
kailash info ollama

# 2. Pull a small model for lab use (keep it small: short scans,
#    fast iterations)
ollama pull smollm2:360m           # the documented tiny test model

# 3. Serve it bound to loopback ONLY (the blast-radius boundary)
OLLAMA_HOST=127.0.0.1:11434 ollama serve

# 4. In another terminal: prove the endpoint is alive BEFORE scanning
curl http://127.0.0.1:11434/                 # -> "Ollama is running"
curl http://127.0.0.1:11434/api/generate \
     -d '{"model":"smollm2:360m","prompt":"Reply with OK only.","stream":false}'

What success looks like:

  • the root endpoint answers Ollama is running
  • the generate call returns a JSON object with a response field (the model’s answer) — round-trip proven
  • the server socket is bound to 127.0.0.1, not 0.0.0.0 netstat / lsof on port 11434 shows the loopback bind

23.3 Discussion

  • Why Ollama first: the manifest lists it as the primary local serving home (native packaging, safety safe, category o-04 with o-02 as secondary). vLLM (o-02) is the high-throughput engine for parallel probe load — garak’s parallel-hint path. Ollama is the smallest verified loop from zero to a target.
  • Why loopback binding is mandatory: a target endpoint is a deliberate attack surface. A 0.0.0.0 bind puts it on the network. Bind 127.0.0.1 on a lab box. Anything more open is a deliberate, documented decision — not a flag accident.
  • Why a small model: scanners drive the target hard (garak runs --generations per probe, repeated across probes). A 360M test model keeps the loop fast and the disk light, while exercising the full request path. Scale up when the recipe’s question demands it, not by default.
  • Streaming off: the stream:false generate call returns one JSON object — simpler to assert in health checks than a stream.
  • The scan’s target grammar: garak consumes this endpoint with --target_type ollama --target_name <model> — see Scan a self-hosted model for prompt-injection resistance.
  • vLLM variant: same shape, different engine — vllm serve (manifest row native, safety safe, o-02). The high-throughput option when the run needs --parallel_attempts headroom.

23.4 See also


ref: manifest row + Ollama CLI/API docs - verified 2026-10-14.