fix(security): harden CSP policy and hide nginx server tokens - #748
Conversation
- Remove 'unsafe-inline' and 'unsafe-eval' from script-src directive - Restrict connect-src to 'self' only - Disable nginx server_tokens to hide version information Signed-off-by: wurongjie <wurongjie@uniontech.com>
0614022 to
b807fb3
Compare
|
The direction is right (dropping
If you've already run the built frontend through login + notifications + skill browse with the console open and it's clean, say so in the PR and this is good to go. |
|
We've run through login, notifications, and skill browsing on the built frontend with the console open – no CSP errors and all features work as expected. This has been running stably in our internal production for several days, so it should be good to merge. @FenjuFu |
FenjuFu
left a comment
There was a problem hiding this comment.
Re-reviewed after the production-build smoke evidence. The diff is limited to removing script unsafe-inline and unsafe-eval, restricting connect-src to same-origin, and disabling nginx server tokens. Login, notifications, and skill browsing were exercised without CSP violations, and all remote checks, DCO, and CLA are green.
What
Harden Content Security Policy (CSP) and hide nginx server version information.
Why
CSP Hardening:
'unsafe-inline'and'unsafe-eval'in script-src allow inline scripts and eval(), which can enable XSS attacksws: wss: http://localhost:* https://localhost:*in connect-src allows WebSocket and localhost connections that may not be needed in productionNginx Server Tokens:
Server: nginx/x.x.x)How
'unsafe-inline' 'unsafe-eval'from script-src directive'self'onlyserver_tokens off;to nginx configurationTesting
Impact