Skip to content

Commit 5650740

Browse files
MAGECLOUD-12969: security fix patch
1 parent 4a50068 commit 5650740

8 files changed

+821
-1
lines changed

patches.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,16 @@
282282
">=2.4.4 <2.4.7": "MCLOUD-11514__enhanced_layout_cache_efficiency__2.4.6-p3.patch"
283283
},
284284
"Patch for CVE-2024-34102 - CosmicSting": {
285-
">=2.4.4 <2.4.8": "MCLOUD-12969__Patch_for_CVE_2024_34102_CosmicSting__2.4.7.patch"
285+
">=2.4.4 <2.4.5": "MCLOUD-12969__Patch_for_CVE_2024_34102_CosmicSting__2.4.4.patch",
286+
">=2.4.5 <2.4.6": "MCLOUD-12969__Patch_for_CVE_2024_34102_CosmicSting__2.4.5.patch",
287+
">=2.4.6 <2.4.7": "MCLOUD-12969__Patch_for_CVE_2024_34102_CosmicSting__2.4.6.patch",
288+
">=2.4.7 <2.4.8": "MCLOUD-12969__Patch_for_CVE_2024_34102_CosmicSting__2.4.7.patch"
289+
},
290+
"Patch for CVE-2024-34102 - KeyRotation": {
291+
">=2.4.4 <2.4.5": "MCLOUD-12969__Patch_for_CVE_2024_34102_KeyRotation__2.4.4.patch",
292+
">=2.4.5 <2.4.6": "MCLOUD-12969__Patch_for_CVE_2024_34102_KeyRotation__2.4.5.patch",
293+
">=2.4.6 <2.4.7": "MCLOUD-12969__Patch_for_CVE_2024_34102_KeyRotation__2.4.6.patch",
294+
">=2.4.7 <2.4.8": "MCLOUD-12969__Patch_for_CVE_2024_34102_KeyRotation__2.4.7.patch"
286295
}
287296
},
288297
"magento/module-paypal": {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/vendor/magento/theme-frontend-blank/i18n/en_US.csv b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
2+
index a491a567a37..5e8bef787d2 100644
3+
--- a/vendor/magento/theme-frontend-blank/i18n/en_US.csv
4+
+++ b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
5+
@@ -4,3 +4,4 @@ Summary,Summary
6+
Menu,Menu
7+
Account,Account
8+
Settings,Settings
9+
+"Invalid data type","Invalid data type"
10+
diff --git a/vendor/magento/theme-frontend-luma/i18n/en_US.csv b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
11+
index 7bf9e0afaf0..00493cc05ba 100644
12+
--- a/vendor/magento/theme-frontend-luma/i18n/en_US.csv
13+
+++ b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
14+
@@ -54,3 +54,4 @@ Footer,Footer
15+
"Update to your %store_name shipment","Update to your %store_name shipment"
16+
"Address Book","Address Book"
17+
"Account Information","Account Information"
18+
+"Invalid data type","Invalid data type"
19+
diff --git a/vendor/magento/framework/Webapi/ServiceInputProcessor.php b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
20+
index 908a4e70140..cc019845b58 100644
21+
--- a/vendor/magento/framework/Webapi/ServiceInputProcessor.php
22+
+++ b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
23+
@@ -153,6 +153,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
24+
* @return \Magento\Framework\Reflection\NameFinder
25+
*
26+
* @deprecated 100.1.0
27+
+ * @see nothing
28+
*/
29+
private function getNameFinder()
30+
{
31+
@@ -261,6 +262,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
32+
* @throws \Exception
33+
* @throws SerializationException
34+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
35+
+ * @SuppressWarnings(PHPMD.NPathComplexity)
36+
*/
37+
protected function _createFromArray($className, $data)
38+
{
39+
@@ -268,6 +270,12 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
40+
// convert to string directly to avoid situations when $className is object
41+
// which implements __toString method like \ReflectionObject
42+
$className = (string) $className;
43+
+ if (is_subclass_of($className, \SimpleXMLElement::class)
44+
+ || is_subclass_of($className, \DOMElement::class)) {
45+
+ throw new SerializationException(
46+
+ new Phrase('Invalid data type')
47+
+ );
48+
+ }
49+
$class = new ClassReflection($className);
50+
if (is_subclass_of($className, self::EXTENSION_ATTRIBUTES_TYPE)) {
51+
$className = substr($className, 0, -strlen('Interface'));
52+
diff --git a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php
53+
--- a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 022e64b08a88658667bc2d6b922eada2b7910965)
54+
+++ b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 8d2b0c1c6b421cdcd7f62a48a5edc9b0211d92a2)
55+
@@ -35,6 +35,7 @@
56+
public function __construct(DeploymentConfig $deploymentConfig, JwkFactory $jwkFactory)
57+
{
58+
$this->keys = preg_split('/\s+/s', trim((string)$deploymentConfig->get('crypt/key')));
59+
+ $this->keys = [end($this->keys)];
60+
//Making sure keys are large enough.
61+
foreach ($this->keys as &$key) {
62+
$key = str_pad($key, 2048, '&', STR_PAD_BOTH);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
diff --git a/vendor/magento/theme-frontend-blank/i18n/en_US.csv b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
2+
index a491a567a37..5e8bef787d2 100644
3+
--- a/vendor/magento/theme-frontend-blank/i18n/en_US.csv
4+
+++ b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
5+
@@ -4,3 +4,4 @@ Summary,Summary
6+
Menu,Menu
7+
Account,Account
8+
Settings,Settings
9+
+"Invalid data type","Invalid data type"
10+
diff --git a/vendor/magento/theme-frontend-luma/i18n/en_US.csv b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
11+
index 7bf9e0afaf0..00493cc05ba 100644
12+
--- a/vendor/magento/theme-frontend-luma/i18n/en_US.csv
13+
+++ b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
14+
@@ -54,3 +54,4 @@ Footer,Footer
15+
"Update to your %store_name shipment","Update to your %store_name shipment"
16+
"Address Book","Address Book"
17+
"Account Information","Account Information"
18+
+"Invalid data type","Invalid data type"
19+
diff --git a/vendor/magento/framework/Webapi/ServiceInputProcessor.php b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
20+
index a5e881f4be5..a60f1dd7ba1 100644
21+
--- a/vendor/magento/framework/Webapi/ServiceInputProcessor.php
22+
+++ b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
23+
@@ -153,6 +153,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
24+
* @return \Magento\Framework\Reflection\NameFinder
25+
*
26+
* @deprecated 100.1.0
27+
+ * @see nothing
28+
*/
29+
private function getNameFinder()
30+
{
31+
@@ -261,6 +262,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
32+
* @throws \Exception
33+
* @throws SerializationException
34+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
35+
+ * @SuppressWarnings(PHPMD.NPathComplexity)
36+
*/
37+
protected function _createFromArray($className, $data)
38+
{
39+
@@ -268,6 +270,12 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
40+
// convert to string directly to avoid situations when $className is object
41+
// which implements __toString method like \ReflectionObject
42+
$className = (string) $className;
43+
+ if (is_subclass_of($className, \SimpleXMLElement::class)
44+
+ || is_subclass_of($className, \DOMElement::class)) {
45+
+ throw new SerializationException(
46+
+ new Phrase('Invalid data type')
47+
+ );
48+
+ }
49+
$class = new ClassReflection($className);
50+
if (is_subclass_of($className, self::EXTENSION_ATTRIBUTES_TYPE)) {
51+
$className = substr($className, 0, -strlen('Interface'));
52+
diff --git a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php
53+
--- a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 022e64b08a88658667bc2d6b922eada2b7910965)
54+
+++ b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 8d2b0c1c6b421cdcd7f62a48a5edc9b0211d92a2)
55+
@@ -35,6 +35,7 @@
56+
public function __construct(DeploymentConfig $deploymentConfig, JwkFactory $jwkFactory)
57+
{
58+
$this->keys = preg_split('/\s+/s', trim((string)$deploymentConfig->get('crypt/key')));
59+
+ $this->keys = [end($this->keys)];
60+
//Making sure keys are large enough.
61+
foreach ($this->keys as &$key) {
62+
$key = str_pad($key, 2048, '&', STR_PAD_BOTH);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
diff --git a/vendor/magento/theme-frontend-blank/i18n/en_US.csv b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
2+
index a491a567a37..5e8bef787d2 100644
3+
--- a/vendor/magento/theme-frontend-blank/i18n/en_US.csv
4+
+++ b/vendor/magento/theme-frontend-blank/i18n/en_US.csv
5+
@@ -4,3 +4,4 @@ Summary,Summary
6+
Menu,Menu
7+
Account,Account
8+
Settings,Settings
9+
+"Invalid data type","Invalid data type"
10+
diff --git a/vendor/magento/theme-frontend-luma/i18n/en_US.csv b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
11+
index 7bf9e0afaf0..00493cc05ba 100644
12+
--- a/vendor/magento/theme-frontend-luma/i18n/en_US.csv
13+
+++ b/vendor/magento/theme-frontend-luma/i18n/en_US.csv
14+
@@ -54,3 +54,4 @@ Footer,Footer
15+
"Update to your %store_name shipment","Update to your %store_name shipment"
16+
"Address Book","Address Book"
17+
"Account Information","Account Information"
18+
+"Invalid data type","Invalid data type"
19+
diff --git a/vendor/magento/framework/Webapi/ServiceInputProcessor.php b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
20+
index 9d7fd443508..65987772c23 100644
21+
--- a/vendor/magento/framework/Webapi/ServiceInputProcessor.php
22+
+++ b/vendor/magento/framework/Webapi/ServiceInputProcessor.php
23+
@@ -275,6 +275,12 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
24+
// convert to string directly to avoid situations when $className is object
25+
// which implements __toString method like \ReflectionObject
26+
$className = (string) $className;
27+
+ if (is_subclass_of($className, \SimpleXMLElement::class)
28+
+ || is_subclass_of($className, \DOMElement::class)) {
29+
+ throw new SerializationException(
30+
+ new Phrase('Invalid data type')
31+
+ );
32+
+ }
33+
$class = new ClassReflection($className);
34+
if (is_subclass_of($className, self::EXTENSION_ATTRIBUTES_TYPE)) {
35+
$className = substr($className, 0, -strlen('Interface'));
36+
diff --git a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php
37+
--- a/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 022e64b08a88658667bc2d6b922eada2b7910965)
38+
+++ b/vendor/magento/module-jwt-user-token/Model/SecretBasedJwksFactory.php (revision 8d2b0c1c6b421cdcd7f62a48a5edc9b0211d92a2)
39+
@@ -35,6 +35,7 @@
40+
public function __construct(DeploymentConfig $deploymentConfig, JwkFactory $jwkFactory)
41+
{
42+
$this->keys = preg_split('/\s+/s', trim((string)$deploymentConfig->get('crypt/key')));
43+
+ $this->keys = [end($this->keys)];
44+
//Making sure keys are large enough.
45+
foreach ($this->keys as &$key) {
46+
$key = str_pad($key, 2048, '&', STR_PAD_BOTH);
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
diff --git a/vendor/magento/module-encryption-key/Console/Command/UpdateEncryptionKeyCommand.php b/vendor/magento/module-encryption-key/Console/Command/UpdateEncryptionKeyCommand.php
2+
new file mode 100644
3+
index 0000000000000..8777f99139edc
4+
--- /dev/null
5+
+++ b/vendor/magento/module-encryption-key/Console/Command/UpdateEncryptionKeyCommand.php
6+
@@ -0,0 +1,141 @@
7+
+<?php
8+
+/**
9+
+ * Copyright © Magento, Inc. All rights reserved.
10+
+ * See COPYING.txt for license details.
11+
+ */
12+
+
13+
+declare(strict_types=1);
14+
+
15+
+namespace Magento\EncryptionKey\Console\Command;
16+
+
17+
+use Magento\Framework\App\DeploymentConfig\Writer;
18+
+use Magento\Framework\Config\ConfigOptionsListConstants;
19+
+use Magento\Framework\Config\Data\ConfigData;
20+
+use Magento\Framework\Config\File\ConfigFilePool;
21+
+use Magento\Framework\Console\Cli;
22+
+use Magento\Framework\Exception\FileSystemException;
23+
+use Magento\Framework\Math\Random;
24+
+use Symfony\Component\Console\Command\Command;
25+
+use Symfony\Component\Console\Input\InputInterface;
26+
+use Symfony\Component\Console\Input\InputOption;
27+
+use Symfony\Component\Console\Output\OutputInterface;
28+
+use Magento\Framework\App\CacheInterface;
29+
+use Magento\Framework\Encryption\EncryptorInterface;
30+
+
31+
+/**
32+
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
33+
+ */
34+
+class UpdateEncryptionKeyCommand extends Command
35+
+{
36+
+ /**
37+
+ * @var EncryptorInterface
38+
+ */
39+
+ private EncryptorInterface $encryptor;
40+
+
41+
+ /**
42+
+ * @var CacheInterface
43+
+ */
44+
+ private CacheInterface $cache;
45+
+
46+
+ /**
47+
+ * Configuration writer
48+
+ *
49+
+ * @var Writer
50+
+ */
51+
+ private Writer $writer;
52+
+
53+
+ /**
54+
+ * Random string generator
55+
+ *
56+
+ * @var Random
57+
+ */
58+
+ private Random $random;
59+
+
60+
+ /**
61+
+ * @param EncryptorInterface $encryptor
62+
+ * @param CacheInterface $cache
63+
+ * @param Writer $writer
64+
+ * @param Random $random
65+
+ */
66+
+ public function __construct(EncryptorInterface $encryptor, CacheInterface $cache, Writer $writer, Random $random)
67+
+ {
68+
+ $this->encryptor = $encryptor;
69+
+ $this->cache = $cache;
70+
+ $this->writer = $writer;
71+
+ $this->random = $random;
72+
+
73+
+ parent::__construct();
74+
+ }
75+
+
76+
+ /**
77+
+ * @inheritDoc
78+
+ */
79+
+ protected function configure()
80+
+ {
81+
+ $this->setName('encryption:key:change');
82+
+ $this->setDescription('Change the encryption key inside the env.php file.');
83+
+ $this->addOption(
84+
+ 'key',
85+
+ 'k',
86+
+ InputOption::VALUE_OPTIONAL,
87+
+ 'Key has to be a 32 characters long string. If not provided, a random key will be generated.'
88+
+ );
89+
+
90+
+ parent::configure();
91+
+ }
92+
+
93+
+ /**
94+
+ * @inheritDoc
95+
+ */
96+
+ protected function execute(InputInterface $input, OutputInterface $output)
97+
+ {
98+
+ try {
99+
+ $key = $input->getOption('key');
100+
+
101+
+ if (!empty($key)) {
102+
+ $this->encryptor->validateKey($key);
103+
+ }
104+
+
105+
+ $this->updateEncryptionKey($key);
106+
+ $this->cache->clean();
107+
+
108+
+ $output->writeln('<info>Encryption key has been updated successfully.</info>');
109+
+
110+
+ return Cli::RETURN_SUCCESS;
111+
+ } catch (\Exception $e) {
112+
+ $output->writeln('<error>' . $e->getMessage() . '</error>');
113+
+ return Cli::RETURN_FAILURE;
114+
+ }
115+
+ }
116+
+
117+
+ /**
118+
+ * Update encryption key
119+
+ *
120+
+ * @param string|null $key
121+
+ * @return void
122+
+ * @throws FileSystemException
123+
+ */
124+
+ private function updateEncryptionKey(string $key = null): void
125+
+ {
126+
+ // prepare new key, encryptor and new configuration segment
127+
+ if (!$this->writer->checkIfWritable()) {
128+
+ throw new FileSystemException(__('Deployment configuration file is not writable.'));
129+
+ }
130+
+
131+
+ if (null === $key) {
132+
+ // md5() here is not for cryptographic use. It used for generate encryption key itself
133+
+ // and do not encrypt any passwords
134+
+ // phpcs:ignore Magento2.Security.InsecureFunction
135+
+ $key = md5($this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE));
136+
+ }
137+
+
138+
+ $this->encryptor->setNewKey($key);
139+
+
140+
+ $encryptSegment = new ConfigData(ConfigFilePool::APP_ENV);
141+
+ $encryptSegment->set(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, $this->encryptor->exportKeys());
142+
+
143+
+ $configData = [$encryptSegment->getFileKey() => $encryptSegment->getData()];
144+
+
145+
+ $this->writer->saveConfig($configData);
146+
+ }
147+
+}
148+
diff --git a/vendor/magento/module-encryption-key/etc/di.xml b/vendor/magento/module-encryption-key/etc/di.xml
149+
index b4e471f4e40ef..495234759a7f8 100644
150+
--- a/vendor/magento/module-encryption-key/etc/di.xml
151+
+++ b/vendor/magento/module-encryption-key/etc/di.xml
152+
@@ -11,4 +11,11 @@
153+
<argument name="structure" xsi:type="object">Magento\Config\Model\Config\Structure\Proxy</argument>
154+
</arguments>
155+
</type>
156+
+ <type name="Magento\Framework\Console\CommandList">
157+
+ <arguments>
158+
+ <argument name="commands" xsi:type="array">
159+
+ <item name="encryption_update_key_command" xsi:type="object">Magento\EncryptionKey\Console\Command\UpdateEncryptionKeyCommand</item>
160+
+ </argument>
161+
+ </arguments>
162+
+ </type>
163+
</config>

0 commit comments

Comments
 (0)