By Manny Fernandez

November 30, 2026

AI Data Leakage: Myths, Reality, and Locking It Down With Local Models

AI Data Leakage: Myths, Reality, and Locking It Down With Local Models

NO FLUFF. JUST THE CONFIG THAT WORKS.

Executive Summary

Every few weeks a headline warns that some AI model, usually a Chinese one, is “leaking” data. Most people read that and picture the model quietly phoning home. That is not how it works, and the confusion leads to bad decisions in both directions: blocking things that are harmless and trusting things that are not. This post breaks down what AI data leakage actually means, which myths to drop, and how to run local models so your prompts, files and configs stay on hardware you control.

Objective: understand the three real leak paths (hosted services, model files and loaders, and agent tools), then harden a local Ollama deployment with loopback binding, cloud features off, safe model formats, host egress blocking, FortiGate egress policy and logging.

Target audience: security engineers, network admins and practitioners who are being asked “is it safe to use model X?” and want a real answer instead of a vibe.

Figure 1: The three real AI data leakage paths and the control that closes each one

Diagram of three AI data leakage paths: hosted apps, model files and loaders, and agent tools, each with its control

What AI Data Leakage Actually Means

When a researcher or a news story says a model “leaks” data, they almost always mean one of three things. None of them is the weights file reaching out on its own.

Leak path What really happens Real example
1. Hosted app or API Your prompts and uploads are stored on the provider’s servers, under their privacy policy, their country’s laws and their security practices. Wiz found an open DeepSeek ClickHouse database with plaintext chat history and API keys. NowSecure found the DeepSeek iOS app sending device data unencrypted.
2. Model file and loader Some model formats (Python pickle) can run code when they are loaded. Separately, local inference servers get exposed to the internet with no authentication. ReversingLabs and JFrog found malicious pickle models on Hugging Face. Cisco found over 1,100 exposed Ollama servers in one Shodan sweep.
3. Agent tools A model with web, mail or API tools reads attacker-controlled content (prompt injection) and is tricked into sending your data out through those tools. EchoLeak (CVE-2025-32711) exfiltrated Microsoft 365 Copilot data from a single crafted email with zero clicks.

Notice the pattern. Path 1 is about where your data goes. Path 2 is about the code around the model. Path 3 is about what the model is allowed to do. A local model closes path 1 completely, and with the right hardening it closes path 2. Path 3 follows you everywhere, local or hosted.

Myths vs. Reality

Myth 1: “The model phones home to China”

Reality: model weights are a giant file of numbers. A GGUF or safetensors file has no networking code and cannot open a socket. The data collection people worry about happens in the service: the chat website, the mobile app and the API.

That service risk is real and documented. The February 2025 version of the DeepSeek privacy policy states that the information it collects is stored on servers in the People’s Republic of China. On top of that, Wiz found a DeepSeek ClickHouse database open to the internet with no authentication, holding over a million log lines with chat history, API keys and backend details. NowSecure found the iOS app had App Transport Security disabled and was sending some registration and device data without encryption.

So the accurate statement is: using the hosted DeepSeek app or API sends your data to DeepSeek. Downloading the open weights and running them on your own box does not.

Myth 2: “If I run it locally, I’m 100% safe”

Reality: local is not the same as offline. Three things routinely turn a “local” model into an exposed one:

  • The inference API gets exposed. Ollama listens on 127.0.0.1:11434 by default, but one OLLAMA_HOST=0.0.0.0 from a web UI tutorial, a Docker -p 11434:11434 or a router port forward puts an unauthenticated API on the network. Cisco found over 1,100 exposed Ollama servers in a single Shodan sweep, and SANS cites a January 2026 SentinelLABS and Censys count of 175,108 reachable Ollama hosts.
  • The app has cloud features. Recent Ollama builds include cloud models and web search. Those send prompts off the box by design unless you turn them off.
  • The loader runs code. A pickle-format model (.bin, .pt, .pth, .pkl) can execute arbitrary Python the moment it is loaded.

Myth 3: “Only Chinese models leak, so a US model is fine”

Reality: every hosted AI service holds your prompts somewhere. The questions that matter are the same for every provider: where is the data stored, how long is it kept, is it used for training, who can compel access, and how good is the provider’s security. Country of origin changes the legal answer to “who can compel access,” which is a legitimate factor in your risk decision. It does not change the mechanics.

