From patchwork Wed Jan 22 11:36:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 313215 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 72BBA2C00B3 for ; Wed, 22 Jan 2014 22:36:47 +1100 (EST) Received: from localhost ([::1]:34753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5w6u-0001yb-E0 for incoming@patchwork.ozlabs.org; Wed, 22 Jan 2014 06:36:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5w6Z-0001hv-E7 for qemu-devel@nongnu.org; Wed, 22 Jan 2014 06:36:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5w6U-0001Nv-LL for qemu-devel@nongnu.org; Wed, 22 Jan 2014 06:36:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5w6U-0001Nl-DF for qemu-devel@nongnu.org; Wed, 22 Jan 2014 06:36:18 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0MBaGfq021701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Jan 2014 06:36:16 -0500 Received: from localhost.localdomain.com (vpn1-5-219.ams2.redhat.com [10.36.5.219]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0MBaDfW008961; Wed, 22 Jan 2014 06:36:13 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Wed, 22 Jan 2014 11:36:01 +0000 Message-Id: <1390390561-14901-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH] Describe flaws in qcow/qcow2 encryption in the docs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The qemu-img.texi / qemu-doc.texi files currently describe the qcow2/qcow2 encryption thus "Encryption uses the AES format which is very secure (128 bit keys). Use a long password (16 characters) to get maximum protection." While AES is indeed a strong encryption system, the way that QCow/QCow2 use it results in a poor/weak encryption system. Due to the use of predictable IVs it is vulnerable to chosen plaintext attacks which can reveal the existance of encrypted data. The direct use of the user passphrase as the encryption key also leads to an inability to change the passphrase of an image. If passphrase is ever compromised the image data will all be vulnerable, since it cannot be re-encrypted. The admin has to clone the image files with a new passphrase and then use a program like shred to secure erase all the old files. Recommend against any use of QCow/QCow2 encryption, directing users to dm-crypt / LUKS which can meet modern cryptography best practices. Signed-off-by: Daniel P. Berrange --- qemu-doc.texi | 23 ++++++++++++++++++++--- qemu-img.texi | 23 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) BTW, I based this patch on info from this previous thread: https://lists.gnu.org/archive/html/qemu-devel/2013-07/msg04225.html If anyone knows of further flaws in qcow2 encryption that we should describe, I'll update the docs further. diff --git a/qemu-doc.texi b/qemu-doc.texi index 4e9c6e9..c9da6ad 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -547,10 +547,27 @@ File name of a base image (see @option{create} subcommand) @item backing_fmt Image format of the base image @item encryption -If this option is set to @code{on}, the image is encrypted. +If this option is set to @code{on}, the image is encrypted with 128-bit AES-CBC. + +The use of encryption in QCow and QCow2 images is considered to flawed by modern +cryptography standards, suffering from a number of design problems + +@itemize @minus +@item The AES-CBC cipher is used with predictable initialization vectors based +on the sector number. This makes it vulnerable to chosen plaintext attacks +which can reveal the existence of encrypted data. +@item The user passphrase is directly used as the encryption key. A poorly +choosen / short passphrase will compromise the security of the encryption. +In the event of the passphrase being compromised there is no way to change +the passphrase to protect data in any QCow images. The files must be cloned, +using a different encryption passphrase in the new file. The original file +must then be securely erased using a program like shred, though even this +is ineffective with many modern storage technologies. +@end itemize -Encryption uses the AES format which is very secure (128 bit keys). Use -a long password (16 characters) to get maximum protection. +Use of QCow / QCow2 encryption is thus strongly discouraged. Users are +recommended to use an alternative encryption technology such as the +Linux dm-crypt / LUKS system. @item cluster_size Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster diff --git a/qemu-img.texi b/qemu-img.texi index 1bba91e..2192eb9 100644 --- a/qemu-img.texi +++ b/qemu-img.texi @@ -402,10 +402,27 @@ File name of a base image (see @option{create} subcommand) @item backing_fmt Image format of the base image @item encryption -If this option is set to @code{on}, the image is encrypted. +If this option is set to @code{on}, the image is encrypted with 128-bit AES-CBC. -Encryption uses the AES format which is very secure (128 bit keys). Use -a long password (16 characters) to get maximum protection. +The use of encryption in QCow and QCow2 images is considered to flawed by modern +cryptography standards, suffering from a number of design problems + +@itemize @minus +@item The AES-CBC cipher is used with predictable initialization vectors based +on the sector number. This makes it vulnerable to chosen plaintext attacks +which can reveal the existence of encrypted data. +@item The user passphrase is directly used as the encryption key. A poorly +choosen / short passphrase will compromise the security of the encryption. +In the event of the passphrase being compromised there is no way to change +the passphrase to protect data in any QCow images. The files must be cloned, +using a different encryption passphrase in the new file. The original file +must then be securely erased using a program like shred, though even this +is ineffective with many modern storage technologies. +@end itemize + +Use of QCow / QCow2 encryption is thus strongly discouraged. Users are +recommended to use an alternative encryption technology such as the +Linux dm-crypt / LUKS system. @item cluster_size Changes the qcow2 cluster size (must be between 512 and 2M). Smaller cluster