The two emergency settings
Two settings from the advisories close the publicly demonstrated paths on PHP 7.4: an unlimited memory_limit and disabled session upload progress.
memory_limit = -1 removes the predictable per-request limit that the CVE-2026-109618 exploit drives PHP into.session.upload_progress.enabled = Off removes the session-upload path of CVE-2026-109619. It is on by default, even when the line in php.ini is commented out. Neither Nextcloud nor Roundcube needs it.
The other demonstrated path for CVE-2026-109619 depends on fatal-error backtraces, a PHP 8.5 feature, so it does not apply to 7.4.
Apply them to every php.ini that serves a site
for ini in /etc/php/7.4/apache2/php.ini /etc/php/7.4/cgi/php.ini /etc/php/7.4/fpm/php.ini; do
cp "$ini" "$ini.bak-$(date +%F)"
printf '\n; PHP CVE-2026-109618/109619 stopgap\nmemory_limit = -1\nsession.upload_progress.enabled = Off\n' >> "$ini"
done
Appending works because the last occurrence of a setting wins. Comments in php.ini must start with ;. A line starting with # can break parsing, and everything after it is then silently ignored. Check each file parses and gives the right values:
php -c /etc/php/7.4/cgi/php.ini -r 'echo ini_get("memory_limit")," / ",var_export(ini_get("session.upload_progress.enabled"),true),"\n";'
The expected output is -1 / ''. Then restart whatever runs PHP: systemctl restart apache2 for mod_php and mod_fcgid, and systemctl restart php7.4-fpm for FPM.
Stop applications from overriding them
Nextcloud’s .htaccess sets php_value memory_limit 512M for mod_php, and its .user.ini does the same for FastCGI and FPM. Either one silently undoes the fix.
For mod_php, admin values cannot be overridden from .htaccess. One global Apache config covers every site under /var/www:
cat > /etc/apache2/conf-available/php-cve-2026-mitigation.conf <<'EOF'
<IfModule php7_module>
<Directory /var/www>
php_admin_value memory_limit -1
php_admin_flag session.upload_progress.enabled off
</Directory>
</IfModule>
EOF
a2enconf php-cve-2026-mitigation
apachectl configtest && systemctl restart apache2
For FPM, set the same pair as php_admin_value[...] and php_admin_flag[...] in the pool file. For FastCGI, edit or comment out memory_limit in the application’s .user.ini. Remember that an application upgrade may restore that file.
Finally, re-run the check script for every application. You want memory_limit: -1 and upload_progress: ''.
If you wanna make it simple, add this to the very end of php ini config file from /etc/php/:
;Php2shell CVE 21 Oct 2026
memory_limit = -1
session.upload_progress.enabled = Off