Title: [Medium][ssr] DOM-backed evaluateSSR uses new Function() eval fallback (defeats CSP-safe design) + missing proto guard · Issue #167 · bQuery/bQuery · GitHub
Open Graph Title: [Medium][ssr] DOM-backed evaluateSSR uses new Function() eval fallback (defeats CSP-safe design) + missing proto guard · Issue #167 · bQuery/bQuery
X Title: [Medium][ssr] DOM-backed evaluateSSR uses new Function() eval fallback (defeats CSP-safe design) + missing proto guard · Issue #167 · bQuery/bQuery
Description: Severity: 🟡 Medium (High if templates can carry untrusted content, e.g. a CMS/page-builder) Location src/ssr/render.ts:189-197 (new Function() fallback) and :174-187 (dot-path, missing proto guard). Used by the DOM-backed renderer — acti...
Open Graph Description: Severity: 🟡 Medium (High if templates can carry untrusted content, e.g. a CMS/page-builder) Location src/ssr/render.ts:189-197 (new Function() fallback) and :174-187 (dot-path, missing proto guard)...
X Description: Severity: 🟡 Medium (High if templates can carry untrusted content, e.g. a CMS/page-builder) Location src/ssr/render.ts:189-197 (new Function() fallback) and :174-187 (dot-path, missing proto guard)...
Opengraph URL: https://github.com/bQuery/bQuery/issues/167
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Medium][ssr] DOM-backed evaluateSSR uses new Function() eval fallback (defeats CSP-safe design) + missing proto guard","articleBody":"## Severity: 🟡 Medium (High if templates can carry untrusted content, e.g. a CMS/page-builder)\n\n## Location\n[`src/ssr/render.ts:189-197`](../blob/main/src/ssr/render.ts#L189-L197) (`new Function()` fallback) and [`:174-187`](../blob/main/src/ssr/render.ts#L174-L187) (dot-path, missing proto guard). Used by the DOM-backed renderer — active whenever a global/configured `DOMParser` exists (browsers, happy-dom, or `configureSSR({ backend: 'dom' })`).\n\n## Description\n`evaluateSSR` falls back to dynamic code generation for any non-trivial expression:\n```ts\nconst fn = new Function(...keys, `return (${trimmed});`);\nreturn fn(...values);\n```\nThis directly contradicts the module's stated security posture — [`src/ssr/expression.ts`](../blob/main/src/ssr/expression.ts) was written specifically to be CSP-safe (no `eval`/`Function`) — and re-introduces `unsafe-eval` on the DOM path. If any part of a template expression is attacker-influenced, this is code execution.\n\nAdditionally, the fast dot-notation path (`render.ts:174-187`) does **not** call `isPrototypePollutionKey`, unlike the hardened `expression.ts` (`lookupIdent`/`safeMember`). `evaluateSSR('constructor.constructor', ctx)` walks the prototype chain and returns the `Function` constructor — an inconsistent hardening gap and a stepping stone when combined with the `new Function` fallback.\n\n## Suggested fix\nReplace `evaluateSSR` with the CSP-safe `evaluateExpression` from `expression.ts` (already used by the pure renderer), eliminating both the `new Function` fallback and the prototype-pollution gap, and unifying evaluator behaviour across backends.\n\n---\n_Filed as part of a full-codebase security \u0026 correctness audit._\n","author":{"url":"https://github.com/JosunLP","@type":"Person","name":"JosunLP"},"datePublished":"2026-07-05T17:03:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/167/bQuery/issues/167"}
| 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:57ca42ec-cf02-c769-30c2-56959b20a796 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F8E:8AE8C:768A77A:A68D259:6A5023ED |
| html-safe-nonce | 18f20f934280cbc2e6223480a26d8f1391944285497fe7e2124cd23799b5e302 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjhFOjhBRThDOjc2OEE3N0E6QTY4RDI1OTo2QTUwMjNFRCIsInZpc2l0b3JfaWQiOiI2OTYzMzU3NTA3Mjk0MDc3OTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ad03446ecaeddde656a0ed4dbd208b225afb3c5616065aebcdb60dcfa21dad52 |
| hovercard-subject-tag | issue:4813694107 |
| 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/bQuery/bQuery/167/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fc3afe1fee22e2e6c020a80ce4fc4456055d0a6fd1457dff12986a4343d5e2ce/bQuery/bQuery/issues/167 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fc3afe1fee22e2e6c020a80ce4fc4456055d0a6fd1457dff12986a4343d5e2ce/bQuery/bQuery/issues/167 |
| og:image:alt | Severity: 🟡 Medium (High if templates can carry untrusted content, e.g. a CMS/page-builder) Location src/ssr/render.ts:189-197 (new Function() fallback) and :174-187 (dot-path, missing proto guard)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JosunLP |
| hostname | github.com |
| expected-hostname | github.com |
| None | a08040246389072795e3b4e7b33c6d9a0c564eee02e829a809326d67c418b069 |
| turbo-cache-control | no-preview |
| go-import | github.com/bQuery/bQuery git https://github.com/bQuery/bQuery.git |
| octolytics-dimension-user_id | 256381806 |
| octolytics-dimension-user_login | bQuery |
| octolytics-dimension-repository_id | 1139284244 |
| octolytics-dimension-repository_nwo | bQuery/bQuery |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1139284244 |
| octolytics-dimension-repository_network_root_nwo | bQuery/bQuery |
| 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 | d1b91b18e7330fc458dfd824c61eaed7daa830d6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width