PHP2Shell: update your Matomo server now

Two critical PHP flaws allow attacks without a login. What Matomo operators should do now and how much AppArmor and SELinux can contain.

On 21 October 2026 the PHP project closed two critical security flaws: CVE-2026-109618 and CVE-2026-109619, also called “PHP2Shell” in reports. Both are rated 9.2 out of 10 (CVSS 4.0) and allow attackers to run their own code on the server without logging in. If you run Matomo yourself, update PHP now rather than waiting for the next maintenance window.

What is known

  • Affected are, according to PHP, all installations that serve web requests: PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP and LiteSpeed. The risk is highest with mod_php.
  • Fixed in PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35. Linux distributions received the fixes in advance and ship their own packages.
  • PHP 8.1 and older no longer get updates from the PHP project. According to CERT-EU, all versions back to at least PHP 5 are vulnerable.
  • The German BSI rates the situation as orange: measures must be taken without delay. It considers broad exploitation within a few hours of the patches being released likely.
  • Public exploits already exist, according to RUS-CERT at the University of Stuttgart. RUS-CERT reproduced one of them on a test system.
  • The cause is memory errors in PHP itself. With CVE-2026-109618, a failed memory allocation leaves a half-built entry behind, which PHP processes while cleaning up the request. With CVE-2026-109619, a PHP process reuses data from an earlier request whose memory has already been freed. The attack takes effect while the request starts, before Matomo even sees it. A login or a setting in Matomo therefore does not protect you.
  • First attack attempts were seen from 17 October, four days before the patches, according to Datadog, citing AWS.
PHP branch Safe from version Security updates until
8.5 8.5.12 end of 2029
8.4 8.4.27 end of 2028
8.3 8.3.36 end of 2027
8.2 8.2.35 end of 2026
8.1 and older no update from the PHP project expired

Why Matomo servers are particularly exposed

Matomo is a PHP application, and its tracking endpoint has to be reachable for every visitor of the measured websites. There is no login there, and the endpoint cannot be put behind a VPN without switching off tracking. Requests without a login are exactly what these flaws exploit.

The tracking endpoint answers requests without a login. Whoever takes over the server through the flaw reaches raw data, credentials and API tokens and can change matomo.js, which runs on every measured website.

Add to that what sits on a Matomo server: raw visit data, database credentials, API tokens and the tracking files. The file matomo.js and the Tag Manager containers are loaded on every measured website. Whoever takes over the server can change them and so run their own code on all of these websites.

What to do now

  1. Check the version that serves web requests. php -v only shows the command-line version; PHP-FPM or Apache may use a different one. In Matomo you find the version under Administration, System, System Check.
  2. Update. Via your distribution’s package manager, your hosting panel or a new build of your containers. Distributions use their own version numbers, so their security notice is what counts.
  3. Restart the services. Running PHP-FPM processes and Apache keep using the old version until they are restarted. Then check the version again, including for the archiving cron job.
  4. Replace old PHP versions. If you still run PHP 8.1 or older, the PHP project provides no fix. Before switching, check whether your Matomo version and your plugins run on the new PHP version.
  5. Look for traces. Matomo’s System Check reports files that do not belong to the installation under file integrity. Also check the users with super user access, new API tokens, cron jobs and new PHP files in the web directory.

The emergency measures in the PHP notice, such as removing the memory limit, do not make an installation safe according to PHP. With Matomo, removing the memory limit can also let large reports exhaust the whole server. If you cannot update straight away, take the server offline until the update. It costs tracking data, but it is better than a compromised server.

If you suspect an attack: isolate the server, preserve the web server and PHP logs, and only then clean up.

Would AppArmor or SELinux have helped?

Partly. AppArmor (Debian, Ubuntu) and SELinux (Red Hat, Rocky, Alma) define which files, programs and network connections a process may use. They do not prevent the flaws themselves: the bug sits in the PHP process, and the attack runs entirely inside it. What they can limit is what happens next.

The publicly described attack ends with PHP calling system() while cleaning up the failed request, which starts a command in a shell. A profile that does not let PHP-FPM start other programs breaks exactly this step. Everything PHP-FPM is allowed to do anyway, however, remains possible.

A strict profile prevents

  • Starting a shell or other programs such as sh, curl or wget, and with them a reverse shell
  • Writing outside the permitted paths new PHP files in the web directory, cron jobs, SSH keys
  • Connections to foreign servers as far as the rules cover outgoing connections
  • Access to other data on the server home directories, other websites, system files

Still possible

  • Reading memory The flaws can disclose parts of memory, which may contain passwords and API keys.
  • Credentials and database PHP has to read the configuration with the database password and query the database, including raw data and user accounts.
  • Changing matomo.js and Tag Manager containers Matomo writes these files itself when plugins extend the tracker or a container is published.
  • Using PHP functions directly Anyone running code in the PHP process does not need a shell for much.

With Matomo, the most valuable targets are exactly where PHP has to read and write. The tracker file matomo.js and the containers in the js/ directory run on every tracked website. If you harden consistently, give PHP-FPM read-only access to them and have another user generate the files through the Matomo console: custom-matomo-js:update for the tracker and tagmanager:regenerate-released-containers for the containers. This costs some convenience, as new tracker features from plugins and published containers only appear after this step.

All of this only works with an active, suitable profile:

  • Red Hat, Rocky and Alma: PHP-FPM runs in the web server’s SELinux domain out of the box. Connections to foreign servers and writes to web content are forbidden there unless explicitly allowed. If you switch SELinux off when problems occur or grant permissions generously, you lose this protection.
  • Debian: AppArmor is active, but PHP-FPM is not confined out of the box. The add-on package apparmor-profiles contains a profile for PHP-FPM that only covers the master process. The processes that answer requests need their own sub-profile per pool, attached via the pool setting apparmor_hat.

A side effect helps with detection: if AppArmor or SELinux denies a PHP process the start of a shell, it shows up in the audit log. On a web server, that is a clear warning sign.

So AppArmor and SELinux do not replace the update. They do make sure that a hijacked PHP request does not automatically become a hijacked server. They make sense as a second line of defence, set up and tested before the next flaw arrives. How I go about it is described under Security & hardening.

Operation by feinwerk.io

Matomo instances run by our sister brand feinwerk.io get security updates and patches as soon as they are available. You do not have to do anything. The same applies to servers that feinwerk.io looks after for you under SLA operations.

Do you run Matomo yourself and want to know whether your server is up to date and properly hardened? With Security & hardening I check PHP, the web server and the operating system too, and in a Matomo audit updates and operations as well.

Read on at feinwerk.io: PHP2Shell: critical PHP vulnerabilities and what Matomo operators should do now

Sources

As of 22 October 2026

Questions about your setup?

In an intro call we'll look at your situation together.

Book an intro call

Newsletter

Matomo know-how, once a month.

Practical tips on tracking, privacy settings and performance, plus notes on important Matomo updates. No spam, unsubscribe any time.