diff options
| author | Yi Zhao <yi.zhao@windriver.com> | 2021-07-07 11:23:38 +0800 |
|---|---|---|
| committer | Jia Zhang <zhang.jia@linux.alibaba.com> | 2021-07-07 14:26:45 +0800 |
| commit | 0e8603b1eab73e94880075b406f609d1be0ce41c (patch) | |
| tree | f194bf18ab8c12d3442973ccf4c9407cabc585a3 | |
| parent | ba04fbba711217e2a7c10270fe932146564f6229 (diff) | |
| download | meta-secure-core-0e8603b1eab73e94880075b406f609d1be0ce41c.tar.gz | |
tpm2-tools: fix CVE-2021-3565
CVE-2021-3565:
A flaw was found in tpm2-tools in versions before 5.1.1 and before
4.3.2. tpm2_import used a fixed AES key for the inner wrapper,
potentially allowing a MITM attacker to unwrap the inner portion and
reveal the key being imported. The highest threat from this
vulnerability is to data confidentiality.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2021-3565
Patch from:
https://github.com/tpm2-software/tpm2-tools/commit/c069e4f179d5e6653a84fb236816c375dca82515
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
| -rw-r--r-- | meta-tpm2/recipes-tpm/tpm2-tools/files/CVE-2021-3565.patch | 53 | ||||
| -rw-r--r-- | meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_4.1.3.bb | 1 |
2 files changed, 54 insertions, 0 deletions
diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/files/CVE-2021-3565.patch b/meta-tpm2/recipes-tpm/tpm2-tools/files/CVE-2021-3565.patch new file mode 100644 index 0000000..9402f1b --- /dev/null +++ b/meta-tpm2/recipes-tpm/tpm2-tools/files/CVE-2021-3565.patch | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | From 47b3b6e6fffed7080a2f1ce7673207ea44823ef7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: William Roberts <william.c.roberts@intel.com> | ||
| 3 | Date: Fri, 21 May 2021 12:22:31 -0500 | ||
| 4 | Subject: [PATCH] tpm2_import: fix fixed AES key CVE-2021-3565 | ||
| 5 | |||
| 6 | tpm2_import used a fixed AES key for the inner wrapper, which means that | ||
| 7 | a MITM attack would be able to unwrap the imported key. Even the | ||
| 8 | use of an encrypted session will not prevent this. The TPM only | ||
| 9 | encrypts the first parameter which is the fixed symmetric key. | ||
| 10 | |||
| 11 | To fix this, ensure the key size is 16 bytes or bigger and use | ||
| 12 | OpenSSL to generate a secure random AES key. | ||
| 13 | |||
| 14 | Fixes: #2738 | ||
| 15 | |||
| 16 | Signed-off-by: William Roberts <william.c.roberts@intel.com> | ||
| 17 | |||
| 18 | Upstream-Status: Backport | ||
| 19 | [https://github.com/tpm2-software/tpm2-tools/commit/c069e4f179d5e6653a84fb236816c375dca82515] | ||
| 20 | |||
| 21 | CVE: CVE-2021-3565 | ||
| 22 | |||
| 23 | Signed-off-by: Yi Zhao <yi.zhao@windriver.com> | ||
| 24 | --- | ||
| 25 | tools/tpm2_import.c | 12 +++++++++++- | ||
| 26 | 1 file changed, 11 insertions(+), 1 deletion(-) | ||
| 27 | |||
| 28 | diff --git a/tools/tpm2_import.c b/tools/tpm2_import.c | ||
| 29 | index 50072894..ee5dec15 100644 | ||
| 30 | --- a/tools/tpm2_import.c | ||
| 31 | +++ b/tools/tpm2_import.c | ||
| 32 | @@ -118,7 +118,17 @@ static tool_rc key_import(ESYS_CONTEXT *ectx, TPM2B_PUBLIC *parent_pub, | ||
| 33 | TPM2B_DATA enc_sensitive_key = { | ||
| 34 | .size = parent_pub->publicArea.parameters.rsaDetail.symmetric.keyBits.sym / 8 | ||
| 35 | }; | ||
| 36 | - memset(enc_sensitive_key.buffer, 0xFF, enc_sensitive_key.size); | ||
| 37 | + | ||
| 38 | + if(enc_sensitive_key.size < 16) { | ||
| 39 | + LOG_ERR("Calculated wrapping keysize is less than 16 bytes, got: %u", enc_sensitive_key.size); | ||
| 40 | + return tool_rc_general_error; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + int ossl_rc = RAND_bytes(enc_sensitive_key.buffer, enc_sensitive_key.size); | ||
| 44 | + if (ossl_rc != 1) { | ||
| 45 | + LOG_ERR("RAND_bytes failed: %s", ERR_error_string(ERR_get_error(), NULL)); | ||
| 46 | + return tool_rc_general_error; | ||
| 47 | + } | ||
| 48 | |||
| 49 | /* | ||
| 50 | * Calculate the object name. | ||
| 51 | -- | ||
| 52 | 2.25.1 | ||
| 53 | |||
diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_4.1.3.bb b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_4.1.3.bb index 8748a47..1df2d40 100644 --- a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_4.1.3.bb +++ b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_4.1.3.bb | |||
| @@ -8,6 +8,7 @@ DEPENDS = "tpm2-abrmd tpm2-tss openssl curl autoconf-archive" | |||
| 8 | 8 | ||
| 9 | SRC_URI = "https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \ | 9 | SRC_URI = "https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \ |
| 10 | file://0001-tests-switch-to-python3.patch \ | 10 | file://0001-tests-switch-to-python3.patch \ |
| 11 | file://CVE-2021-3565.patch \ | ||
| 11 | " | 12 | " |
| 12 | 13 | ||
| 13 | SRC_URI[md5sum] = "48e0f58232b6a86fe4d007acf12af283" | 14 | SRC_URI[md5sum] = "48e0f58232b6a86fe4d007acf12af283" |
