
An alternative solution(as a Magento 2 extension) to fix the XXE vulnerability CVE-2024-34102(aka Cosmic Sting). If you cannot upgrade Magento or cannot apply the official patch, try this one.
An alternative solution(as a Magento 2 extension) to fix the XXE vulnerability CVE-2024-34102(aka Cosmic Sting). If you cannot upgrade Magento or cannot apply the official patch, try this one.
If you don't fix this vulnerability, the attacker can RCE. We've already observed real world attacks.
2.3.0 ~ 2.4.4-p8
2.4.5 ~ 2.4.5-p7
2.4.6 ~ 2.4.6-p5
2.4.7
CVE-2024-34102(aka Cosmic Sting) was identified as XXE vulnerability and the details were published on June 2024. By exploiting this vulnerability, the attacker can read secret and important configuration files on the server.
Typically, the attacker will extract encryption keys in env.php.
In most hacked servers, we observed one or multiple of the followings:
If you want to know "How Exactly It Works", we have very detailed blog posts that examine and fix the vulnerability.
The attacker can craft fake Admin Token by using the stolen encryption key. With the fake Admin Token, the attacker is able to perform Admin level actions such as creating fake orders, modifying CMS Block to inject malicious Javascript and more.
XXEs are now RCEs.
As CVE-2024-34102 enables the ability to read arbitrary file on the server, the attacker can now combine it with a bug(CVE-2024-2961) discovered in glibc to run any command on the server. One real case we experienced was that multiple backdoors got downloaded and installed.
The glibc bug exists in glibc version <= 2.3.9
glibc version by runningldd --version | grep -i 'libc'
There are 3 Ways Available:
Note you still need to fix "Secondary Disasters" after completing the above step.
This step invalidates crafted fake tokens to completely deny WebAPI access from attacker.
If you are unsure whether encryption keys are leaked or not, do this step.
Some Magento 2.4 versions have a bug that you need to apply a patch before performing key rotation.
Alternative Encryption Key Rotation Tool
New Magento encryption key format
glibc Bug(Strongly Recommended)Update glibc to >= 2.40 to fix CVE-2024-2961.
Don't forget to reboot server.
This extension
By default, logging is disabled for performance consideration. To enable, open a local module and merge the following to etc/di.xml.
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Wubinworks\CosmicStingPatch\Plugin\Framework\Webapi\ServiceInputProcessor">
<arguments>
<argument name="loggerConfig" xsi:type="array">
<item name="ip" xsi:type="array">
<item name="enabled" xsi:type="boolean">true</item>
</item>
</argument>
</arguments>
</type>
</config>
<magento_root>/var/log/wubinworks_cve-2024-34102.log
If you got incorrect IP such as 127.0.0.1, empty string or a CDN's IP, this means your web server, middleware, and/or proxy server have incorrect settings. There is no way to tell the real IP address without fixing those incorrect settings.
Magento 2.3 or 2.4
Version 1.0.0 and 1.1.0 support PHP 8 only
Version 1.2.0(re-designed) supports PHP 7 and PHP 8
Latest:
composer require wubinworks/module-cosmic-sting-patch
Installation Tips:
composercomposer or directly to app/codeIf you like this extension or this extension helped you, please ★star☆ this repository.
You may also like:
Magento 2 Patch for CVE-2022-24086, CVE-2022-24087
Magento 2 Enhanced XML Security
Magento 2 Encryption Key Manager CLI
Magento 2 JWT Authentication Patch
Magento 2 Disable Customer Change Email Extension
Magento 2 Disable Customer Extension