PrestaShop

Fortify Your PrestaShop Admin: The Essential Referrer-Policy Module for Enhanced Security and Privacy

Browser developer tools showing a Referrer-Policy header in the network tab
Browser developer tools showing a Referrer-Policy header in the network tab

Fortify Your PrestaShop Admin: The Essential Referrer-Policy Module for Enhanced Security and Privacy

As e-commerce migration experts at Migrate My Shop, we constantly emphasize the critical importance of security and privacy in online retail. While PrestaShop provides a robust foundation for thousands of merchants worldwide, even the most sophisticated platforms can have subtle areas ripe for enhancement. A recent, insightful discussion within the PrestaShop community highlighted a common yet often overlooked vulnerability: the potential exposure of your PrestaShop admin panel's 'secret' URL.

This isn't just about keeping a low profile; it's about preventing sensitive information from inadvertently falling into the wrong hands or being logged where it shouldn't be. For any merchant, developer, or agency managing PrestaShop stores, understanding and mitigating this risk is a fundamental step towards a truly secure online presence.

The Hidden Risk: Unintended Admin URL Exposure

Many PrestaShop store owners rely on the obscurity of their admin folder name (ee.g., admin123abc) as a basic layer of security. The idea is simple: if no one knows the URL, they can't easily find the login page. However, this 'security by obscurity' can be undermined by a standard web browser behavior: the Referer HTTP header.

When you navigate from your PrestaShop back office to the storefront – perhaps by clicking 'View my shop', previewing a product, or even just following an internal link – your browser, by default, sends the full URL of the page you just left (your admin panel) to the destination page. This means the complete admin URL, including its 'secret' folder name and potentially even session tokens, can be captured in:

  • Server access logs: Every request to your storefront from the admin panel will log the full admin URL.
  • Third-party analytics platforms: Google Analytics, Matomo, and similar tools will record the referrer, exposing your admin URL in their data.
  • Marketing pixels and scripts: Any tracking pixels (Facebook, TikTok, etc.) or custom scripts installed on your storefront can capture and transmit this referrer information.

This unintended exposure compromises the 'secret' nature of your admin URL and creates a potential attack vector. An attacker gaining access to these logs or analytics could easily discover your admin login page, making brute-force or phishing attempts more targeted. Surprisingly, PrestaShop versions up to 9.2.0 do not natively implement the Referrer-Policy HTTP header, which is the industry-standard solution to control this information leakage.

Introducing the Solution: The Referrer-Policy Header

The Referrer-Policy HTTP header is a powerful web security mechanism that allows a website to declare how much referrer information (the URL of the previous page) should be sent with requests originating from that page. By setting an appropriate policy, you can prevent sensitive URLs from being transmitted to other sites or even within your own domain.

The Community-Driven Fix: ecom_referrerpolicy Module

Recognizing this critical gap, a dedicated community member, gusman126 (ecomyseo), has generously developed and shared a free, open-source module: ecom_referrerpolicy. This module is a game-changer for PrestaShop security and privacy.

Key Features and Benefits of the Module:

  • Dual Policy Implementation: It intelligently adds the Referrer-Policy header to both your PrestaShop storefront and the admin panel, with distinct, optimized values for each zone.
  • Sensible Defaults: Out-of-the-box, it applies strict-origin-when-cross-origin to the storefront (preserving analytics and affiliate tracking) and no-referrer to the admin panel (ensuring maximum privacy).
  • Customizable Control: Each zone (storefront and admin) has its own toggle and allows you to select from various policy values: no-referrer, same-origin, strict-origin, strict-origin-when-cross-origin, or origin. This flexibility allows you to tailor the policy to your specific needs.
  • Broad Compatibility: The module works seamlessly across PrestaShop 1.7.8 up to 9.2, including the login page and the modern Symfony pages within the PrestaShop 9 admin, utilizing a single, efficient hook (actionDispatcherBefore).
  • Non-Intrusive: It's designed to be a good citizen. If another module or a future native PrestaShop option already sets a Referrer-Policy header via PHP, this module will not overwrite or duplicate it.
  • Robust and Error-Free: The module is built to never cause an error. If the header cannot be sent for any reason, it simply does nothing, ensuring your store's stability.
  • Lightweight and Clean: It operates without overrides, Composer dependencies, custom database tables, or external connections, keeping your PrestaShop installation lean and manageable.
  • Multistore Ready: For those managing multiple stores, the storefront settings are per-shop, while the admin panel settings are global, offering practical management.
  • Addresses PrestaShop Specifics: A notable detail discovered during testing is PrestaShop's reliance on the Referer header for returning to old list views in the admin (e.g., carriers, cart rules). The module intelligently re-establishes this functionality, allowing you to use the strictest no-referrer policy without impacting admin usability.

The module is compatible with PHP versions 7.4 to 8.3, ensuring broad server environment support.

What the Module Doesn't Do (and Why It's Okay)

It's important to understand the scope of this module:

  • Server-Level Policies: If your web server (Apache, Nginx) or CDN already adds a Referrer-Policy header, PHP cannot see or override it. In such cases, you should choose to implement the policy either at the server level or via this module, but not both.
  • Static Assets: Images, CSS, and JavaScript files are typically served directly by your web server without passing through PrestaShop's PHP engine. Therefore, they won't carry the Referrer-Policy header. This is normal and expected; the policy that matters is the one applied to the HTML page itself.
Browser developer tools showing a Referrer-Policy header in the network tab
An illustration of how the Referrer-Policy header appears in browser developer tools.

Installation and Usage

Installing the ecom_referrerpolicy module is straightforward:

  1. Download the ZIP file from the GitHub repository.
  2. Rename the extracted folder to ecom_referrerpolicy.
  3. Re-compress the folder into a ZIP file.
  4. Upload this ZIP file via your PrestaShop module manager.

Detailed instructions and a table explaining each policy value are available in the module's README file on GitHub. The module is released under the AFL-3.0 license, encouraging community contributions and improvements.

Why This Matters for E-commerce Migrations and Development

For businesses undergoing PrestaShop migrations or actively developing their stores, integrating such security enhancements is paramount. During a migration, ensuring that sensitive data, including admin URLs, is not inadvertently exposed is a critical step in maintaining data integrity and security posture. As development progresses, adopting best practices like proper Referrer-Policy implementation helps build a more resilient and trustworthy e-commerce platform from the ground up.

At Migrate My Shop, we advocate for proactive security measures. Modules like ecom_referrerpolicy are excellent examples of how the PrestaShop community contributes to making the platform safer and more private. Implementing this module is a simple yet highly effective way to bolster your store's defenses and protect your administrative access.

Conclusion

The ecom_referrerpolicy module is a testament to the power of community-driven development in PrestaShop. It addresses a subtle but significant security and privacy concern with an elegant, robust, and free solution. By preventing the leakage of your PrestaShop admin URL, you enhance your store's overall security posture, protect sensitive data, and build greater trust with your customers.

We highly recommend all PrestaShop merchants, developers, and agencies to integrate this module into their stores. It's a small step that yields significant security benefits. For further assistance with PrestaShop security, development, or seamless e-commerce migrations, don't hesitate to contact the experts at Migrate My Shop.

Share:

Start with the tools

Explore migration tools

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

Explore migration tools