Extension 26.38.0: evmAsk.js uses new Function (Zod JIT), so connecting fails on dApps whose CSP doesn't allow 'unsafe-eval' #537
Unanswered
dperdic-streamflow
asked this question in
Help & Support
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Since extension 26.38.0, connecting Phantom to our dApp fails with a generic JSON-RPC error, both in the desktop extension and in the mobile in-app browser. It worked before this version, and our CSP has never allowed
'unsafe-eval'.The injected
evmAsk.jsscript now callsnew Function(Zod 4's JIT compilation) while parsing provider notifications inhandleNotification. Our page CSP doesn't allow'unsafe-eval', so the browser throws anEvalErrorand the connect request never completes.Scripts injected into third-party pages run under that page's CSP, and many security-conscious dApps don't allow
'unsafe-eval'. Our only workaround is adding'unsafe-eval'to our CSP, which weakens security for all our users.Suggested fix: turn off Zod's JIT in every bundle injected into web pages, before any schemas are defined:
The likely cause is Zod's cached eval check (
util.allowsEval). In the injected script, it evidently reports eval as allowed even though the page CSP blocks it, so Zod takes thenew Functionpath instead of falling back.Example
https://app.streamflow.finance
Steps to Reproduce
script-srcdoes not include'unsafe-eval'.The Phantom mobile in-app browser fails the same way on the same site.
Expected: connecting works regardless of whether the page's CSP allows
'unsafe-eval', as it did before 26.38.0.Phantom Version
Extension 26.38.0 (Chrome); mobile app in-app browser (26.38.0))
Is there an existing discussion for this?
All reactions