summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>2020-12-15 15:22:48 +0800
committerArmin Kuster <akuster808@gmail.com>2021-01-10 19:43:27 -0800
commit28a08b88ef17286cd163b8472561450a3ec04e48 (patch)
tree906a4a7584620e105189c34e16afc120c1ca813f
parent8d4826f656e07802cb7c2455164855aa0c5fee9c (diff)
downloadmeta-openembedded-28a08b88ef17286cd163b8472561450a3ec04e48.tar.gz
php: CVE-2020-7069
Security Advisory References https://nvd.nist.gov/vuln/detail/CVE-2020-7069 https://bugs.php.net/patch-display.php?bug_id=79601&patch=openssl_aes_ccm_iv_fix&revision=latest Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com> Signed-off-by: Khem Raj <raj.khem@gmail.com> (cherry picked from commit fa80193468745a11bc12d5845f66412a0d62e0e2) Signed-off-by: Armin Kuster <akuster808@gmail.com> (cherry picked from commit 992e09f09a40e7a8d03c7c4b5adf40f821ed3774) Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-oe/recipes-devtools/php/php/CVE-2020-7069.patch158
-rw-r--r--meta-oe/recipes-devtools/php/php_7.4.9.bb1
2 files changed, 159 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/php/php/CVE-2020-7069.patch b/meta-oe/recipes-devtools/php/php/CVE-2020-7069.patch
new file mode 100644
index 0000000000..0cf4d5ed60
--- /dev/null
+++ b/meta-oe/recipes-devtools/php/php/CVE-2020-7069.patch
@@ -0,0 +1,158 @@
1Subject: Fix bug #79601 (Wrong ciphertext/tag in AES-CCM encryption
2 for a 12 bytes IV)
3
4---
5 ext/openssl/openssl.c | 10 ++++-----
6 ext/openssl/tests/cipher_tests.inc | 21 +++++++++++++++++
7 ext/openssl/tests/openssl_decrypt_ccm.phpt | 22 +++++++++++-------
8 ext/openssl/tests/openssl_encrypt_ccm.phpt | 26 ++++++++++++++--------
9 4 files changed, 57 insertions(+), 22 deletions(-)
10
11diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
12index 04cb9b0f..fdad2c3b 100644
13--- a/ext/openssl/openssl.c
14+++ b/ext/openssl/openssl.c
15@@ -6521,11 +6521,6 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
16 {
17 char *iv_new;
18
19- /* Best case scenario, user behaved */
20- if (*piv_len == iv_required_len) {
21- return SUCCESS;
22- }
23-
24 if (mode->is_aead) {
25 if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) {
26 php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed");
27@@ -6534,6 +6529,11 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
28 return SUCCESS;
29 }
30
31+ /* Best case scenario, user behaved */
32+ if (*piv_len == iv_required_len) {
33+ return SUCCESS;
34+ }
35+
36 iv_new = ecalloc(1, iv_required_len + 1);
37
38 if (*piv_len == 0) {
39diff --git a/ext/openssl/tests/cipher_tests.inc b/ext/openssl/tests/cipher_tests.inc
40index b1e46b41..779bfa85 100644
41--- a/ext/openssl/tests/cipher_tests.inc
42+++ b/ext/openssl/tests/cipher_tests.inc
43@@ -1,5 +1,26 @@
44 <?php
45 $php_openssl_cipher_tests = array(
46+ 'aes-128-ccm' => array(
47+ array(
48+ 'key' => '404142434445464748494a4b4c4d4e4f',
49+ 'iv' => '1011121314151617',
50+ 'aad' => '000102030405060708090a0b0c0d0e0f',
51+ 'tag' => '1fc64fbfaccd',
52+ 'pt' => '202122232425262728292a2b2c2d2e2f',
53+ 'ct' => 'd2a1f0e051ea5f62081a7792073d593d',
54+ ),
55+ array(
56+ 'key' => '404142434445464748494a4b4c4d4e4f',
57+ 'iv' => '101112131415161718191a1b',
58+ 'aad' => '000102030405060708090a0b0c0d0e0f' .
59+ '10111213',
60+ 'tag' => '484392fbc1b09951',
61+ 'pt' => '202122232425262728292a2b2c2d2e2f' .
62+ '3031323334353637',
63+ 'ct' => 'e3b201a9f5b71a7a9b1ceaeccd97e70b' .
64+ '6176aad9a4428aa5',
65+ ),
66+ ),
67 'aes-256-ccm' => array(
68 array(
69 'key' => '1bde3251d41a8b5ea013c195ae128b21' .
70diff --git a/ext/openssl/tests/openssl_decrypt_ccm.phpt b/ext/openssl/tests/openssl_decrypt_ccm.phpt
71index a5f01b87..08ef5bb7 100644
72--- a/ext/openssl/tests/openssl_decrypt_ccm.phpt
73+++ b/ext/openssl/tests/openssl_decrypt_ccm.phpt
74@@ -10,14 +10,16 @@ if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
75 --FILE--
76 <?php
77 require_once __DIR__ . "/cipher_tests.inc";
78-$method = 'aes-256-ccm';
79-$tests = openssl_get_cipher_tests($method);
80+$methods = ['aes-128-ccm', 'aes-256-ccm'];
81
82-foreach ($tests as $idx => $test) {
83- echo "TEST $idx\n";
84- $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
85- $test['iv'], $test['tag'], $test['aad']);
86- var_dump($test['pt'] === $pt);
87+foreach ($methods as $method) {
88+ $tests = openssl_get_cipher_tests($method);
89+ foreach ($tests as $idx => $test) {
90+ echo "$method - TEST $idx\n";
91+ $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
92+ $test['iv'], $test['tag'], $test['aad']);
93+ var_dump($test['pt'] === $pt);
94+ }
95 }
96
97 // no IV
98@@ -32,7 +34,11 @@ var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA,
99
100 ?>
101 --EXPECTF--
102-TEST 0
103+aes-128-ccm - TEST 0
104+bool(true)
105+aes-128-ccm - TEST 1
106+bool(true)
107+aes-256-ccm - TEST 0
108 bool(true)
109
110 Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in %s on line %d
111diff --git a/ext/openssl/tests/openssl_encrypt_ccm.phpt b/ext/openssl/tests/openssl_encrypt_ccm.phpt
112index fb5dbbc8..8c4c41f8 100644
113--- a/ext/openssl/tests/openssl_encrypt_ccm.phpt
114+++ b/ext/openssl/tests/openssl_encrypt_ccm.phpt
115@@ -10,15 +10,17 @@ if (!in_array('aes-256-ccm', openssl_get_cipher_methods()))
116 --FILE--
117 <?php
118 require_once __DIR__ . "/cipher_tests.inc";
119-$method = 'aes-256-ccm';
120-$tests = openssl_get_cipher_tests($method);
121+$methods = ['aes-128-ccm', 'aes-256-ccm'];
122
123-foreach ($tests as $idx => $test) {
124- echo "TEST $idx\n";
125- $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
126- $test['iv'], $tag, $test['aad'], strlen($test['tag']));
127- var_dump($test['ct'] === $ct);
128- var_dump($test['tag'] === $tag);
129+foreach ($methods as $method) {
130+ $tests = openssl_get_cipher_tests($method);
131+ foreach ($tests as $idx => $test) {
132+ echo "$method - TEST $idx\n";
133+ $ct = openssl_encrypt($test['pt'], $method, $test['key'], OPENSSL_RAW_DATA,
134+ $test['iv'], $tag, $test['aad'], strlen($test['tag']));
135+ var_dump($test['ct'] === $ct);
136+ var_dump($test['tag'] === $tag);
137+ }
138 }
139
140 // Empty IV error
141@@ -32,7 +34,13 @@ var_dump(strlen($tag));
142 var_dump(openssl_encrypt('data', $method, 'password', 0, str_repeat('x', 16), $tag, '', 1024));
143 ?>
144 --EXPECTF--
145-TEST 0
146+aes-128-ccm - TEST 0
147+bool(true)
148+bool(true)
149+aes-128-ccm - TEST 1
150+bool(true)
151+bool(true)
152+aes-256-ccm - TEST 0
153 bool(true)
154 bool(true)
155
156--
1572.25.1
158
diff --git a/meta-oe/recipes-devtools/php/php_7.4.9.bb b/meta-oe/recipes-devtools/php/php_7.4.9.bb
index 73caed6543..16fc311b0e 100644
--- a/meta-oe/recipes-devtools/php/php_7.4.9.bb
+++ b/meta-oe/recipes-devtools/php/php_7.4.9.bb
@@ -31,6 +31,7 @@ SRC_URI_append_class-target = " \
31 file://0001-opcache-config.m4-enable-opcache.patch \ 31 file://0001-opcache-config.m4-enable-opcache.patch \
32 file://xfail_two_bug_tests.patch \ 32 file://xfail_two_bug_tests.patch \
33 file://CVE-2020-7070.patch \ 33 file://CVE-2020-7070.patch \
34 file://CVE-2020-7069.patch \
34 " 35 "
35 36
36S = "${WORKDIR}/php-${PV}" 37S = "${WORKDIR}/php-${PV}"