And the most notable real-world AI exfiltration bug so far was not a Chinese product at all. EchoLeak hit Microsoft 365 Copilot: an attacker sent one email, Copilot later pulled it in as context, and hidden instructions made Copilot embed internal data in an image URL that the client fetched automatically. No click required. Leakage through agents is a design problem, not a nationality problem.

Myth 4: “A backdoored model will steal your files”

Reality: backdoors in model behavior are possible, and serious research proves it. Anthropic’s Sleeper Agents paper trained models that wrote secure code when the prompt said the year was 2023 and inserted exploitable code when it said 2024, and standard safety training did not remove the behavior.

But look at what that backdoor does: it changes the output. A model can only touch your files or the network through the tools you give it. A poisoned model with no tools can mislead you or write bad code. A poisoned model with a shell, a browser and your mailbox can do real damage. That is why the controls in this post focus on tools and egress, not on trying to inspect billions of weights.

Myth 5: “A strong system prompt will stop prompt injection”

Reality: OWASP ranks prompt injection as LLM01, the top risk for LLM applications, and states plainly that it is unclear whether fool-proof prevention exists. Telling the model “ignore malicious instructions” helps a little. What actually limits the blast radius is least privilege, separating untrusted content, and human approval for high-risk actions. In network terms: treat the model like an untrusted user and enforce policy outside of it.

Prerequisites and Architecture

Assumed knowledge: basic Linux administration, systemd, iptables or nftables concepts, and FortiGate firewall policy configuration.

Lab requirements: one Linux host with a GPU (or a capable CPU) running Ollama, sitting on an internal VLAN behind a FortiGate. The same principles apply to macOS on Apple Silicon, with notes where the commands differ.

Component Lab value Role
AI inference host 10.0.20.50 (Ubuntu 24.04 LTS) Runs Ollama as the ollama service user
AI VLAN 10.0.20.0/24 on interface LAN-AI Isolated segment for inference hosts
User LAN 10.0.10.0/24 Workstations that use the model through a UI or API proxy
FortiGate WAN 198.18.0.2/30 on wan1 Internet edge, egress policy and logging
Model format GGUF via Ollama, or safetensors No code execution on load

Step-by-Step: Locking Down a Local Model

Step 1: Use Model Formats That Cannot Run Code

Goal: remove the “model file runs code on load” risk entirely.

Action: pull models through Ollama (GGUF) or use safetensors. Treat any pickle-based file from an unknown publisher as untrusted executable code. Hugging Face’s own scanner has been bypassed: ReversingLabs found malicious models that used deliberately broken pickle files so the scanner missed the payload, which still ran at load time.

# Pull from the Ollama library (GGUF, no code on load)
ollama pull qwen3:8b

# On a Hugging Face repo, list files before downloading
# Good:  *.safetensors  *.gguf
# Risky: *.bin  *.pt  *.pth  *.pkl  *.ckpt  (pickle based)
huggingface-cli download <org>/<model> --include "*.safetensors" "*.json"

GUI verification: on the Hugging Face model page, open Files and versions and confirm the weights end in .safetensors or .gguf. If the only weights are .bin or .pt, skip that model or convert it in a disposable VM with no network.

Step 2: Keep the Ollama API on Loopback

Goal: make sure nothing off the box can talk to the inference API.

Action: check what Ollama is bound to and remove any override that exposes it.

# What is listening on 11434, and on which address?
sudo ss -ltnp | grep 11434
# Want:  127.0.0.1:11434   Bad:  0.0.0.0:11434 or *:11434

# Look for an override in the systemd unit
systemctl cat ollama | grep -i OLLAMA_HOST

# Remove it if present, then restart
sudo systemctl edit ollama      # delete the OLLAMA_HOST line
sudo systemctl daemon-reload
sudo systemctl restart ollama

If you run Ollama in Docker, publish the port on loopback only. A plain -p 11434:11434 binds every interface, and Docker’s own iptables rules are processed before UFW, so UFW will not save you.

docker run -d --name ollama --gpus all \
  -v ollama:/root/.ollama \
  -p 127.0.0.1:11434:11434 \
  ollama/ollama

GUI verification: none on the host. From another machine on the LAN, run curl -m 5 http://10.0.20.50:11434/. It should time out or be refused.

