Skip to content

Error 500 CSP #39192

@marctbb

Description

@marctbb

Preconditions and environment

  • Magento version: 2.4.7
  • Community version
  • Php version 8.3

Steps to reproduce

I'am currently managing a Magento 2.4.7 instance on an Apache server, and we have encountered issues related to Content Security Policies (CSP) after updates and the installation of third-party plugins. The problem manifests as CSP errors in the console, which we have addressed by adding specific directives to our custom whitelist located in app/code. Additionally, these third-party plugins have added their own CSP rules in their respective whitelists.

Over time, we’ve cleaned our custom whitelist to remove directives already included by the third-party plugins. However, we’ve now reached a point where we cannot reduce the whitelist further, as the remaining entries in our custom CSP whitelist are unique across the codebase. Removing them would result in console CSP errors.

The core issue is that Apache imposes a limit on the number of CSP directives. When this limit is exceeded, we encounter 500 server errors, rendering both the frontend and backend of Magento unusable.

It is possible to remove csp in the whitelists of third party plugins and thus reduce the number of csp and therefore the frontend and backend are shown. But this means that there is a possibility of errors appearing in the console and having the problem in future updates.

It should be noted that it is only reproducible if the Magento is on a server, it does not work on localhost.

Expected result

The expected result is that magento will detect the csp's that are added to the head and if it finds that they are duplicated in several whitelists it will only add or use one of those.
With this you would be able to see both the forntend and the backend without any problem.

Actual result

The current result is as I said, we get error 500 in both the frontend and the backend and it is not possible to work.
Is there a way for magento to handle csp correctly?

Additional information

I found this, maybe it helps to understand the issue:
https://konkretor.com/2022/07/07/apache-ah01070-error-parsing-script-headers/

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: FrameworkComponent: CspIssue: needs updateAdditional information is require, waiting for responseReported on 2.4.7Indicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions