Under attack right now? hello@incursor.io
BlogPentest

Magento in 2026: PolyShell, StyleSmuggler and a year of patching under fire

Magento and Adobe Commerce stores went through three critical bugs in 2026, all reachable without an account, and two of them were mass exploited before a clean fix was available. This post covers what happened, how each attack works, and what we check first when a client calls about their store.

Gerard Capdevila Oct 2026 · 12 min read · Magento
KEY TAKEAWAYS
PolyShell (March): the cart REST API accepts a base64 file and writes it to disk without checking its type or content. A GIF with PHP inside becomes a webshell.
CVE-2026-71362 (August): an authorization check returns the wrong answer, so an attacker without credentials can read and change sensitive store data. CVSS 9.1, listed by CISA as exploited.
StyleSmuggler, CVE-2026-75650 (September), CVSS 10: a payload written to a log file runs later, when an internal email is rendered. Attacks started three days before the hotfix, on fully patched stores.
Patching closes the entry point but does not remove an attacker who is already in. After each of these bugs, hunt for traces, rotate secrets and sometimes rebuild.

1. Why Magento was a target this year

Magento has a large and old codebase, thousands of Internet-facing stores with the same structure, and card numbers at the end of the checkout. When a bug is published, scanning the whole Internet for it takes a few hours. Many integrators also update slowly, which produced what we saw in 2026: automated campaigns arriving before the patches.

2. PolyShell: an upload that never checks the file

The entry point is the product file option, used for example to print a customer’s image on a t-shirt. When that product is added to the cart through the REST API, the request carries a file_info object with the file content in base64. Magento decodes it and writes it to pub/media/custom_options/quote/ without any real check on type or content. Sansec disclosed it in mid-March and mass scanning followed immediately, with heavy activity from 19 March. The attack uses a polyglot file: a valid GIF89a header followed by PHP code, saved as index.php. A naive check sees an image, and a misconfigured web server executes it as a script. The webshell observed in the wild compared a cookie against a hard-coded MD5, then passed the rest to eval(). Attackers then installed a JavaScript skimmer on the checkout, stole the database or pivoted further.

POST /rest/V1/guest-carts/{id}/items
{
  "cartItem": {
    "product_option": { "extension_attributes": { "custom_options": [{
      "option_id": "12",
      "extension_attributes": { "file_info": {
        "base64_encoded_data": "R0lGODlhPD9waHAg...",
        "type": "image/gif",
        "name": "index.php"
      }}
    }]}}
  }
}

→ written to pub/media/custom_options/quote/i/n/index.php

3. The validation: ImageContentValidator::isValid()

The cart endpoint is declared with the anonymous resource, so no account is needed. The file_info object is checked by ImageContentValidator::isValid(), which base64-decodes the data, asks getimagesizefromstring() whether it is an image, compares the detected MIME type with the declared one against an allowlist (JPEG, PNG, GIF) and rejects a few characters in the name. Searchlight Cyber points out what is missing: the extension of the file name is never compared with the detected image type. A valid image header followed by PHP code, named index.php, passes every check.

// app/code/Magento/Quote/etc/webapi.xml
<route url="/V1/guest-carts/:cartId/items" method="POST">
    <service class="Magento\Quote\Api\GuestCartItemRepositoryInterface" method="save"/>
    <resources>
        <resource ref="anonymous" />          <!-- no authentication required -->
    </resources>
</route>

// lib/internal/Magento/Framework/Api/ImageContentValidator.php
public function isValid(ImageContentInterface $imageContent)
{
    $fileContent = @base64_decode($imageContent->getBase64EncodedData(), true);
    if (empty($fileContent)) { throw new InputException(...); }

    $imageProperties = @getimagesizefromstring($fileContent);   // the only content check: is it an image?
    if (empty($imageProperties)) { throw new InputException(...); }

    $sourceMimeType = $imageProperties['mime'];
    if ($sourceMimeType != $imageContent->getType() || !$this->isMimeTypeValid($sourceMimeType)) {
        throw new InputException(...);                            // declared type must match the detected one
    }
    if (!$this->isNameValid($imageContent->getName())) {
        throw new InputException(...);
    }
    return true;                                                  // the extension of the name is never compared with the image type
}

protected function isNameValid($name)
{
    // Cannot contain \ / ? * : " ; < > ( ) | { }
    if ($name === null || !preg_match('/^[^\\/?*:";<>()|{}\\\\]+$/', $name)) {
        return false;
    }
    return true;                                                  // index.php passes: no forbidden character
}

4. Where the file lands: getFileName() and processImageContent()

ImageProcessor::processImageContent() writes the decoded bytes to the system temp directory, then hands the file to the uploader, which saves it under the media directory for the entity type, custom_options/quote. getFileName() only appends an extension derived from the MIME type when the supplied name has none, so index.php keeps its .php extension. With files dispersion enabled, the first two characters of the name become two subfolders. The fix that later appeared in 2.4.9-alpha3 adds an ImageContentProcessor whose validateBeforeSaveToTmp() checks the extension against a blocklist of PHP-executable types; at the time of Searchlight Cyber’s write-up, it had not been backported to stable releases.

// lib/internal/Magento/Framework/Api/ImageProcessor.php
public function processImageContent($entityType, $imageContent)
{
    if (!$this->contentValidator->isValid($imageContent)) { ... }

    $fileContent = @base64_decode($imageContent->getBase64EncodedData(), true);
    $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
    $fileName = $this->getFileName($imageContent);
    $tmpFileName = substr(md5(rand()), 0, 7) . '.' . $fileName;
    $tmpDirectory->writeFile($tmpFileName, $fileContent);         // the decoded bytes are written as-is
    ...
    $this->uploader->setFilesDispersion(true);                    // files dispersion: two subfolders from the first two characters of the name
    $destinationFolder = $entityType;                             // custom_options/quote
    $this->uploader->save($this->mediaDirectory->getAbsolutePath($destinationFolder), $fileName);
    ...
}

private function getFileName($imageContent)
{
    $fileName = $imageContent->getName();
    if (!pathinfo($fileName, PATHINFO_EXTENSION)) {             // an extension is only added when the name has none
        ...
        $fileName .= '.' . $this->getMimeTypeExtension($imageContent->getType());
    }
    return $fileName;                                             // index.php keeps its .php extension
}

// Resulting path for name = "index.php"
//   pub/media/custom_options/quote/i/n/index.php

5. What decides whether the file runs

The file is on disk in every case. Whether it executes depends on the web server. Magento ships an .htaccess that denies access to pub/media/custom_options/, another one that sets php_flag engine 0 under pub/media/, and an nginx sample that denies the folder and only passes a short list of entry scripts to PHP-FPM. Searchlight Cyber lists the setups where this breaks: .htaccess files removed or ignored after an AccessFileName change, and nginx configurations that dropped the deny rules or the PHP restriction. A configuration that is safe today can become exploitable after a later change, while the uploaded file is still there.

# pub/media/custom_options/.htaccess  (Apache: blocks any access to the folder)
<IfVersion >= 2.4>
    Require all denied
</IfVersion>

# pub/media/.htaccess  (Apache + mod_php: disables PHP under pub/media)
<IfModule mod_php.c>
    php_flag engine 0
</IfModule>

# nginx.conf.sample (Magento 2.4.8)
location /media/custom_options/ {
    deny all;
}
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
    fastcgi_pass   fastcgi_backend;                # only these scripts reach PHP-FPM
    ...
}
location ~* (\.php$|\.phtml$|\.htaccess$|\.htpasswd$|\.git) {
    deny all;
}

# Audit: anything other than .htaccess deserves a look
find pub/media/custom_options/ -type f ! -name '.htaccess'
curl -s -o /dev/null -w '%{http_code}\n' https://shop.example/media/custom_options/quote/   # expected: 403 or 404

6. Why PolyShell lasted so long

The timing made PolyShell dangerous. The vulnerable code dated from the early days of Magento 2, and the only official fix was in a 2.4.9 prerelease, with no patch for production versions. For weeks, web server configuration was the only real defence. Even with PHP execution blocked in that folder, the uploaded files stayed on disk and could become executable after the next configuration change or migration.

Campaigns chained the polyglot upload, a persistent webshell, then a skimmer on the checkout.
Some skimmers used WebRTC to exfiltrate card data, which a strict CSP does not stop.
Field reports described more than half of vulnerable stores as already targeted.

7. CVE-2026-71362: an authorization check that answers yes

This bug is quieter and much less documented. Authentication is not bypassed: the authorization check runs, but it applies the wrong rule to a crafted request and grants access. An attacker without an account gets read and write access to sensitive store resources. CVSS 9.1, no user interaction. The fix shipped in the August security cycle (APSB26-92), and CISA added the CVE to its Known Exploited Vulnerabilities catalog on 24 September. The exact endpoint is not public. In a pentest, this kind of bug shows up when you replay privileged API calls with no session, or with a customer session, and look for 200 responses where 401 is expected.

8. StyleSmuggler: a payload that runs when an email is built

StyleSmuggler (CVE-2026-75650) is the most sophisticated of the three and the most worrying. It scores CVSS 10, needs no authentication and works in two steps. The first step poisons a file. The attacker sends styles[...] parameters to /graphql, or goes through /paypal/transparent/response/ and /customer/section/load/, and triggers an error on purpose. The PHP payload is written to var/report/ or var/log/, and nothing runs yet. The second step triggers it. When Magento internally builds the “Payment Transaction Failed Reminder” email, the template engine renders the poisoned content and executes the code. Nobody needs to open or even receive the email. A dropper then tries execution functions one by one until it finds one that is not disabled, and installs an implant.

04/09  first attacks seen, no disclosure
05/09  Sansec alert, no CVE, no patch
06/09  second actor, implant disguised as fc-cache
07/09  Adobe ships APSB26-146, hotfix VULN-39341
07/09  new variant disguised as chronyd

