Skip to content

Commit

Permalink
Merge pull request #291 from alphagov/forbid-inline-styles
Browse files Browse the repository at this point in the history
Forbid unsafe-inline for style attributes in CSP
  • Loading branch information
kevindew authored Jun 2, 2023
2 parents 1879053 + 65ca334 commit 565d07a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 8.0.0

* BREAKING: Content Security Policy forbids the use of inline style attributes.

# 7.2.1

* Allow prometheus binding to fail with a warning rather than a crash ([#294](https://github.com/alphagov/govuk_app_config/pull/294))
Expand Down
11 changes: 2 additions & 9 deletions lib/govuk_app_config/govuk_content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,10 @@ def self.build_policy(policy)
"www.youtube-nocookie.com"

# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
# Note: we purposely don't include `data:` or `unsafe-eval` because
# Note: we purposely don't include `data:`, `unsafe-inline` or `unsafe-eval` because
# they are security risks, if you need them for a legacy app please only apply them at
# an app level.
policy.style_src :self,
*GOOGLE_STATIC_DOMAINS,
# This allows `style=""` attributes and `<style>` elements.
# As of January 2023 our intentions to remove this were scuppered
# by Govspeak [1] using inline styles on tables. Until that
# is resolved we'll keep unsafe_inline
# [1]: https://github.com/alphagov/govspeak/blob/5642fcc4231f215d1c58ad7feb30ca42fb8cfb91/lib/govspeak/html_sanitizer.rb#L72-L73
:unsafe_inline
policy.style_src :self, *GOOGLE_STATIC_DOMAINS

# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/font-src
# Note: we purposely don't include data here because it produces a security risk.
Expand Down
2 changes: 1 addition & 1 deletion lib/govuk_app_config/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GovukAppConfig
VERSION = "7.2.1".freeze
VERSION = "8.0.0".freeze
end

0 comments on commit 565d07a

Please sign in to comment.