Details
Patches
To fix the problem, we took the following measures (in no particular order):
- We apply DOMpurify (a library we already use to sanitize user-submitted HTML via the Markdown format) to the SVG preview, too. It strips script tags and other uncommon security-relevant and potentially malicious tags/properties from the SVG file. So whether you open the SVG in a new tab or not and whether CSP is present and enabled or not does not matter any more, as the displayed SVG is sanitized.
- As a further defence in depth mechanism we now send the CSP both as an HTTP header, as well as a meta tag. This protects instance with mis-configured web servers, CDNs, proxy or similar, from stripping or breaking the CSP headers, as they still get the CSP inside of the HTML content itself. Please note though, that the meta tag approach is not as strong as the HTTP header approach and should thus only be considered as a fallback.
- The PrivateBin Directory now also scans whether the recommend Content-Security-Policy header is used on a given instance. If you do not want to have your website appear in the list, but check it manually you can use a separate check page there.
The code-changes in PrivateBin can be found in https://github.com/PrivateBin/PrivateBin/pull/906.
Note: Please note that we explicitly chose to _not_ apply _DOMPurify_ if you download the (SVG) attachment with the download button. Subsequently, if a user would manually opens the downloaded SVG in the browser, it will be opened from the file:// protocol and thus from a different origin, so all reference to the download location is lost and no more security risk is associated with that, than opening any website or local HTML file. Thus, the SVG file with stay intact in it's original form, if you download the attachment.
We consider the execution of code from attachments outside of the PrivateBin instance's context to be out of scope to mitigate (i.e. malware in executables, office documents macros, PDF scripts), as all of these require client side mitigations to be applied to all such downloaded file types, independent on where they get downloaded from.
Workarounds
We strongly recommend you to upgrade to our latest release, especially as we also upgraded outdated and potential vulnerable libraries (see below). However, here are two workarounds that may help you to mitigate this vulnerability:
- Update the CSP in your configuration file to the latest recommended settings and check that it isn't getting reverted or overwritten by your web server, reverse proxy or CDN, i.e. using our offered check service.
- Deploying PrivateBin on a separate domain may limit the scope of the vulnerability to PrivateBin itself and thus, as described in the “Impact” section, effectively prevent any damage by the vulnerability to other resources you are hosting.
- As explained in the impact assessment, disabling attachments also prevents this issue.
References
We highly encourage server administrators and others involved with the PrivateBin project to read-up on how Content-Security-Policies work, especially should you consider to manually adjust it:
- https://content-security-policy.com/
- https://developer.mozilla.org/docs/Web/HTTP/CSP
- https://developers.google.com/web/fundamentals/security/csp/
Also please note that if multiple headers are set (as e.g. done via our now introduced meta tag) browsers should apply the most restrictive set of the policies, as per the CSP specification.
For more information
Please notice we also upgraded jQuery that was reported to us as being vulnerable both by our automated container security scanning as well as by users.
By doing so, we also updated all other dependencies we use. Our tooling identified the following vulnerabilities in jQuery:
- CVE-2020-11023
- CVE-2020-11022
In a limited assessment about these when we were made aware of them we could not find any immediate risk, but nevertheless, we encourage users to upgrade to be on the safe side.
Finally, we also upgraded zlib to address CVE-2018-25032.
Timeline
- 2022-02-22 – Initial contact by reporter.
- 2022-02-25 – Reporter sends in a detailed report.
- 2022-02-26 – Report gets reviewed, initial findings around the content security get shared and reporter withdraws report.
- 2022-04-09 – Vulnerability details published.
Credits
This vulnerability was reported by Ian Budd, Nethemba s.r.o, which we'd like to thank for that.
In general, we'd like to thank everyone reporting issues and potential vulnerabilities to us.
If you think you have found a vulnerability or potential security risk, we'd kindly ask you to follow our security policy and report it to us. We then assess the report and will take the actions we deem necessary to address it.