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

Bug-fix: CSP violated-directive: style-src-attr #319

Open
oioix opened this issue Mar 9, 2024 · 1 comment
Open

Bug-fix: CSP violated-directive: style-src-attr #319

oioix opened this issue Mar 9, 2024 · 1 comment
Assignees

Comments

@oioix
Copy link

oioix commented Mar 9, 2024

AddOns: consent_manager 4.2.0

Inline Style in consent_manager_box.php

Wenn man CSP im Einsatz hat und in consent_manager einen Dienst verwendet, der nach dem Einverständnis ein Script lädt, bekommt man einen CSP-Verstoß.

Screenshot 2024-03-09 | 17 51 44

Grund des Problems
In der Datei consent_manager_box.php Zeile 98 findet sich nachfolgende Zeile mit dem Inline style: style="display: none"
echo '<div style="display: none" class="consent_manager-script" data-uid="script-' . $uid . '" data-script="' . $script . '"></div>';

Da diese Zeile nur geladen wird, wenn man einen Dienst mit Script aktiviert hat, fällt das Problem ansonsten nicht auf. Mir ist es nun auch nur aufgefallen, weil ich erstmals ein YouTube-Video mit dem Addon plyr einbinden wollte.

Lösung:
Das div hat ohnehin keinen sichtbaren(!) Inhalt, weil es nur dazu dient das für den Dienste benötigte Script im div-Attribut data-script="" zuspeichern und später im Falle der Zustimmung in diesem div als <script></script> (also weiterhin unsichtbar)zu injizieren.

Daher kann man den Inline-Style style="display: none" einfach löschen und der Spuk hat ein Ende.
Wie gesagt man sieht das leere div nicht. Vorsorglich hab im CSS dennoch den entfernten Inline-Style aufgenommen:
consent_manager-script {display:none;}

@oioix
Copy link
Author

oioix commented Apr 20, 2024

In dem PR, den ich heute auf Wunsch von bitshiftergmbh eingestellt habe, ist das style="display: none" nun nicht mehr drin. Insofern ist es damit gelöst.

Allerdings habe ich kein CSS geändert, also kein consent_manager-script {display:none;} in irgendeinem css/scss aufgenommen, weil in meinen Tests - wie schon beschrieben - das div ohnehin nicht sichtbar war, weil das Script hier nur als base64 im Attribut des divs aufgegeben wurde und das div-tag ansonsten keinen Inhalt hat.
Wollte ich vorsorglich nur noch anmerken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants