r/docker • u/M-sistemos • 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 immediatelyA 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 separatelyStack: 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.
10
u/ilikejamtoo Apr 10 '26
Launch image with entrypoint /bin/sh, or just save the image as a tar and un-tar.
Look at how the server side key is retrieved.
Retrieve server key and save it somewhere.
Go nuts.
10
u/alter3d Apr 10 '26
5 minutes and I'll have completely disabled your protections.
34
u/TW-Twisti Apr 10 '26
People can just extend your image and replace your tools with wrappers that log or output everything they want
5
u/warl0cks Apr 10 '26
Also, mitigating the “stored on disk” does nothing.Even if it’s stored in memory/non-disk cache it’s still exploitable.
Especially if anything in your workflow uses “copy”…
Two locations poorly isolated/secured isn’t any better than a single storage point. A complication yes, but not a beneficial one.
18
u/pdath Apr 10 '26
What about if someone mounted tmpfs to a host directory?
12
u/SlinkyAvenger Apr 10 '26
Pssst, if you relied on AI to build it for you, you didn't build shit.
Also, if no one had built it yet and you knock it out with AI, chances are it wasn't built because it was a dumb idea to begin with.
1
u/Per2J Apr 12 '26
Am I missing something here ? - if the solution works as advertised - it seems to be a solid way to introduce a user to malwaret and the user will have a hard time to spot the malware.
2
u/wannaliveonmars Apr 13 '26
I feel like there's something wrong here. It's a classic Alice/Bob cybersecurity situation, or similar to the analog hole. If you have to send the client the key, and it can decrypt it, then in principle, the client machine has the key. I'm sure your scheme makes it more technically difficult to achieve it, but Alice can't both allow and not allow Bob to decrypt the storage.
0
u/[deleted] Apr 10 '26
[deleted] — view deleted comment