Note: Need other users to reach the model? Put an authenticated front end in front of it (Open WebUI with accounts, a reverse proxy with auth, or a ZTNA connector) and keep Ollama itself on 127.0.0.1. Ollama’s API has no authentication of its own.

Step 3: Turn Off Ollama Cloud Features

Goal: stop the app from sending prompts to cloud models or web search.

Action: Ollama documents a local-only mode. Set it with the environment variable or the config file, then restart.

# Linux (systemd): add under [Service]
sudo systemctl edit ollama
#   [Service]
#   Environment="OLLAMA_NO_CLOUD=1"
sudo systemctl daemon-reload
sudo systemctl restart ollama

# Or use the config file
mkdir -p ~/.ollama
echo '{ "disable_ollama_cloud": true }' > ~/.ollama/server.json

# macOS app
launchctl setenv OLLAMA_NO_CLOUD 1   # then quit and reopen Ollama

GUI verification: the Ollama log should show Ollama cloud disabled: true. On Linux check with journalctl -u ollama | grep -i cloud. On macOS the log is in ~/.ollama/logs/server.log.

Step 4: Deny Egress From the Model Process on the Host

Goal: even if something goes wrong, the inference process cannot reach the internet.

Action: on Linux, the standard installer runs Ollama as the ollama user, so you can drop that user’s outbound traffic with an owner match while still allowing loopback. Pull your models first, then apply the rule.

# Allow loopback, then reject everything else from the ollama user
sudo iptables -A OUTPUT -o lo -m owner --uid-owner ollama -j ACCEPT
sudo iptables -A OUTPUT -m owner --uid-owner ollama \
  -j LOG --log-prefix "OLLAMA-EGRESS: "
sudo iptables -A OUTPUT -m owner --uid-owner ollama -j REJECT

# Persist across reboots
sudo apt install -y iptables-persistent
sudo netfilter-persistent save

On macOS, use a per-process outbound firewall such as LuLu or Little Snitch and set the Ollama binaries to deny, allowing only localhost. Approve model pulls by hand when you need them.

GUI verification: sudo iptables -L OUTPUT -v -n --line-numbers should show the three rules with packet counters. Any counter on the LOG line means something tried to get out.

Step 5: Enforce and Log It at the FortiGate

Goal: a second, independent control at the network edge that also gives you a log trail. Host rules can be changed by anyone with root on the box. The firewall cannot.

Action: create an address object for the inference host and a deny policy with logging, and place it above any general outbound allow for that VLAN.

config firewall address
    edit "AI-HOST-01"
        set subnet 10.0.20.50 255.255.255.255
    next
end
config firewall policy
    edit 0
        set name "AI-HOST-EGRESS-DENY"
        set srcintf "LAN-AI"
        set dstintf "wan1"
        set srcaddr "AI-HOST-01"
        set dstaddr "all"
        set action deny
        set schedule "always"
        set service "ALL"
        set logtraffic all
    next
end

Then move it to the top of the LAN-AI to wan1 section with config firewall policy, move <new-id> before <first-allow-id>. When you need to pull a new model, either stage it on a different host and copy the model directory over, or open a short scheduled allow to the model registry and close it again.

For everyone else on the network, the same FortiGate handles path 1: use Application Control to monitor or block the generative AI category, and apply DLP and SSL deep inspection to the AI sites you do allow, so you can see and stop source code, credentials and customer data going into hosted prompts.

GUI verification: Policy & Objects > Firewall Policy shows AI-HOST-EGRESS-DENY above the allow rules with hit counts. Log & Report > Forward Traffic filtered on source 10.0.20.50 shows any blocked attempts.

Step 6: Put Agents in a Box

Goal: close path 3. This is the one a local model does not fix on its own. If your agent has a web fetch tool, a local model can be prompt-injected just as easily as a hosted one.

Action:

  • Least privilege tools. Give the agent only the tools the task needs. A summarizer does not need email send. A code helper does not need your home directory.
  • Egress allowlist for the agent, not the model. Run the agent in a container or VM whose only route out is a proxy with a domain allowlist. Image and link fetches to unknown domains are exactly how EchoLeak-style exfiltration works.
  • Human approval for outbound actions. Sending mail, posting to an API, writing outside a working folder or running shell commands should require a click from a person.
  • Log every tool call. Tool name, arguments, destination and result, shipped to your SIEM. If you cannot answer “what did the agent send, and where?” you are not in control of it.
  • Treat fetched content as untrusted. Web pages, emails, PDFs and tickets are attacker input. Keep them clearly separated from instructions in your prompts.

