-
Notifications
You must be signed in to change notification settings - Fork 35
Description
- Laravel Version: 5.8.33
- Nova Version: 2.3.0
- PHP Version: 7.3.9
Description
This is a deployment issue caused by overall code structure, rather than any specific bit of code.
If you have a very strict CSP policy like this:
Content-Security-Policy: "default-src 'self' https: ; script-src 'self' ...
Nova will load its login page, but shows a blank grey page after login, and throws these two errors:
[Error] TypeError: undefined is not an object (evaluating 'h.app.$loading.start')
(anonymous function) — app.js:1:37137
(anonymous function) — vendor.js:1:1758947
Gt — vendor.js:1:1758388
promiseReactionJob
It (vendor.js:1:1758278)
jt (vendor.js:1:1758191)
Yt (vendor.js:1:1757843)
(anonymous function) (vendor.js:1:1758962)
Gt (vendor.js:1:1758388)
promiseReactionJob
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'h.app.$loading.finish')
dispatchException (app.js:1:637192)
(anonymous function) (app.js:1:639360)
o (app.js:1:795247)
(anonymous function) (app.js:1:795344)
promiseReactionJob
The error can be avoided by allowing unsafe-eval in script-src, however, allowing that along with unsafe-inline means you're losing all the XSS defences that CSP provides.
I know that this isn't a simple thing to work around because removing unsafe-inline requires moving all JS out to external files, and unsafe-eval can be tricky to avoid, but since Nova is an admin panel, I think it would be good if it avoided preventing the use of good security measures that would otherwise be usable - XSS in admin interfaces is a common attack vector.
Steps To Reproduce
- Use any Nova installation (requires no alterations to the app).
- Configure a strict CSP in nginx:
add_header Content-Security-Policy "default-src 'self' https: ; script-src 'self' 'unsafe-inline' ; style-src 'self' 'unsafe-inline' fonts.googleapis.com ;
img-src * 'self' blob: data: ; font-src 'self' fonts.gstatic.com ; media-src * 'self' ; form-action 'self' ; frame-ancestors 'self' ; base-uri 'self' ;";
- Reload nginx then try to log in to Nova; it should succeed, but redirect to a blank grey page.
- Add
unsafe-evalto thescript-srcsection, so it becomesscript-src 'self' 'unsafe-inline' 'unsafe-eval' ;. - Reload nginx, observe that login now works and the dashboard is displayed correctly.
It would be good to avoid using google fonts too - they are typically regarded as trackers, and it's fiddly to have to enable them only for Nova. I know they're pretty, but falling back to local static or standard web fonts would be preferable for an admin interface.