VM Cloning and Linux Random Number Generation: Security Implications and Solutions
This document analyzes the security implications of restoring multiple VM clones from a single snapshot. Linux exposes three main RNG interfaces: /dev/random, /dev/urandom, and the getrandom syscall. Cloning VMs leads to inconsistent RNG states due to multiple parameters (like timer data or CPU HWRNG instruction outputs) being mixed into each result. The article examines different implementations of RNGs in newer and older kernels and proposes solutions: reinitializing the RNG after restore, using the virtio-rng device, and leveraging the VMGenID mechanism (introduced in Linux 5.18 and later) to address inconsistent RNG states after cloning.