A complete development environment for experimenting with AWS Nitro Enclaves using QEMU VM simulation. This project provides a local development setup that mimics the Nitro Enclave environment, allowing you to develop, test, and debug enclave applications without needing actual AWS hardware.
AWS Nitro Enclaves provide a secure, isolated compute environment for highly sensitive data and workloads. Here are some of the most common and impactful use cases:
- Trusted Execution Environment (TEE): Run code in a hardware-isolated environment, protecting against host OS and hypervisor attacks.
- Processing Personally Identifiable Information (PII): Securely process, analyze, or transform sensitive user data (e.g., healthcare, finance, government).
- Embedded Wallet Infrastructure: Store and use private keys for cryptocurrency wallets in a way that keys never leave the enclave.
- Multi-Party Computation (MPC) Wallet Infrastructure: Run MPC protocols for digital asset custody, ensuring key shares are never exposed outside the enclave.
- Payment and Transaction Signing: Sign blockchain or financial transactions securely, with private keys protected by the enclave.
- Confidential Machine Learning: Run ML inference or training on sensitive data without exposing the data to the host or cloud provider.
- Secure API Gateways: Decrypt, process, and re-encrypt sensitive API payloads (e.g., payment info, health records) in a trusted environment.
- Data Decryption and Re-encryption: Decrypt data for processing and re-encrypt before storage or transmission, with keys only accessible inside the enclave.
- Digital Rights Management (DRM): Enforce DRM policies and process protected content securely.
- Attestation and Remote Proof: Prove to external parties that code is running in a genuine enclave and has not been tampered with.
- Secure Credential Brokering: Issue short-lived credentials or tokens after verifying policies inside the enclave.
- Confidential Data Aggregation: Aggregate sensitive data from multiple sources without exposing raw data to any party.
- Regulatory Compliance: Meet requirements for data residency, privacy, and auditability by isolating sensitive workloads.
- Secure Voting and Polling: Run cryptographically secure voting or polling applications.
- Secure Document Processing: Process, sign, or watermark documents in a tamper-proof environment.
- Custom Hardware Security Module (HSM) Replacement: Use enclaves as a software-based HSM for key management and cryptographic operations.
These use cases demonstrate the versatility of Nitro Enclaves for any scenario requiring strong isolation, confidentiality, and integrity guarantees for code and data.
# Start the complete environment (order matters!)
make setup-vm # Boot the QEMU VM first
# ⚠️ IMPORTANT: Wait for VM to fully boot before continuing!
# You'll see a login prompt when ready. Press Ctrl+A, then X to exit QEMU.
make start-enclave # Build and start enclave inside the VM
make start-vsock-proxy # Start localstack, setup KMS, and run vsock-proxy
make start-connector # Start the connector Go application last
# View enclave logs
make view-logs- OS: Linux (Ubuntu 20.04+ recommended)
- RAM: At least 4GB available
- Storage: 10GB free space
- CPU: x86_64 with KVM support
# Install QEMU and KVM
sudo apt update
sudo apt install -y qemu-kvm qemu-system-x86 cloud-localds
# Install Docker and Docker Compose
sudo apt install -y docker.io docker-compose
sudo usermod -aG docker $USER
# Install Go (1.19+)
wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc# Generate SSH key for VM access
ssh-keygen -t rsa -b 4096 -f ~/.ssh/dev-vm -N ""This development environment simulates the AWS Nitro Enclave architecture with a complete roundtrip communication flow:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Host System │ │ QEMU VM │ │ LocalStack │
│ │ │ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Connector │ │ │ │ Enclave │ │ │ │ KMS │ │
│ │ │ │ │ │ │ │ │ │ │ │
│ └─────────────┘ │ │ └─────────────┘ │ │ └─────────────┘ │
│ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │
│ ┌─────────────┐ │ │ │ │ │ │ │
│ │VSOCK Proxy │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │
│ └─────────────┘ │ │ │ │ │ │ │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ │ │
└───────────────────────┼───────────────────────┘
│
┌───────────▼───────────┐
│ Communication Flow │
│ │
│ 1. Connector → Enclave│
│ 2. Enclave → VSOCK │
│ 3. VSOCK → KMS │
│ 4. KMS → VSOCK │
│ 5. VSOCK → Enclave │
│ 6. Enclave → Connector│
└───────────────────────┘
Important: The startup order is critical for proper communication:
- VM must be running first to provide the enclave environment
- Enclave must be started inside the VM before proxy setup
- VSOCK Proxy must be running to handle host-VM communication
- Connector starts last to initiate communication with the enclave
- Connector → Enclave: Host application sends request to enclave
- Enclave → VSOCK Proxy: Enclave forwards request through VSOCK
- VSOCK Proxy → KMS: Proxy routes request to LocalStack KMS
- KMS → VSOCK Proxy: KMS processes request and returns response
- VSOCK Proxy → Enclave: Proxy forwards KMS response back to enclave
- Enclave → Connector: Enclave processes response and returns to host
- QEMU VM: Simulates the Nitro Enclave environment
- Enclave: Your secure application running inside the VM
- Connector: Host application that communicates with the enclave
- VSOCK Proxy: Handles communication between host and VM
- LocalStack: Local AWS services (KMS) for development
make setup-vmCtrl+A, then X.
This boots the QEMU VM with:
- Cloud-init for automatic setup
- VSOCK support for enclave communication
- SSH access on port 2222
- Network forwarding for development
make start-enclaveThis:
- Builds the enclave application
- Copies it to the VM
- Starts it as a background process
make start-vsock-proxyThis command:
- Starts LocalStack (local AWS services)
- Sets up KMS with test keys
- Starts the VSOCK proxy for host-VM communication
make start-connectorThis builds and starts the connector application that will communicate with the enclave.
make ssh-vmmake view-logsmake get-logs# Build all applications
make build-all
# Build specific applications
make build-enclave
make build-connector
make build-vsock-proxy# SSH into VM and check processes
make ssh-vm
ps aux | grep enclave# Real-time log viewing
make view-logs
# Copy logs to host for analysis
make get-logs
ls -la vm-logs/# From host
netstat -tlnp | grep :9000
# From VM (after SSH)
netstat -tlnpIf you encounter communication problems, ensure the correct startup order:
# 1. Always start VM first
make setup-vm
# ⚠️ Wait for VM to fully boot (you'll see login prompt), then press Ctrl+A, X to exit
# 2. Start enclave inside VM
make start-enclave
# 3. Start VSOCK proxy environment
make start-vsock-proxy
# 4. Start connector last
make start-connectorIf you get port conflicts:
# Kill all development processes
make kill-all
# Check what's using the ports
lsof -i :2222 -i :9000# Force kill all QEMU processes
pkill -9 -f qemu-system-x86_64
# Rebuild VM
make clean
make setup-vm# Restart Docker services
docker-compose down
docker-compose up -dnitro-dev-qemu/
├── cmd/
│ ├── enclave/ # Enclave application
│ ├── connector/ # Host connector application
│ └── vsock-proxy/ # VSOCK proxy for communication
├── cloud-init.yaml # VM initialization configuration
├── docker-compose.yaml # LocalStack and VSOCK proxy services
├── kms-test-policy.json # KMS policy for development
├── Makefile # Development automation
└── README.md # This file
- Basic Enclave Communication: Modify the enclave and connector to exchange encrypted messages
- KMS Integration: Use the local KMS to encrypt/decrypt data
- Attestation Simulation: Implement basic attestation protocols
- Multi-Enclave Setup: Run multiple enclaves in the same VM
- Custom VSOCK Protocols: Implement custom communication protocols
Edit the configuration variables in the Makefile:
VM_MEM=1024 # VM memory in MB
VM_CPUS=2 # Number of CPU cores
VSOCK_PORT=9000 # VSOCK communication port
SSH_PORT=2222 # SSH access port- Modify
cmd/enclave/for enclave application logic - Modify
cmd/connector/for host application logic - Modify
cmd/vsock-proxy/for communication protocols
- AWS Nitro Enclaves Documentation
- QEMU Documentation
- LocalStack Documentation
- Go Programming Language
Happy Enclave Development! 🚀