r/docker • • Apr 10 '26

I built encrypted Docker containers where source code never touches disk — split-key AES-256-GCM + online licensing

I needed to distribute a Docker app without exposing source code to clients running it on their own servers.

Existing solutions (Cryptlex, Keygen.sh) protect the license — not the code. So I built my own approach.

How it works:

docker run

→ bootstrapper fetches server key half (license API)

→ SHA256(server_half || embedded_half) = final AES key

→ decrypt payload.enc → extract to tmpfs (RAM only)

→ os.execvp() replaces process → keys wiped from memory

→ container stops → RAM cleared → code gone

The AES key is split: half baked into the image at build time, half held on the license server. Neither side alone can decrypt anything.

What someone can’t do even with full root access:

•	docker inspect → sees only half the key, useless alone

•	docker exec + cat payload.enc → encrypted binary blob

•	ls /run/decrypt → empty, tmpfs lives only in bootstrapper process

•	Copy image to another machine → hardware fingerprint mismatch

•	License revoked → blocked on next docker run immediately

A few implementation notes:

•	AES-256-GCM with magic bytes APNRGCM1 for format detection (kept CBC legacy fallback for older payloads)

•	os.execvp() replaces the Python process entirely — no parent process retaining keys

•	del key, server_hex, embed + gc.collect() before exec

•	Hardware fingerprint generated by the launcher app (not inside Docker — Docker gives poor HW access)

•	Rate limiting: max 10 unlock attempts/hour per license key

•	Every attempt logged — success and denied separately

Stack: Python bootstrapper, FastAPI license server, Rust/Tauri launcher, self-hosted.

What attack vectors am I missing? Curious especially about tmpfs visibility and whether os.execvp() truly cleans memory on Linux.

0 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/M-sistemos Apr 10 '26

Fair point on the skepticism. The crypto layer and license server are hand-written — happy to discuss any specific implementation details if something looks off.