Magento 2 PHP Configuration: Uncovering Hidden Flaws and Boosting Security

As e-commerce migration experts at Shopping Mover, we constantly monitor the Magento ecosystem for critical updates, performance insights, and security vulnerabilities that could impact your store, especially during a migration or upgrade. A recent GitHub issue (No. 41684) has brought to light several significant concerns regarding Magento 2’s default PHP configuration settings, revealing potential security gaps and performance inefficiencies that every Magento user should be aware of.

Magento 2 PHP Configuration: Uncovering Hidden Flaws and Boosting Security

The issue, reported by lbajsarowicz, details how Magento 2.4-develop (and likely earlier versions) ships with PHP settings that are either outdated, ineffective, or introduce security risks. These problems span across critical configuration files such as .user.ini, pub/.user.ini, pub/.htaccess, .htaccess.sample, and nginx.conf.sample. While the original post mentions a proposed fix in a linked pull request, the issue itself serves as a comprehensive audit of default configurations that demand immediate attention. As no comments were provided in the source, our analysis of discussion points and outcomes is based solely on the issue description.

Key Findings and Their Implications:

  • Dead Directives and False Security: Magento’s configuration files still include references to Suhosin, specifically suhosin.session.cryptua. Suhosin has not been released for PHP 8.x, meaning these directives are completely ineffective on modern Magento installations. This creates unnecessary clutter and can give a false sense of security, leading administrators to believe they are protected when they are not.
  • Ineffective Nginx PHP-FPM Settings: For installations using Nginx with PHP-FPM, the nginx.conf.sample attempts to set session.auto_start=off using fastcgi_param PHP_FLAG. However, PHP-FPM only processes settings passed via PHP_VALUE or PHP_ADMIN_VALUE. This means the session.auto_start directive is likely ignored, potentially leading to unexpected session behavior or security issues if not explicitly configured elsewhere.
  • Inadequate .user.ini Protection: A critical security oversight was identified in how Magento handles .user.ini files. The default location /.user.ini { deny all; } rule in nginx.conf.sample (and similar in Apache’s .htaccess) is a prefix location, meaning it only blocks /.user.ini at the document root. Files like /static/.user.ini or /media/x/.user.ini remain accessible, returning a 200 OK status. This vulnerability could allow an attacker to upload a malicious .user.ini file to a publicly accessible directory, potentially overriding PHP settings and executing arbitrary code.
  • Unused Feature, Major Security Risk: The PHP default for session.upload_progress.enabled is 1 (enabled). Magento does not utilize this feature. However, as recent PHP advisories (CVE-2026-109619 and CVE-2026-115560) highlight, this feature allows unauthenticated multipart requests to write session data before Magento's application logic even runs. Disabling this is a crucial security hardening step.
  • PHP 8.5 Deprecation Warnings: On PHP 8.5 with register_argc_argv=1 (which is PHP’s default), every web request triggers a Deprecated: Deriving $_SERVER['argv'] from the query string is deprecated warning. While not a functional bug, these warnings clutter logs, consume resources, and indicate an outdated approach that should be addressed for cleaner, more efficient operation.
  • Missing Comprehensive php.ini Reference: Magento removed its php.ini.sample in 2018. This issue points out the lack of a reference for critical server-level PHP settings that cannot be configured per directory (e.g., opcache.*, realpath_cache_*, expose_php, cgi.fix_pathinfo, disable_functions). This leaves developers and administrators without clear guidance on optimal PHP settings for Magento, potentially leading to suboptimal performance or security configurations.

What This Means for Your Magento Store:

These findings underscore the importance of a thorough review of your Magento 2 environment's PHP configuration. For merchants, these issues translate to potential security vulnerabilities that could be exploited, leading to data breaches or website defacement. For developers and system administrators, they represent performance bottlenecks, cluttered logs, and a need for manual hardening beyond Magento's default recommendations. During a Magento migration, especially to newer PHP versions, proactively addressing these configurations is paramount to ensure a secure, stable, and high-performing store.

While the issue mentions a proposed fix, it serves as a critical reminder that default configurations should always be audited and tailored to your specific environment and security posture. Proactive hardening of your PHP settings is not just a best practice; it's a necessity for a robust Magento 2 store.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools