LLM Secure Inference
LLM inference without secure execution can compromise models and data — without secure inference, inference remains unprotected. Four controls: secure enclave execution, TEE, confidential computing and input/output validation.
What is LLM Secure Inference? Simply Explained
LLM secure inference protects LLM inference through hardware-based isolation: secure enclave execution runs inference in Intel SGX, AMD SEV or ARM TrustZone with remote attestation and memory encryption. Trusted execution environment (TEE) uses cloud confidential computing like AWS Nitro Enclaves or Azure Confidential Computing with VM-level isolation. Confidential computing uses homomorphic encryption or secure multi-party computation to compute on encrypted data without decrypting it. Input/output validation validates and sanitises all inputs and outputs in the secure enclave to prevent attacks.
↓ Jump to secure inference controls
4 Secure Inference Controls
Execute LLM inference in secure enclaves. Use Intel SGX, AMD SEV, or ARM TrustZone to protect model and data.
# Moltbot secure enclave execution:
secure_enclave:
enabled: true
# Enclave type:
enclave_type:
# Intel SGX: Software Guard Extensions
# AMD SEV: Secure Encrypted Virtualization
# ARM TrustZone: TrustZone technology
# Select: based on hardware availability
type: "intel_sgx"
# Enclave configuration:
configuration:
# Memory: enclave memory size
memory_size: "128MB"
# Threads: number of enclave threads
threads: 4
# Attestation: remote attestation required
attestation: true
# Model protection:
model_protection:
# Encrypt: model weights in enclave
# Decrypt: only in enclave
# Key: sealed in enclave
# Prevents: model extractionUse TEE for secure LLM inference. Ensure code and data integrity through hardware-based isolation.
# Moltbot TEE execution:
tee:
enabled: true
# TEE framework:
framework:
# Nitro Enclaves: AWS Nitro Enclaves
# Confidential Computing: Azure Confidential Computing
# Shielded VMs: GCP Shielded VMs
# Select: based on cloud provider
provider: "aws_nitro"
# TEE configuration:
configuration:
# CPU: vCPUs allocated to TEE
vcpus: 4
# Memory: memory allocated to TEE
memory: "8GB"
# Storage: encrypted storage for TEE
storage: "encrypted"
# Attestation:
attestation:
enabled: true
# Verify: TEE integrity before inference
# Use: remote attestation
# Validate: TEE identity, measurements
# Block: unattested TEEsUse confidential computing to protect data in use. Encrypt data during computation with homomorphic encryption or secure multi-party computation.
# Moltbot confidential computing:
confidential_computing:
enabled: true
# Homomorphic encryption:
homomorphic_encryption:
enabled: true
# Encrypt: input data before inference
# Compute: on encrypted data
# Decrypt: only output
# Use: FHE or PHE based on requirements
# Secure multi-party computation:
smpc:
enabled: true
# Split: input data across parties
# Compute: without revealing inputs
# Reveal: only final output
# Use: for collaborative inference
# Data protection:
data_protection:
# Protect: input data, model weights, output
# Encrypt: at rest and in use
# Key: secure key management
# Prevents: data leakageValidate all inputs and outputs in the secure enclave. Sanitise inputs to prevent attacks and validate outputs to ensure correctness.
# Moltbot input/output validation:
validation:
enabled: true
# Input validation:
input_validation:
enabled: true
# Validate: input format, size, content
# Sanitise: remove dangerous content
# Check: for prompt injection, malicious patterns
# Block: invalid or malicious inputs
# Output validation:
output_validation:
enabled: true
# Validate: output format, size, content
# Sanitise: remove dangerous content
# Check: for hallucinations, bias, PII
# Flag: suspicious outputs
# Validation logging:
logging:
enabled: true
# Log: all validation attempts
# Track: validation success/failure
# Audit: validation historyFrequently Asked Questions
What is the difference between secure enclaves and TEEs?
Secure enclaves (e.g., Intel SGX, AMD SEV, ARM TrustZone) are hardware-based isolated execution environments that protect code and data from the rest of the system. They provide memory encryption and remote attestation. Trusted Execution Environments (TEEs) are cloud-based confidential computing services (AWS Nitro Enclaves, Azure Confidential Computing, GCP Shielded VMs) that provide similar isolation at the virtual machine level. Both provide hardware-based isolation, but secure enclaves are CPU-level while TEEs are VM-level. Secure enclaves require specific hardware support, while TEEs are cloud-managed services.
How does confidential computing protect LLM inference?
Confidential computing protects data in use during LLM inference. Homomorphic encryption allows computation on encrypted data without decryption. The input data is encrypted, the model computes on the encrypted data, and only the output is decrypted. This ensures that the input data is never exposed to the model or the inference infrastructure. Secure multi-party computation (SMPC) splits input data across parties, computes without revealing inputs, and reveals only the final output. Both techniques provide strong privacy guarantees but are computationally expensive.
How does remote attestation work?
Remote attestation allows a verifier to confirm that a secure enclave or TEE is running genuine, unmodified code. The enclave/TEE generates a cryptographic attestation report that includes measurements of the code and data loaded into the enclave. The verifier validates the attestation report against expected values. If validation succeeds, the verifier knows the enclave is running the expected code in a secure environment. Remote attestation prevents attackers from running malicious code in the enclave or tampering with the enclave.
What are the performance implications of secure inference?
Secure inference using secure enclaves, TEEs, or confidential computing has performance overhead: 1) Enclave isolation adds latency due to context switches and memory encryption. 2) Homomorphic encryption is 100-1000x slower than plaintext computation. 3) SMPC adds communication overhead and computational cost. 4) Input/output validation adds latency. Optimisation strategies: 1) Use hardware-accelerated encryption. 2) Batch operations to amortise overhead. 3) Use PHE instead of FHE when possible. 4) Cache validation results. 5) Use hybrid approaches (partial decryption for intermediate steps).