9. Fully patched stores were compromised

The first confirmed StyleSmuggler victim ran 2.4.6-p15 with every July and August fix applied, and the chain was reproduced on clean installs of 2.4.7, 2.4.8 and 2.4.9. Between 4 and 7 September, no 2.4.x store was protected, however well maintained. The persistence is designed to survive a quick cleanup. A cron entry runs every five minutes and reinstalls itself when removed (one server had rewritten it more than 1,700 times). A process poses as kworker, fc-cache or chronyd, and a webshell returns a normal 404 unless the request carries the right X-Cache-Token header. The implant lives in the system user’s home directory, outside the Magento root, so a scan limited to the project folder reports nothing.

10. What I would check tonight

On a production Magento store, I would start with the commands below, in this order. They do not cover everything, but they cover all three bugs.

# PolyShell: nothing executable in cart uploads
find pub/media/custom_options/ -type f \( -name "*.php" -o -name "*.phtml" \)
grep -rl "<?php" pub/media/custom_options/

# StyleSmuggler: persistence and injection traces
crontab -l | grep -i gvfsd
ls -la ~/.local/share/.gvfsd/ ~/.cache/fontconfig/fc-cache /tmp/.kw_* 2>/dev/null
ps -eo pid,user,comm,args | grep -iE "kworker|fc-cache|chronyd" | grep -v " root "
grep -rl "X_TRACE_" var/report/ var/log/

# Is the hotfix really installed?
vendor/bin/magento-patches -n status | grep 39341

# Nginx: close the folder, before the PHP block
location ^~ /pub/media/custom_options/ { deny all; }

11. Cleaning up after patching

All three bugs give access that remains after the fix is applied. When a client calls about their store, we apply these rules.

Treat any store exposed during an exploitation window as compromised until proven otherwise.
Hunt on every node, including the ones that look healthy, and outside the Magento folder.
If you find an implant, rebuild the server. With self-healing persistence, manual cleaning is unreliable.
Rotate the Magento encryption key first, then every secret it protects: admin accounts, API keys and payment credentials.
Put the admin and privileged APIs behind an IP allowlist or a WAF. CVE-2026-71362 would have done much less damage on an admin interface that does not answer the Internet.

12. What a store pentest needs to cover

A vulnerability scan reports that a version is vulnerable. It does not find an index.php left in custom_options since March, or an API call that returns customer data without a session. On a store we test the real flow (cart, product options, GraphQL, payment callbacks and transactional emails) and replay every privileged call without the required permissions. That is where these three bugs were.

DO THIS WEEK
→Install hotfix VULN-39341 and the August security cycle, then confirm the patch is active.
→Block pub/media/custom_options/ at the web server and remove anything that should not be there.
→Hunt for StyleSmuggler traces outside the Magento root: cron, ~/.local/share, /tmp and non-root processes.
→Rotate the Magento encryption key and every secret it protects.
→Put the admin and privileged APIs behind an IP allowlist.

Frequently asked questions

My store is up to date. Am I safe?

Not necessarily. StyleSmuggler was exploited three days before the hotfix, on fully patched stores. If the store was exposed between 4 and 7 September, look for traces.

I use Adobe Commerce Cloud. Does this affect me?

Yes. All three bugs affect Adobe Commerce as well as Magento Open Source, and managed hosting does not replace a compromise check or secret rotation.

Does a WAF protect me?

It buys time, for example by blocking styles[ parameters on GraphQL. It does not clean anything, and a variant can get through, so treat it as a stopgap until you patch.

Can you test our store?

Yes. We run a pentest focused on the real e-commerce flow, plus a compromise hunt if the store was exposed during one of these windows.

Is someone already inside your Magento store?

Test us. An expert hacker replies within one business day.
Incursor
© 2026 Incursor Security · Paris · Barcelona · Amsterdam · EU based
{{ rIncidentQ }} hello@incursor.io
Incursor {{ menuLabel }}
{{ navServices }} {{ navEngagements }} {{ navMethod }} {{ navTeam }} {{ navBlog }}
{{ navContact }}
{{ navBlog }}{{ arCat }}

{{ arT }}

{{ arLede }}

{{ arAuthor }} {{ arMeta }}
{{ arTldrT }}
{{ b }}

{{ sec.n }}. {{ sec.h }}

{{ sec.p }}

{{ sec.code }}
{{ li.t }} {{ li.t }}
{{ heatLowL }}
{{ heatMediumL }}
{{ heatHighL }}
{{ heatCriticalL }}
{{ arFlagsT }}
{{ arFlagMark }}{{ f }}

{{ arFaqT }}

{{ q.q }}

{{ q.a }}

{{ arSvcT }} {{ sv.t }}

{{ arCta }}

{{ rHmEndBtn }} {{ rHmEndNote }}
Incursor
© 2026 Incursor Security · {{ cities }}