Skip to content
CVE-2024-34102CriticalCVSS 9.8Patch

CVE-2024-34102 (CosmicSting) Magento security patch

Free Composer patch for CVE-2024-34102 (CosmicSting), the Magento XXE flaw, on releases Adobe never fixed. Tested on eight releases, 2.3.0 to 2.4.9.

  • Updated
  • Maintained by The Big Cart Energy team

Install with Composer

Run it from your Magento root as the file-system owner. Test it on staging first, with a backup you've restored at least once.

Before you install. This patch is free software under OSL-3.0 (opens in a new tab), with no support. Apart from the license's own warranty of provenance, it is provided "AS IS" and WITHOUT WARRANTY, express or implied, and the entire risk as to its quality is with you. It's tested only on the versions listed on this page. Try it on a staging store first and keep a backup you have restored. By installing it you accept our terms and the package's license. Not affiliated with Adobe.

The copy button and the repository link wait for this box.

Locked until you tick “I've read this and I'll test on staging first”.
bash
composer require bigcartenergy/module-cosmicsting-patch

The source and every release live on GitHub: github.com/bigcartenergy/module-cosmicsting-patch

Then enable the module, register it and compile:

bash
bin/magento module:enable BigCartEnergy_CosmicStingPatch
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean

setup:di:compile is needed in production mode and does no harm in developer mode. In production mode, setup:upgrade also empties the deployed static files unless you run it with --keep-generated. So either run bin/magento setup:static-content:deploy after the compile, as after any module install, or pass --keep-generated (the module ships no static content) and let setup:di:compile rebuild the generated code.

  • It's a module, not a .patch file: nothing in the Magento source changes, and no patching tool is involved.
  • It adds no table, setting, menu item, cron job or storefront output, and it depends on no other Big Cart Energy package.
  • The package is on Packagist, so Composer needs no extra repository.
  • No Composer? Download the release archive from the repository: its link sits under the install command above and unlocks once you tick the box. The archive unpacks into one folder named after the repository and the release. Copy that folder's contents, registration.php included, to app/code/BigCartEnergy/CosmicStingPatch, then run the same bin/magento commands.
  • Not sure you need it? Check your release before it goes anywhere near production.

Check that it's working

bash
bin/magento module:status BigCartEnergy_CosmicStingPatch

It prints "Module is enabled". From then on, each refusal writes one line to var/log/bigcartenergy_cve-2024-34102.log, after Magento's own timestamp: the UTC time, the client IP address, the request method and path, and the refused type. The request body is never logged.

If the file doesn't exist, nothing has been refused yet. That's the expected state for a store that never receives such a request, not a sign that the guard is off.

Already exposed? Patching doesn't rotate your keys

A fix acts on requests from the moment it's in place. It changes nothing that happened before. If your store has run an exposed release since the flaw went public on June 11, 2024, Adobe's guidance for this CVE is that merchants "must apply the VULN-27015 patch (dependent on your version) and rotate your encryption keys" (Adobe). We'd say the same to a store patched with this module:

  • Rotate the store's encryption keys. Adobe's guidance on securing your store and rotating encryption keys covers the key.
  • Review the admin users, integrations and API tokens.
  • On 2.4.4 to 2.4.7, apply Adobe's isolated patch or the patch release of your line too, for the July 2024 hotfix this module doesn't contain.

The module does none of that for you. If you think the store has already been hit: Store hacked or down? Get help now.

Logging and IP addresses

Logging is on by default. IP addresses are personal data in the EU, so if your store has no basis to keep them, turn the log off from a small module of your own: the three files below. Magento merges every module's etc/di.xml in module load order, and the last value wins. This patch sets enableLog to true in its own etc/di.xml, so yours must load after it, which is what the <sequence> in your module.xml is for. Without that <sequence>, a module whose name sorts before BigCartEnergy loads first, loses the merge, and the log stays on with nothing to tell you. Don't put the override in Magento's app/etc/di.xml either: that file belongs to the magento/magento2-base package and is written over when that package updates.

app/code/Acme/PatchLogOff/registration.php (use your own vendor name in place of Acme):

php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Acme_PatchLogOff',
    __DIR__
);

app/code/Acme/PatchLogOff/etc/module.xml:

xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Acme_PatchLogOff">
        <sequence>
            <module name="BigCartEnergy_CosmicStingPatch"/>
        </sequence>
    </module>
</config>

app/code/Acme/PatchLogOff/etc/di.xml:

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="BigCartEnergy\CosmicStingPatch\Plugin\Webapi\ServiceInputProcessorPlugin">
        <arguments>
            <argument name="enableLog" xsi:type="boolean">false</argument>
        </arguments>
    </type>
</config>

Then run bin/magento module:enable Acme_PatchLogOff, bin/magento setup:upgrade, bin/magento setup:di:compile and bin/magento cache:clean; the static-content note at the top of this tab applies here too. Running both of our patches? One module can switch both logs off: list both patch modules in the <sequence> and both plugin types in the di.xml.

Confirm it took. bin/magento module:status lists the enabled modules in load order, and Acme_PatchLogOff must come after BigCartEnergy_CosmicStingPatch; if it comes before, the <sequence> is missing or misspelled and the log is still on. Nothing exposes the switch directly, so the check that settles it is the file: run your store's own API traffic on a staging copy and confirm var/log/bigcartenergy_cve-2024-34102.log gains no line.

The guard works the same with the log off.

How to remove the patch

Same rules as the install: a staging copy first, with a backup.

bash
bin/magento module:disable BigCartEnergy_CosmicStingPatch
composer remove bigcartenergy/module-cosmicsting-patch
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean

In production mode, the static-content note at the top of this tab applies to this setup:upgrade too. Nothing is left behind except the log file, which you can delete.

Am I affected?

Read your release from the Magento root:

bash
bin/magento --version

It prints a line such as Magento CLI 2.4.3-p3. A patch file applied on top of a release doesn't change that line, so if someone may have applied Adobe's isolated patch by hand, ask whoever deploys the store. Our guide to checking your version and patch level covers the other places to look. Then find your row. We read Adobe's fix in the Magento Open Source code of every release below, so the table says what the code says.

Your Magento Open Source releaseAdobe's fixThis module
2.3.0 to 2.3.7-p4NoneYes
2.4.0 to 2.4.3-p3NoneYes
2.4.4 to 2.4.4-p8, 2.4.5 to 2.4.5-p7, 2.4.6 to 2.4.6-p5, 2.4.7Adobe's isolated patch VULN-27015, or the patch release of your line in the next rowYes, if you've applied neither, as the stopgap until you do: both of Adobe's fixes also carry the July 2024 hotfix in the note below, which this module doesn't
2.4.4-p9 and later, 2.4.5-p8 and later, 2.4.6-p6 and later, 2.4.7-p1 and later, 2.4.8, 2.4.9IncludedNot needed. Installed anyway, it's redundant: core refuses the same types a moment later

"Yes" means the release needs a fix, not that we tested the module on it: the tested releases are under How we tested it. Installed next to Adobe's fix, the module stays out of the way. On our 2.4.8 and 2.4.9 test installs, whose core already has the fix, every flow we tested returned the same response with and without the module; where the module refused a request first, it only added its log line.

The note on 2.4.4 to 2.4.7. Adobe followed the June 2024 fix with a hotfix on July 17, 2024 (AC-12485), which its 2.4.4 patch notes describe as resolving "a JSON web token (JWT) validation issue related to CVE-2024-34102". Adobe's isolated patch contains that hotfix, and so do the patch releases that followed it: 2.4.4-p10 is the first of its line to list it. Stores already on the June releases (2.4.4-p9, 2.4.5-p8, 2.4.6-p6 and 2.4.7-p1) don't need this module, but Adobe's notes ask them to apply the hotfix. This module doesn't contain it: it closes the input-processor hole only. On 2.4.4 to 2.4.7, Adobe's isolated patch or the patch release of your line is the complete fix, and this module is the stopgap until you apply one. Magento's JSON web tokens for the Web API arrived in 2.4.4 (the magento/module-jwt-user-token package is first required by 2.4.4), so on 2.3.0 to 2.4.3 the hotfix has no counterpart, and this module is the whole of what we can offer for the vulnerability there.

Mage-OS ships the same Web API code as the Magento Open Source release it's based on, so that release's row applies to it. We haven't tested this version of the module on Mage-OS.

What CosmicSting is, and how the patch works

CosmicSting (CVE-2024-34102) is an XML external entity (XXE) flaw in the Magento Web API. Adobe scores it 9.8 out of 10 (CVSS 3.1): an attacker needs no login and no user interaction, and Adobe says it could lead to arbitrary code execution. Adobe fixed it for supported releases in bulletin APSB24-40 on June 11, 2024.

The flaw lives in Magento\Framework\Webapi\ServiceInputProcessor, the class that turns a REST or SOAP request body into the objects a service method expects: it accepted PHP's XML classes as types to build from request data. Adobe's fix makes it refuse subclasses of SimpleXMLElement and DOMElement with the error "Invalid data type".

The module is one before plugin on convertValue(), the processor's one public entry point, which the processor also passes through for every nested value. It refuses a conversion to either XML class, the class itself as well as any subclass, directly or as an array item type, with Adobe's own message, so monitoring that matches the official fix keeps working. One value the processor builds without that entry point is an object-typed custom attribute. For those, the module resolves the attribute's type the way the processor does (the entity type of the owning object, then Magento's custom attribute type locator) and refuses it the same way when it's an XML class. Simple types and mixed are never checked, every other request is untouched, and no core file is edited.

On 2.3.0, install the SessionReaper patch alongside it. That release converts a service method's own parameters and setter values, where this guard refuses the XML classes, but copies nested constructor data without converting it. That data never reaches an XML class on 2.3.0, with or without this module, and the SessionReaper patch removes the keys on that path that fail Adobe's allow-list. Together the two cover both paths.

How we tested it

On every release below we ran the same checks, with the module alone and alongside the SessionReaper patch:

  • install and setup:di:compile
  • guest checkout over REST to a placed order, customer sign-up, product search with filters and sort orders, and admin product saves with custom and extension attributes, Magento's own object-typed custom attribute included
  • one SOAP call with search criteria
  • the guard refusing an XML-typed parameter on a test fixture, single and as a list, with its log line
  • object-typed custom attributes on a test fixture: one of a non-XML type passing untouched, and an XML-typed one refused with "Invalid data type" on every release
  • removal, then REST again

Every legitimate flow returned the same results with the module as without it on every release. On the releases that already carry Adobe's fix, the refusal was identical too: the module answered first, with the same message, and added its log line. The unit suite passes on PHPUnit 6.5, 9, 10 and 12.

ReleasePHPDatabaseOn this release
Magento Open Source 2.4.98.5MySQL 8.4Adobe's fix is in core; the module is redundant
Magento Open Source 2.4.88.3MySQL 8.4Adobe's fix is in core; the module is redundant
Magento Open Source 2.4.78.2MySQL 8.0The module is the only guard
Magento Open Source 2.4.68.1MySQL 8.0The module is the only guard
Magento Open Source 2.4.3-p37.4MySQL 8.0The module is the only guard
Magento Open Source 2.3.7-p47.4MySQL 5.7The module is the only guard
Magento Open Source 2.3.5-p27.3MySQL 5.7The module is the only guard
Magento Open Source 2.3.07.2MySQL 5.7The module is the only guard; see the 2.3.0 note above

We installed 2.3.0 and 2.3.5-p2 from Adobe's public release tags rather than as Composer projects, because the public package mirror serves no 2.3 release before 2.3.7-p2; the code under test is each release's own. A release that isn't in this table hasn't been tested, and we haven't tested this version of the module on Mage-OS. The Tested versions tab carries the same list.

Patch or upgrade?

A patch is not an upgrade. This module closes one hole in a release that Adobe no longer patches; it doesn't fix the others, and it never will. The lasting fix is a supported release of Magento Open Source, and our Magento end-of-life guide has Adobe's support dates. Install the module, then plan the upgrade. Stuck on an old version? We'll patch you now and upgrade you when you're ready.

Want it done for you? It's part of our Magento development work. We install the patch on your staging copy first, run your checkout and integrations through it and read the guard's log before it goes to production. On 2.4.4 to 2.4.7, we apply Adobe's isolated patch or your line's patch release as well. If the store ran exposed, we rotate the keys and review the admin users, integrations and tokens with you, then scope the upgrade. Like every engagement, it's scoped in writing, and we don't publish prices; how an engagement runs covers the rest. Talk shop and tell us your release, how you deploy and what talks to your API.

Stuck on an old version?

We'll patch you now and upgrade you when you're ready.