Title: Updated Recommendations for CSP and Avoiding 'unsafe-eval' · Issue #156 · Dynamsoft/barcode-reader-javascript · GitHub
Open Graph Title: Updated Recommendations for CSP and Avoiding 'unsafe-eval' · Issue #156 · Dynamsoft/barcode-reader-javascript
X Title: Updated Recommendations for CSP and Avoiding 'unsafe-eval' · Issue #156 · Dynamsoft/barcode-reader-javascript
Description: Hello Dynamsoft Team, We are a team developing an Angular web app with PWA capabilities and are integrating the dynamsoft-barcode-reader-bundle (version 10.4.3100). Our application hosts the required Dynamsoft resources locally to ensure...
Open Graph Description: Hello Dynamsoft Team, We are a team developing an Angular web app with PWA capabilities and are integrating the dynamsoft-barcode-reader-bundle (version 10.4.3100). Our application hosts the requir...
X Description: Hello Dynamsoft Team, We are a team developing an Angular web app with PWA capabilities and are integrating the dynamsoft-barcode-reader-bundle (version 10.4.3100). Our application hosts the requir...
Opengraph URL: https://github.com/Dynamsoft/barcode-reader-javascript/issues/156
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Updated Recommendations for CSP and Avoiding 'unsafe-eval'","articleBody":"Hello Dynamsoft Team,\n\nWe are a team developing an Angular web app with PWA capabilities and are integrating the dynamsoft-barcode-reader-bundle (version 10.4.3100). Our application hosts the required Dynamsoft resources locally to ensure quick and seamless caching via our service worker. These resources include the following:\n\n```\n/assets/dynamsoft-capture-vision-std/std.js\n/assets/dynamsoft-capture-vision-std/std.wasm\n/assets/dynamsoft-image-processing/dip.wasm\n/assets/dynamsoft-core/core.js\n/assets/dynamsoft-core/core.worker.js\n/assets/dynamsoft-core/core.wasm\n/assets/dynamsoft-license/license.js\n/assets/dynamsoft-license/dls.license.dialog.html\n/assets/dynamsoft-license/license.wasm\n/assets/dynamsoft-utility/utility.js\n/assets/dynamsoft-barcode-reader/dbr.js\n/assets/dynamsoft-barcode-reader/dbr.wasm\n/assets/dynamsoft-barcode-reader/DBR-PresetTemplates.json\n/assets/dynamsoft-capture-vision-router/cvr.js\n/assets/dynamsoft-capture-vision-router/cvr.wasm\n/assets/dynamsoft-capture-vision-router/cvr.worker.js\n/assets/dynamsoft-camera-enhancer/dce.js\n/assets/dynamsoft-camera-enhancer/dce.ui.html\n```\nCurrently, we are concerned about having to use 'unsafe-eval' in our Content Security Policy (CSP). Our CSP configuration is defined in a web.config file and looks like this:\n\n```\n\u003cadd name=\"Content-Security-Policy\"\n value=\"default-src 'self' login.microsoftonline.com; \n script-src 'self' 'unsafe-eval'; \n style-src 'self' 'unsafe-inline'; \n img-src http: https: data:; \n connect-src 'self' login.microsoftonline.com mdls.dynamsoftonline.com sdls.dynamsoftonline.com data:; \n frame-ancestors 'none'; \n font-src 'self' data:\" />\n```\nThis setup works but requires 'unsafe-eval' for the library to function, which we would like to avoid for security reasons. Ideally, we aim to:\n\n- Use 'wasm-unsafe-eval' instead of 'unsafe-eval' (or a similarly scoped policy).\n- Specify more restrictive CSP rules (e.g., per-directory or per-file rules) for Dynamsoft resources to minimize the risk.\n\nWe came across [Issue #102](https://github.com/Dynamsoft/barcode-reader-javascript/issues/102) from October 2021, which provides minimum CSP requirements. However, that post is over three years old, and we were wondering if there have been any updates since then.\n\nAdditionally, we attempted to set CSP-specific rules for Dynamsoft files by using `\u003clocation>` nodes in web.config:\n\n```\n\u003clocation path=\"\u003cpath-to-dynamsoft-files>\">\n \u003csystem.webServer>\n \u003chttpProtocol>\n \u003ccustomHeaders>\n \u003cadd name=\"Content-Security-Policy\" \n value=\"...specific CSP rules here...\" />\n \u003c/customHeaders>\n \u003c/httpProtocol>\n \u003c/system.webServer>\n\u003c/location>\n```\nUnfortunately, this approach resulted in an error when trying to load core.worker.js.\n\nQuestions:\n\n1. Are there updated recommendations for configuring CSP to avoid 'unsafe-eval' with Dynamsoft libraries?\n2. Is there a roadmap or consideration for removing the reliance on 'unsafe-eval' in the library?\n3. Are there best practices for hosting Dynamsoft resources locally while maintaining a secure CSP?\n\nThank you for your guidance and support!\n\nBest regards,\nRune","author":{"url":"https://github.com/rujep","@type":"Person","name":"rujep"},"datePublished":"2025-01-21T14:46:41Z","url":"https://github.com/Dynamsoft/barcode-reader-javascript/issues/156"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e9d39b7e-9c92-ddb5-06d0-9c1e2af2b615 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DABC:29FFA9:1297EC5:179B036:6B011E7E |
| html-safe-nonce | 79cef9f5c0ca2db907dcf0d59b6fe1076ac1d0b079c679f53d6a783aa36b2839 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUJDOjI5RkZBOToxMjk3RUM1OjE3OUIwMzY6NkIwMTFFN0UiLCJ2aXNpdG9yX2lkIjoiNzcwNzkwMDI3NTcyOTcwMjUyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e50138a9313e1905c1dd057bb12296639c6307ad809e76f54314ccbe8bccf214 |
| hovercard-subject-tag | issue:2802057311 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Dynamsoft/barcode-reader-javascript/156/issue_layout |
| twitter:image | https://opengraph.githubassets.com/196d45ecace82e1e1f08baa1f529362e842456d9e3475ff248d7f39fd9bc1c7f/Dynamsoft/barcode-reader-javascript/issues/156 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/196d45ecace82e1e1f08baa1f529362e842456d9e3475ff248d7f39fd9bc1c7f/Dynamsoft/barcode-reader-javascript/issues/156 |
| og:image:alt | Hello Dynamsoft Team, We are a team developing an Angular web app with PWA capabilities and are integrating the dynamsoft-barcode-reader-bundle (version 10.4.3100). Our application hosts the requir... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rujep |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/Dynamsoft/barcode-reader-javascript git https://github.com/Dynamsoft/barcode-reader-javascript.git |
| octolytics-dimension-user_id | 5820187 |
| octolytics-dimension-user_login | Dynamsoft |
| octolytics-dimension-repository_id | 145683056 |
| octolytics-dimension-repository_nwo | Dynamsoft/barcode-reader-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145683056 |
| octolytics-dimension-repository_network_root_nwo | Dynamsoft/barcode-reader-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width