Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Content-Security-Policy directive 'frame-ancestors' does not support the source expression ''unsafe-inline'' #33101

Closed
minhluan259 opened this issue May 30, 2021 · 38 comments · Fixed by #33202
Assignees
Labels
Component: Security Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@minhluan259
Copy link

Preconditions (*)

  1. Magento 2.4.2-p1 with sample data
  2. Chrome v91

Steps to reproduce (*)

  1. Open console in Google Chrome (F12)
  2. Reload the homepage

Expected result (*)

  1. Console without error

Actual result (*)

  1. Console is displaying error:
    The Content-Security-Policy directive 'frame-ancestors' does not support the source expression ''unsafe-inline''

How to solve 'frame-ancestors' issue?

@m2-assistant
Copy link

m2-assistant bot commented May 30, 2021

Hi @minhluan259. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@mrtuvn
Copy link
Contributor

mrtuvn commented May 31, 2021

Seem you have add whitelist csp to your external resources. Otherwises browser will raise error like that
Ex: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Csp/etc/csp_whitelist.xml

@TheRealHunzik
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @TheRealHunzik. Thank you for your request. I'm working on Magento instance for you.

@minhluan259
Copy link
Author

@mrtuvn it's not about whitelist issue, because on default luma theme we do not have any iframe (object, embed, ... https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors ) tags.
the problem is 'unsafe-inline' only support by 'script-src'
and 'frame-ancestors' does not support the source expression ''unsafe-inline''
https://content-security-policy.com/unsafe-inline/

@engcom-Echo engcom-Echo self-assigned this May 31, 2021
@m2-assistant
Copy link

m2-assistant bot commented May 31, 2021

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Echo
Copy link
Contributor

Hi Minhluan259,

Please refer the devdocs link - https://devdocs.magento.com/guides/v2.4/extension-dev-guide/security/content-security-policies.html
For CSP related information.

Hope this link will help you resolve this issue that you are getting.

Let me know , if the information does not suffice your query.

Thanks

@engcom-Echo engcom-Echo added the Issue: needs update Additional information is require, waiting for response label Jun 1, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jun 1, 2021
@minhluan259
Copy link
Author

@engcom-Echo please read this:

@mrtuvn it's not about whitelist issue, because on default luma theme we do not have any iframe (object, embed, ... https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors ) tags.
the problem is 'unsafe-inline' only support by 'script-src'
and 'frame-ancestors' does not support the source expression ''unsafe-inline''
https://content-security-policy.com/unsafe-inline/

@refueledinc
Copy link

I'm in agreement with @minhluan259 - the issue is happening because frame-ancestors does not support unsafe-inline.

The issue is reported as an error in console starting in Chrome v91.

@refueledinc
Copy link

refueledinc commented Jun 1, 2021

I have not fully tested this, but changing line https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Csp/etc/config.xml#L109 to <inline>0</inline> appears to resolve the issue for me. Be sure to run php bin/magento c:c after the change.

@jmonrove
Copy link

jmonrove commented Jun 2, 2021

Having the same issue on 2.4.2, Chrome 91.0.4472.77. @refueledinc's solution worked, but instead of doing it on the core file I added a section to my custom CSP extension

@engcom-Echo engcom-Echo added Issue: ready for confirmation and removed Issue: needs update Additional information is require, waiting for response labels Jun 3, 2021
@m2-community-project m2-community-project bot moved this from Needs Update to Ready for Confirmation in Issue Confirmation and Triage Board Jun 3, 2021
@jmonrove
Copy link

jmonrove commented Jun 3, 2021 via email

@pathakkrunal
Copy link

This is how mine looks: <report_uri>https://yoururl.com/</report_uri> <report_uri>https://yoururl.com/</report_uri> <policy_id>frame-ancestors</policy_id> 1 0 0 0

On Thu, Jun 3, 2021 at 9:53 AM kunzi @.***> wrote: Having the same issue on 2.4.2, Chrome 91.0.4472.77. @refueledinc https://github.com/refueledinc's solution worked, but instead of doing it on the core file I added a section to my custom CSP extension Could you share your file as I could not get this fix to work in my custom module's config.xml? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#33101 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHZMN4SV3BQCW2KE3NDDFXTTQ6XRLANCNFSM45ZSOOGQ .

this help for me too
Thank you.

@davirs
Copy link

davirs commented Jun 7, 2021

@jmonrove @pathakkrunal what is the solution? I think the repository not exists anymore..
Can you share the solution, please

@uisuru
Copy link

uisuru commented Jun 7, 2021

@refueledinc and @jmonrove solution is working.
@davirs

  1. Create a new module or use an existing one.
  2. Create a file called config.xml in the etc folder
  3. put the following content to the file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <csp>
            <policies>
                <storefront>
                    <frame-ancestors>
                        <inline>0</inline>
                    </frame-ancestors>
                </storefront>
            </policies>
        </csp>
    </default>
</config>

  1. Delete static folder and clean cache

@engcom-Echo engcom-Echo added Component: Security Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reproduced on 2.4.2 Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Jun 14, 2021
@m2-community-project m2-community-project bot added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jul 27, 2021
@magento-engcom-team
Copy link
Contributor

@m2-community-project[bot] Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jul 27, 2021
@magento-engcom-team
Copy link
Contributor

@m2-community-project[bot] Thank you for verifying the issue.

Unfortunately, not enough information was provided to acknowledge ticket. Please consider adding the following:

  • Add "Reproduced on " label(s) to this ticket based on verification result

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@m2-community-project m2-community-project bot moved this from Confirmed to Ready for Confirmation in Issue Confirmation and Triage Board Jul 27, 2021
@engcom-Hotel engcom-Hotel added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch and removed Issue: ready for confirmation labels Jul 27, 2021
@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Jul 27, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Hotel
Thank you for verifying the issue. Based on the provided information internal tickets MC-42876 were created

Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@m2-community-project m2-community-project bot added this to Pull Request In Progress in High Priority Backlog Jul 27, 2021
@m2-community-project m2-community-project bot removed this from Ready for Confirmation in Issue Confirmation and Triage Board Jul 27, 2021
@m2-community-project m2-community-project bot added Progress: PR in progress and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Jul 27, 2021
@andrei-vdc
Copy link

@magento-engcom-team how come you agree that disabling security enhancements "fixes the issues" instead of guiding the community on how to create implementation that make use of your own SECURITY POLICIES?

@speedupmate
Copy link
Contributor

speedupmate commented Aug 18, 2021

2.4.3 affected logged in every page to console

The Content-Security-Policy directive 'frame-ancestors' does not support the source expression ''unsafe-inline''

@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Aug 20, 2021
seyuf added a commit to MAD-I-T/magento-worldline-sips2 that referenced this issue Aug 26, 2021
@przmak
Copy link

przmak commented Sep 23, 2021

So why this is closed while this error occurs ? :) I just checked a random site with magento 2.4.2 demo and it seems the error appears there
https://demo-m2.bird.eu/

@markshust
Copy link
Contributor

markshust commented Sep 23, 2021 via email

@YetiCGN
Copy link

YetiCGN commented Oct 5, 2021

I have not fully tested this, but changing line https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Csp/etc/config.xml#L109 to <inline>0</inline> appears to resolve the issue for me. Be sure to run php bin/magento c:c after the change.

What also helps is deactivating the Csp module altogether: bin/magento module:disable Magento_Csp.

@ChameleonDevil
Copy link

ChameleonDevil commented Nov 4, 2021

What also helps is deactivating the Csp module altogether: bin/magento module:disable Magento_Csp.

I see alot of downvotes, basically because: What you actually inadvertently do when you disable the module, is to completely disable a new security feature created by Magento core, from the official documentation a better explanation than I can:

Content Security Policies (CSP) are a powerful tool to mitigate against Cross Site Scripting (XSS) and related attacks, including card skimmers, session hijacking, clickjacking, and more. Web servers send CSPs in response HTTP headers (namely Content-Security-Policy and Content-Security-Policy-Report-Only) to browsers that whitelist the origins of scripts, styles, and other resources

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/security/content-security-policies.html

Perhaps you should try to look at re-enabling Magento_Csp and then use the csp_whitelist.xml to whitelist your trusted content in the future rather.

@gvasilakiss
Copy link

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @gvasilakiss. Thank you for your request. I'm working on Magento instance for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Security Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: ready for confirmation Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.