-
Notifications
You must be signed in to change notification settings - Fork 68
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
Tree control triggers errors with CSP #171
Comments
You can take a look into this example file i configured a csp header with jsDelivr seems to work. Also checked your repo. Maybe you configured your csp header wrong? If i check the documentation here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/Sources#sources //EDIT Looks like a kind of URL Schema is also allowed, but i'm not such an expert in CSP headers to be honest |
@danielleroux thanks for looking into this. Your example only works because it contains the Once you remove it, you'll see the errors also there. Check my fork: https://codesandbox.io/s/suspicious-lamport-b3dvy4 The layout is broken there too EDIThttps://content-security-policy.com/unsafe-inline/ provides more information about |
I dont see point here. If you trust an cdn provider you can never be "safe" nobody have control over this server. If someone replace the source files on the cdn you are in a trust enviroment and the scripts are also executed with the malicious code. If you have problem with trust i recommand to host your 3rd party dependency on your own server Possible nonce support: ionic-team/stencil#3823 Fix for your probleme could be use sha: ionic-team/stencil#496 (comment) |
@danielleroux I'm sorry if I caused confusion with mentioning the CDN setup at all. And this is also not the problem here as the CDN is explicitly trusted ( The CSP shall (amongst others) protect against injection attacks. You tell the browser "I don't have any inline styles in my pages and only load them from these well-defined servers". If an attacker is able to inject inline styles (or inline JavaScript) to your application (or links to other styles/scripts), browsers can block this because we informed them that we don't have any inline styles at all. The locations where the browser complains about are setting styles via JavaScript which is apparently considered an inline style because they work like:
|
Yes, this might help. Browsing through the Stencil issues, I found ionic-team/stencil#3203 which also reads like my issue... |
@erlmann Maybe i can try to create sha checksums for each inline style this can be used as trusted csp entry then. This will one approche until the pr ionic-team/stencil#3823 is merged and release. |
@danielleroux Yes, adding the checksums to the CSP shall serve as workaround. I'll go for this and add the four checksums reported by the browser to my CSP, knowing that this will break as soon as a single character in the styles is changed 😅. |
@erlmann No don't do this manually 😊 I will try to integrate a script in our build process which will generate a sha map or something like that. |
Looks like stencil have released some CSP support. We will check this during the development release. |
Feature is available only in stencil v3.0.0. Due to internal planning moved to next release (#327 ) |
I'm submitting a...
Current behavior
When using the Tree control in an application that uses a CSP to prevent inline styles, the control is not rendered properly. Instead, an error is thrown by the browser.
I'm loading iX packages from
jsdelivr.net
but this should not matter here.Used CSP:
default-src 'self' https://cdn.jsdelivr.net/npm/@siemens/ix@1.1.0/ https://cdn.jsdelivr.net/npm/@siemens/ix-icons@1.0.1/
Result:
The behavior is not tied to my application of the Tree control. It could already be observed with the sample (https://ix.siemens.io/docs/controls/tree/) if the server would return a CSP.
Expected behavior
No errors should be generated.
Minimal reproduction of the problem with instructions
EDIT
I have set up a repo holding a sample project: https://github.com/erlmann/repro-siemens-ix-171
git clone https://github.com/erlmann/repro-siemens-ix-171 cd repro-siemens-ix-171 python3 server.py
Then, browse to
http://localhost:8080/index.html
to see the issue.What is the motivation / use case for changing the behavior?
Use of a CSP is a common security requirement.
The text was updated successfully, but these errors were encountered: