Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Plugin causes CSP (Content Security Policy) violations, cannot use CSP block and ID-card signing functionality at the same time #158

Closed
tiblu opened this issue Feb 19, 2020 · 5 comments · Fixed by #180

Comments

@tiblu
Copy link

tiblu commented Feb 19, 2020

Problem

A website wanting to support ID-card signing cannot use CSP to block on policy violations because Token Signing plugin will not work if the CSP is set to block.

Example:

{ 
   "blocked-uri":"inline",
   "column-number":44,
   "document-uri":"https://app.citizenos.com/",
   "line-number":128,
   "original-policy":"default-src 'self' 'report-sample'; img-src *; script-src 'self' https://cdn.crowdin.com https://apis.google.com https://www.google-analytics.com 'report-sample'; style-src 'self' https://fonts.googleapis.com 'sha256-swnxFqaff0i3bsLtJDRpMd5tZFLBnglxSxSqPSAWdIk='; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://id.citizenos.com https://api.citizenos.com https://sentry.io https://graph.microsoft.com https://www.google-analytics.com; base-uri 'self'; object-src 'none'; frame-src https://p.citizenos.com/ https://accounts.google.com/ https://docs.google.com; report-uri https://api.citizenos.com/api/internal/report",
   "referrer":"",
   "script-sample":"// Promises \nvar _eid_promises = {}; \n//…",
   "source-file":"moz-extension://d6dfd14d-b72d-49dc-8586-53ec01e217dd/content.js",
   "violated-directive":"script-src"
}

Reproduce

  • Download latest Firefox
  • Install Estonian ID-card software
  • Visit https://app.citizenos.com
  • Create a Topic
  • Send the Topic to Voting, configure Hard ID voting.
  • Vote with ID-card and see console for CSP reports.

image

Fix?

Resources

@taneltm
Copy link
Contributor

taneltm commented Oct 26, 2020

The extension needs to inject the TokenSigning function so that we don't break the implementation on existing websites.
What we can do is allow websites to add the page script by themselves and before the extension injects the page script, it checks the website if the code is already there.

The requirement would be that the script tag which loads the page.js code needs to have a data-name="TokenSigning" attribute.

<script src="path-to/page.js" data-name="TokenSigning"></script>

@tiblu
Copy link
Author

tiblu commented Oct 28, 2020

The extension needs to inject the TokenSigning function so that we don't break the implementation on existing websites.
What we can do is allow websites to add the page script by themselves and before the extension injects the page script, it checks the website if the code is already there.

The requirement would be that the script tag which loads the page.js code needs to have a data-name="TokenSigning" attribute.

<script src="path-to/page.js" data-name="TokenSigning"></script>

Thanks for the info! If that works, fine by me.

taneltm added a commit to taneltm/chrome-token-signing that referenced this issue Nov 24, 2020
taneltm added a commit to taneltm/chrome-token-signing that referenced this issue Dec 1, 2020
Signed-off-by: Tanel Metsar <tanel.metsar@cgi.com>
@ilmartyrk
Copy link

ilmartyrk commented Apr 12, 2021

Hi, thank you for this workaround @taneltm. Hope that your pull gets merged soon as adding page.js file works in chrome without any errors, but still triggers errors in Firefox and Safari. At least functionality is now working and ID-card is still usable

@kinomehhaanik
Copy link

kinomehhaanik commented Jun 8, 2021

We could not reproduce the problem: signing with ID-card in Firefox was successful in Windows and macOS.
Only situation where we met similar error message in the web developer console was when

  • logging in with ID-card and
  • opening My Account view
    in the app.citizenos.com website.

Has the citizenos.com website been changed meanwhile?

@ilmartyrk
Copy link

@kinomehhaanik we used the suggestion from @taneltm and copied the https://github.com/open-eid/chrome-token-signing/blob/master/extension/page.js into our own code, this allows the id plugin to work properly. I hope you can accept his pull and merge it into next release as it is a good way to get this plugin working on pages with CSP.

metsma added a commit to taneltm/chrome-token-signing that referenced this issue Jun 10, 2021
Safari Token Signing

Signed-off-by: Raul Metsma <raul@metsma.ee>
taneltm added a commit to taneltm/chrome-token-signing that referenced this issue Jun 11, 2021
Signed-off-by: Tanel Metsar <tanel.metsar@cgi.com>
taneltm pushed a commit to taneltm/chrome-token-signing that referenced this issue Jun 11, 2021
Safari Token Signing

Signed-off-by: Raul Metsma <raul@metsma.ee>
@kristelmerilain kristelmerilain linked a pull request Jun 11, 2021 that will close this issue
kristelmerilain pushed a commit that referenced this issue Jun 11, 2021
* Workaround for CSP issues (#158)

Signed-off-by: Tanel Metsar <tanel.metsar@cgi.com>

* Workaround for CSP issues (#158)

Safari Token Signing

Signed-off-by: Raul Metsma <raul@metsma.ee>

Co-authored-by: Raul Metsma <raul@metsma.ee>
mbakhoff added a commit to mbakhoff/chrome-token-signing that referenced this issue Dec 26, 2021
Signed-off-by: Märt Bakhoff <mbakhoff@sigil.red>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants