ocis icon indicating copy to clipboard operation
ocis copied to clipboard

duplicated CSP frame-ancestors policy

Open wkloucek opened this issue 1 year ago • 6 comments

Describe the bug

On the root path of oCIS, we get two content-security-policy headers. One has a static frame-ancestors 'self' config

Steps to reproduce

  1. run oCIS 6.3.0 eg. in Kubernetes using the development-install deployment example
  2. open oCIS, eg https://ocis.kube.owncloud.test/ after opening the network console
  3. Look at the request to https://ocis.kube.owncloud.test/

Expected behavior

Have one header content-security-policy reflecting my oCIS csp configuration.

Actual behavior

image

Further context

The second header seems to be statically set to frame-ancestors 'self' and always there, even if I have a more sophisticated CSP config

wkloucek avatar Sep 12 '24 14:09 wkloucek

This additional header probably originates here:

https://github.com/owncloud/ocis/blob/a7a10f8f0c91859b7f3406d39d618ceded9a47e2/services/web/pkg/middleware/silentrefresh.go#L7-L13

wkloucek avatar Sep 12 '24 14:09 wkloucek

And what it actually does: it takes precedence over the frame-ancestors policy in the first header...

wkloucek avatar Sep 12 '24 14:09 wkloucek

@kulmann @JammingBen

Escalating it to P2

micbar avatar Sep 23 '24 08:09 micbar

As far as I know, the CSP is fully handled by the proxy service (through the csp.yaml file), and no other service should try to set the CSP. The easiest solution is to remove that header from the web service and let the proxy service to handle it; we might need to document that the frame-ancestor 'self' (or a more relaxed) policy is required.

Alternatively, we could implement a way for any service to overwrite the CSP in the proxy service. In this case, the web service would require the proxy service to set, at least, the frame-ancestor 'self' policy. However, the solution seems complex and will require proper design. Note that setting the policy might be critical (service might not work properly if the policy isn't set), and we need to deal with communication errors between the services.

jvillafanez avatar Sep 24 '24 08:09 jvillafanez

The easiest solution is to remove that header from the web service and let the proxy service to handle it;

Yes. That should do it for now.

micbar avatar Sep 24 '24 08:09 micbar

https://github.com/owncloud/ocis/pull/10146 should fix the double CSP header.

jvillafanez avatar Sep 24 '24 09:09 jvillafanez

PR merged. Closing.

jvillafanez avatar Sep 25 '24 08:09 jvillafanez