ai newsMi., 25. Nov.
EilmeldungYale’s Sonnenfeld: Nvidia is a ‘detriment’ to U.S. industrial might — not a champion

Egress-Audit: Ist Ihr selbst gehosteter AI-Stack wirklich offline?

Ein Tutorial zeigt, wie sich ausgehender Traffic eines selbst gehosteten AI-Stacks prüfen lässt: Eine Deny-by-default-Firewall blockiert ausgehende Verbindungen und protokolliert alle Hostnames und Pakete.

dev.toMontag 09:14 · 23.11.DE5 Min. Lesezeit
Bild: dev.to

Posted on Nov 23 • Originally published at actian.com

This article was originally published on the Actian blog.

In this tutorial, you'll run an egress audit against a self-hosted AI stack. You'll block outbound traffic with a deny-by-default firewall, record every hostname and packet the stack tries to reach, and apply offline settings until nothing gets out. You'll need a Linux environment with Docker Engine, Docker Compose, iptables, and tcpdump. The egress audit repo has the full setup.

The test stack was a local RAG app built with LlamaIndex, Actian VectorAI DB Community Edition for retrieval, Ollama running Llama 3.2 3B, a local Hugging Face embedding model, and Arize Phoenix for tracing. It answered queries with the network cut, and it still tried to call out 52 times.

Counts include retries, so they're higher than the number of unique requests. In the cold-start run, the packet capture recorded 31 attempts and the firewall log recorded one more from VectorAI DB.

The audit ran on Ubuntu 24.04 under WSL2, with all four application components in Docker containers. Clone the repo and open the project folder.

git clone https://github.com/actian-devs/developer-content.git cd developer-content/blog/egress-audit Enter fullscreen mode Exit fullscreen mode Follow the README to stage the Ollama and Hugging Face models while you still have internet access. Start the stack with the base Compose file, confirm the RAG app can answer the sample query, and then move on to the audit.

The stack's internal network keeps running, so components can talk to each other while external connections are blocked. A logging DNS sinkhole records requested hostnames, and firewall rules in Docker's DOCKER-USER chain log and reject outbound packets.

Point Docker Compose at the base file and the audit overlay, which adds the DNS sinkhole. Run this in both terminals you use for the audit.

export COMPOSE_FILE = docker-compose.yml:docker-compose.audit.yml Enter fullscreen mode Exit fullscreen mode Prepare the containers without starting them.

docker compose down docker compose up --no-start Enter fullscreen mode Exit fullscreen mode Turn on the firewall and clear the previous DNS and kernel logs so the new records match this run.

sudo./audit/egress-deny.sh on sudo truncate -s 0 capture/dns.log sudo dmesg -C Enter fullscreen mode Exit fullscreen mode The policy allows traffic between containers on br-rag and blocks external IPv4 egress. In the second terminal, start the packet capture before the services launch.

sudo tcpdump -i br-rag -nn -s 0 -w capture/prestaged.pcap 2 >& 1 | tee -i capture/prestaged.tcpdump.txt Enter fullscreen mode Exit fullscreen mode Back in the first terminal, start the stack and run the test query.

docker compose up -d docker compose run --rm app --question "How long are adult patient records kept?" Enter fullscreen mode Exit fullscreen mode Keep the capture running for 30 more minutes to catch scheduled retries and background requests, then stop tcpdump with Ctrl+C.

sleep 1800 Enter fullscreen mode Exit fullscreen mode The DNS sinkhole configuration is in the repo's audit/dns folder.

Give each container a fixed IP address so you can match network traffic to the component that sent it.

ollama: networks: rag: ipv4_address: 10.77.0.11 Enter fullscreen mode Exit fullscreen mode Save the DNS and kernel logs from the run.

sudo cp capture/dns.log capture/prestaged.dns.log sudo TZ = UTC dmesg --time-format iso > capture/prestaged.kernel.log Enter fullscreen mode Exit fullscreen mode Then group outbound activity by component and destination with the summarizer script. It reads the DNS log, packet capture, firewall log, and tcpdump statistics.

sudo./audit/summarize.sh capture/prestaged Enter fullscreen mode Exit fullscreen mode

Classify each attempt as a setup dependency, a runtime check, or a background request. Then repeat the run with empty caches to find dependencies that would stop an offline deployment from starting.

In the cold-start run, Ollama tried to reach its registry and the embedding libraries tried to download model files from Hugging Face. Both failed under the firewall, so the query never completed.

The highest risk comes from calls that carry prompts or document chunks. LlamaIndex falls back to OpenAI's hosted embeddings when Settings.embed_model doesn't point to a local model, so check that setting first. The Hugging Face Hub docs also note that hf_hub_download can check for newer versions of files already in the local cache.

Apply offline settings in a Docker Compose override file. These are the settings the hardened rerun used.

services: ollama: environment: - OLLAMA_NO_CLOUD=1 phoenix: environment: - PHOENIX_ALLOW_EXTERNAL_RESOURCES=false - PHOENIX_TELEMETRY_ENABLED=false app: environment: - HF_HUB_OFFLINE=1 Enter fullscreen mode Exit fullscreen mode OLLAMA_NO_CLOUD=1 turns off Ollama's cloud features. HF_HUB_OFFLINE=1 stops Hugging Face libraries from making HTTP requests to the Hub. The two Phoenix flags restrict external resources and turn off telemetry. Set Settings.embed_model to a local Hugging Face embedding model, and stage every model weight and embedding file before you enforce these settings. Some background requests have no setting to turn them off. For those, keep the network block in place and document the remaining attempts.

Repeat the pre-staged query with the offline settings and the deny-all firewall active, then compare the results with your first capture.

During a 32-minute observation window, the hardened run recorded one blocked connection, the VectorAI DB deployment-usage notification, and no attempts from Ollama, the RAG app, or Phoenix. Blocked packets fell from 52 to 1, DNS lookups fell from 68 to 2, and the app still answered the test query correctly.

Save the DNS logs, packet captures, firewall logs, and query output with the configuration for each run. That record shows an auditor the app worked without external connections and traces any attempts that remain.

The audit tested firewall isolation, DNS logging, and application-level offline settings. A production air-gapped enclave also needs the following controls.

Running a model and a vector database on your own hardware doesn't remove every external dependency. With the network cut, this stack still reached for model registries, metadata checks, and background services. VectorAI DB kept retrieval working locally the whole time, and a few offline settings brought the outbound attempts down to one.

Originaltitel: Is your offline AI stack truly offline?Quelle: dev.to (dev.to). Original öffnen