Skip to content

Commit 834a877

Browse files
Heavily restrict CSP
1 parent d601803 commit 834a877

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/better_errors/middleware.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,14 @@ def show_error_page(env, exception=nil)
114114
headers = {
115115
"Content-Type" => "text/#{type}; charset=utf-8",
116116
"Content-Security-Policy" => [
117-
"default-src 'self' https:", # TODO: remove https:?
118-
"font-src 'self' https: data:",
119-
"img-src 'self' https: data:",
120-
"object-src 'none'",
117+
"default-src 'none'",
121118
# Specifying nonce makes a modern browser ignore 'unsafe-inline' which could still be set
122119
# for older browsers without nonce support.
123-
"script-src 'self' https: 'nonce-#{csp_nonce}' 'unsafe-inline'",
120+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
121+
"script-src 'self' 'nonce-#{csp_nonce}' 'unsafe-inline'",
124122
# Inline style is required by the syntax highlighter.
125-
"style-src 'self' https: 'unsafe-inline'",
126-
"connect-src 'self' https:",
123+
"style-src 'self' 'unsafe-inline'",
124+
"connect-src 'self'",
127125
].join('; '),
128126
}
129127

0 commit comments

Comments
 (0)