Home / AI & GenAI

AI & GenAIRunbookAdvanced

Sev1: self-hosted LLM server (Ollama or vLLM) exposed to the internet without authentication

An Ollama or vLLM endpoint is reachable from the internet with no auth, so anyone can use your GPUs or change models. Close the port, check for tampering, add auth and keep it private.

Deepak Bhardwaj6 min read

Applies toOllama (Linux, Docker), vLLM OpenAI-compatible server, Azure NSG, AWS security groups, Kubernetes Services

Symptoms

  • A security scanner, the cloud provider or an external researcher reports an open port 11434 (Ollama) or 8000 (vLLM) on a public IP.
  • GPU utilisation is high when your own traffic is low; latency for real users jumps.
  • Models appear in ollama list that nobody on the team pulled, or a model you rely on is missing.
  • Access logs show client IPs outside your network.

Ollama has no built-in authentication. vLLM only checks an API key if you start it with one. If either is bound to 0.0.0.0 on a host with a public IP, or published through a public load balancer, the internet can call it.

1. Confirm scope and impact

From a machine outside your network (a phone hotspot or a cloud shell in another tenant):

curl -s --max-time 5 http://<public-ip>:11434/api/version     # Ollama
curl -s --max-time 5 http://<public-ip>:11434/api/tags | jq '.models[].name'
curl -s --max-time 5 http://<public-ip>:8000/v1/models         # vLLM

A JSON reply means it is exposed. Record the time and output for the incident timeline.

Find every exposed instance, not just the one reported:

# Azure: NSG rules that allow these ports from anywhere
az network nsg list --query "[].{nsg:name, rg:resourceGroup, rules:securityRules[?access=='Allow' && direction=='Inbound' && (sourceAddressPrefix=='*' || sourceAddressPrefix=='Internet' || sourceAddressPrefix=='0.0.0.0/0')].{name:name, port:destinationPortRange}}" -o json

# AWS: security groups open to 0.0.0.0/0 on 11434 or 8000
for p in 11434 8000; do
  aws ec2 describe-security-groups \
    --filters Name=ip-permission.cidr,Values=0.0.0.0/0 Name=ip-permission.from-port,Values=$p \
    --query "SecurityGroups[].[GroupId,GroupName]" --output table
done
# Port ranges (e.g. 0-65535) don't match the from-port filter; also review rules with wide ranges

# Kubernetes: Services published with a public load balancer
kubectl get svc -A -o wide | grep -Ei 'LoadBalancer|NodePort' | grep -Ei 'ollama|vllm|llm|11434|8000'

2. Close it (fastest safe mitigation)

Block at the network edge first. It does not require restarting the model server, so real users inside the network keep working.

# Azure: add a high-priority deny for the port from the internet
az network nsg rule create -g rg-gpu -n nsg-gpu-vm --name deny-llm-internet --priority 100 \
  --direction Inbound --access Deny --protocol Tcp --source-address-prefixes Internet \
  --destination-port-ranges 11434 8000

# AWS: remove the open rule
aws ec2 revoke-security-group-ingress --group-id sg-0abc123 \
  --protocol tcp --port 11434 --cidr 0.0.0.0/0

# Kubernetes: make the Service internal
kubectl -n ai patch svc ollama -p '{"spec":{"type":"ClusterIP"}}'

Warning

Changing a Service from LoadBalancer to ClusterIP releases its public IP, and anything inside the network that used that IP stops working. Check who calls it first; if internal apps depend on it, add an internal load balancer annotation for your cloud instead.

Then fix the bind address on the host so the next firewall mistake does not re-open it:

# Ollama on systemd: listen on localhost (or a private IP) only
sudo systemctl edit ollama
#   [Service]
#   Environment="OLLAMA_HOST=127.0.0.1:11434"
sudo systemctl restart ollama
ss -ltnp | grep 11434

For Docker, publish to localhost only: -p 127.0.0.1:11434:11434.

Re-run the external curl from step 1. It must time out.

3. Check what was done while it was open

Who called it and what they called

# Ollama logs each request with client IP, method and path
journalctl -u ollama --since "7 days ago" | grep '\[GIN\]' \
  | awk '{print $(NF-3), $NF}' | sort | uniq -c | sort -rn | head -30

The exact log format varies by version; look for the client IP and path in each [GIN] line. For vLLM, check the uvicorn access log in the pod or service output (kubectl logs deploy/vllm -n ai --since=168h).

Path called by outside IPs Risk
/api/generate, /api/chat, /v1/chat/completions Compute theft; your GPUs served someone else
/api/pull, /api/create New or modified models on your host
/api/delete Models removed; outage for your apps
/api/push Models copied out to an external registry

Model integrity

ollama list                       # compare with your approved model list
ollama show <model> --modelfile   # look for a changed SYSTEM prompt or ADAPTER

Caution

If outside callers used /api/create, /api/pull or /api/push, or the Ollama version was old, treat the host as untrusted. Older Ollama releases had a path traversal bug in model pulls (CVE-2024-37032, fixed in 0.1.34) that allowed file overwrite. Rebuild the host from a clean image and re-pull models from your approved source rather than cleaning it in place. Keep a disk snapshot for forensics before you delete anything.

4. Put authentication in front

Do not expose the model server directly, even to internal networks, without auth.

vLLM: start with an API key.

export VLLM_API_KEY=$(openssl rand -hex 32)   # store in your secret manager
vllm serve meta-llama/Llama-3.1-8B-Instruct --host 0.0.0.0 --port 8000 --api-key "$VLLM_API_KEY"

curl -s http://10.0.1.20:8000/v1/models -H "Authorization: Bearer $VLLM_API_KEY"

The key check covers the OpenAI-compatible /v1 routes. Health and metrics routes may still answer without a key; check your version and keep the port private anyway.

Ollama: it has no auth setting. Keep it on localhost and put a reverse proxy, an API gateway, or an LLM gateway with keys (for example LiteLLM) in front:

server {
  listen 443 ssl;
  server_name llm.internal.example.com;
  # ssl_certificate / ssl_certificate_key ...
  location / {
    if ($http_authorization != "Bearer <long-random-token>") { return 401; }
    proxy_pass http://127.0.0.1:11434;
    proxy_buffering off;          # keep streaming responses working
    proxy_read_timeout 300s;
  }
}

5. Verify recovery

  • External curl to every port times out.
  • Internal calls without a key return 401; calls with a key return 200.
  • nvidia-smi utilisation matches your own traffic again.
  • ollama list matches the approved list; key prompts give expected answers.

Communicate

Tell the security team as soon as you confirm exposure; they decide on any external reporting. Internal note:

"The internal LLM server on was reachable from the internet without authentication from to . Access is now blocked. We are checking for model changes. Prompts sent to this server were not stored by it, but traffic to it was not encrypted. Next update at HH:MM."

Confirm the "not stored" statement for your setup; if a gateway or app logged prompts, say so.

Prevent it next time

  • Policy that denies public IPs and internet-facing rules on GPU subnets (Azure Policy, AWS Config rules or SCPs).
  • Model servers bind to localhost or a private IP; only a gateway with auth is reachable by apps.
  • Run an external port scan of your public ranges on a schedule and alert on 11434 and 8000.
  • Kubernetes: admission policy that blocks type: LoadBalancer without an internal annotation in AI namespaces.
  • Keep Ollama and vLLM on current releases; track their security advisories.