Verification and Validation

Run these after the steps above. Every line should give the expected result.

# 1. API answers locally
curl -s http://127.0.0.1:11434/
# Expected: Ollama is running

# 2. API is NOT reachable from another host (run on 10.0.10.x)
curl -m 5 http://10.0.20.50:11434/
# Expected: timeout or connection refused

# 3. Cloud features are off
journalctl -u ollama --no-pager | grep -i "cloud disabled"
# Expected: Ollama cloud disabled: true

# 4. The ollama user cannot reach the internet
sudo -u ollama curl -m 5 -sS https://ollama.com -o /dev/null
# Expected: Failed to connect ... Connection refused

# 5. Inference still works
ollama run qwen3:8b "Say OK"
# Expected: OK

On the FortiGate, confirm the deny is logging:

execute log filter category 0
execute log filter field srcip 10.0.20.50
execute log display
# Expected: entries with action="deny" policyname="AI-HOST-EGRESS-DENY"

diagnose sniffer packet wan1 'host 10.0.20.50' 4 10
# Expected: no packets leaving wan1 from the AI host

Troubleshooting and Gotchas

Gotcha 1: Model Pulls Fail After You Block Egress

Symptom: ollama pull hangs or errors with a connection failure. That is the control working.

Fix: pull on a staging host with internet access and copy the model store over (/usr/share/ollama/.ollama/models on Linux, ~/.ollama/models on macOS), or point OLLAMA_MODELS at a shared read-only path. If you must pull directly, open a temporary scheduled policy and remove it afterward.

# Copy models from staging to the locked-down host
sudo rsync -a /usr/share/ollama/.ollama/models/ \
  admin@10.0.20.50:/usr/share/ollama/.ollama/models/
sudo chown -R ollama:ollama /usr/share/ollama/.ollama/models

Gotcha 2: Something Re-Exposed Port 11434

Symptom: a web UI install or compose file changed the binding, and ss now shows 0.0.0.0:11434.

Fix: search for the override and the published port, put both back on loopback, and add a detection. Elastic ships a prebuilt rule for Ollama accepting connections from external addresses.

sudo ss -ltnp | grep 11434
systemctl cat ollama | grep -i OLLAMA_HOST
docker ps --format '{{.Names}} {{.Ports}}' | grep 11434
grep -rn "11434" ~/docker /opt 2>/dev/null

Gotcha 3: The Model Is Local but Data Still Leaves

Symptom: egress logs from the inference host are clean, but data shows up somewhere it should not.

Fix: look at the agent and its tools, not the model. Check the proxy logs for the agent container, review the tool-call log, and look for outbound image or link fetches with long query strings. That is the classic prompt-injection exfiltration shape.

The Bottom Line

“The model leaks data” is shorthand that hides the real question: who holds your data, what code runs around the model, and what is the model allowed to do? Run open weights locally in a safe format, keep the API on loopback, turn off cloud features, deny egress at the host and at the FortiGate, and box in your agents with least privilege and logging. Do that, and the headline stops being your problem.

Sources

Herdr: Run and Orchestrate AI Coding Agents From One Terminal

Herdr: Run and Orchestrate AI Coding Agents From One Terminal

Set up herdr for AI coding agents: install it, add the Claude Code and Codex integrations, isolate agents in worktrees, and let one agent...

Read More
AI Primer: Models, RAG, MCP, Harnesses and Agents Explained

AI Primer: Models, RAG, MCP, Harnesses and Agents Explained

A plain-language AI primer: models, tokens, RAG, MCP, harnesses and agents explained with everyday analogies so you can follow any AI conversation.

Read More
iTerm2 Orchestration Chat: Let AI Drive Every Terminal Without Handing Over the Keys

iTerm2 Orchestration Chat: Let AI Drive Every Terminal Without Handing Over the Keys

Lock down an iTerm2 orchestration chat: permission states, @-mention grants, Revoke, prompts, and running it on a local Ollama model over your LAN.

Read More