Zum Inhalt springen
>_<
AI EngineeringWiki

Security

Encryption: At Rest, In Transit, In Use

Data must be protected in three states: stored, transmitted, and during processing. Here is what that means in practice.

Reading time: 12 minLast updated: March 2026
πŸ“‹ At a Glance

Encryption protects data in three phases: At Rest (on disk/SSD), In Transit (on the network), In Use (during processing in RAM). For a self-hosted AI stack, the first two are mandatory, the third is a bonus for high-security scenarios.

The Three Encryption Layers

If you encrypt data on disk but send it unencrypted over the network, you have a gap. Encryption must cover all three states.

Three Encryption Layers: At Rest, In Transit, In Use

Data passes through three states β€” each needs its own protection.

PhaseWhatThreatProtection
At RestData on disk/SSDHardware theft, filesystem accessLUKS, dm-crypt, Veracrypt
In TransitData on the networkMan-in-the-Middle, eavesdroppingTLS 1.3, WireGuard VPN, SSH Tunnel
In UseData in RAM during processingMemory dumps, cold boot attacksConfidential Computing, Intel SGX, AMD SEV

Encryption At Rest: Disk Encryption

At-rest encryption protects your data when someone physically accesses the disk β€” theft, disposal, repair. Without encryption, anyone can plug the drive into another machine and read everything.

LUKS (Linux Unified Key Setup)

LUKS is the standard for disk encryption on Linux. Most Linux distributions offer LUKS encryption during installation.

Encrypt an existing partition

# CAUTION: Create backup FIRST!

# Encrypt partition (all data will be erased!)
sudo cryptsetup luksFormat /dev/sdb1

# Open partition
sudo cryptsetup luksOpen /dev/sdb1 encrypted-data

# Create filesystem
sudo mkfs.ext4 /dev/mapper/encrypted-data

# Mount
sudo mount /dev/mapper/encrypted-data /mnt/secure-data
⚠️ Performance Impact

LUKS encryption on modern CPUs with AES-NI support has only about 1-3% performance overhead for sequential reads/writes. For random I/O (databases), overhead can be 5-10%. For AI workloads where the GPU is the bottleneck, you will not notice the difference.

What to EncryptPriorityReason
Backup VolumesMANDATORYBackups contain everything β€” databases, configs, secrets
Database VolumesHIGHCustomer data, credentials, AI training data
System PartitionMEDIUMProtects configs and logs if stolen
Swap PartitionHIGHRAM contents written to disk (secrets!)
Model StorageLOWModels are public, but your fine-tunes are not

Encryption In Transit: Network Encryption

Every connection between your services and to the internet must be encrypted. Even on your local network β€” networks get compromised, and ARP spoofing on a LAN is trivial.

Connection TypeEncryptionConfiguration
Web Traffic (external)TLS 1.3 (HTTPS)Let's Encrypt or Cloudflare (automatic)
Remote AccessWireGuard VPNPeer-to-peer, <1ms overhead, UDP-based
Server-to-ServerSSH Tunnelssh -L 5432:localhost:5432 user@db-server
Internal API CallsmTLS or SSH TunnelService mesh or manual tunnels
Docker Swarm OverlayIPSec (automatic)docker network create --opt encrypted
ℹ️ Encrypt Ollama API

Ollama listens on http://localhost:11434 by default β€” unencrypted. When other machines on the network access it, all prompt traffic flows in plaintext. Solution: reverse proxy with TLS in front, or SSH tunnel.

πŸ’‘ WireGuard over OpenVPN

WireGuard is faster, simpler, and more secure than OpenVPN. The configuration fits in 10 lines. On Linux: sudo apt install wireguard. Netbird (netbird.io) offers a managed WireGuard solution for zero-trust networks.

Encryption In Use: RAM Protection

While an LLM processes your data, it sits unencrypted in RAM. An attacker with root access can read memory and extract prompts, responses, and model weights.

TechnologyAvailabilityProtectionOverhead
Intel SGXXeon (server CPUs)Enclaves in RAM5-30%
AMD SEV-SNPEPYC (server CPUs)Encrypted VM memory~2%
ARM CCAARMv9+Realms (isolated regions)Low
Software SolutionsEverywhereMemory scrubbing, ASLRMinimal
ℹ️ Irrelevant for most homelabs

Confidential Computing (Intel SGX, AMD SEV) is primarily relevant for cloud scenarios where you do not trust the hoster. In your own homelab, you control the hardware. The practical measures: encrypt swap (prevents plaintext RAM paging), enable screen lock (prevents physical access), and do not leave unnecessary root sessions open.

Encryption Checklist for Self-Hosted AI

MeasurePriorityStatus Check
LUKS on backup volumesMANDATORYlsblk -o NAME,TYPE,FSTYPE | grep crypt
Swap encryptedMANDATORYswapon --show + /etc/crypttab
TLS for all web servicesMANDATORYcurl -vI https://your-service.local
SSH Key-Only (no password)MANDATORYgrep PasswordAuth /etc/ssh/sshd_config
WireGuard for remote accessHIGHwg show
Docker overlay encryptedHIGHdocker network inspect --format '{{.Options}}'
Ollama behind reverse proxyHIGHcurl -I https://ollama.local
Database connections TLSMEDIUMpsql 'sslmode=require'

Encryption and GDPR

The GDPR requires "appropriate technical measures" to protect personal data (Art. 32). Encryption is explicitly mentioned as an example. Without encryption, you risk significantly higher penalties in case of a data breach.

⚠️ Encryption reduces notification obligation

GDPR Art. 34: If personal data was encrypted and the key was not compromised, the obligation to notify affected individuals in case of a data breach is waived. This is a strong incentive to deploy encryption everywhere.

πŸ’‘ Learn more

More about data protection for AI applications in our GDPR Basics article and the GDPR Compliance Bundle.

Das Wichtigste

  • βœ“Three encryption phases: At Rest (disk), In Transit (network), In Use (RAM). The first two are mandatory.
  • βœ“LUKS for disks, TLS 1.3 for web traffic, WireGuard for remote access. All standard tools, no specialist knowledge needed.
  • βœ“Encrypt the swap partition! Otherwise RAM contents (prompts, API keys) end up in plaintext on disk.
  • βœ“GDPR Art. 32 explicitly mentions encryption. Encrypted data reduces notification obligations for breaches (Art. 34).
  • βœ“Ollama API runs unencrypted β€” put a reverse proxy with TLS or SSH tunnel in front.

Sources

War dieser Artikel hilfreich?

Next step: move from knowledge to implementation

If you want more than theory: setups, workflows and templates from real operations for teams that want local, documented AI systems.

Why AI Engineering
  • Local and self-hosted by default
  • Documented and auditable
  • Built from our own runtime
  • Made in Austria
Not legal advice.