diff options
author | Robert Speicher <robert@gitlab.com> | 2016-06-22 23:07:18 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-06-22 23:07:18 +0000 |
commit | 33fa50b1047d08b52896b9954f7106080616dd62 (patch) | |
tree | 8259256c056dca42e6c6d789932ee62be208e7f5 | |
parent | cef021917f0fdf0fd3c24c41d6fd9ee1ed79e8d8 (diff) | |
parent | bba1d2de3bc76bf65b4c2ded07e94ab0d7455bfd (diff) | |
download | gitlab-ce-33fa50b1047d08b52896b9954f7106080616dd62.tar.gz |
Merge branch 'sri' into 'master'
Add Subresource Integrity attribute to CSS and JS assets.
This prevents compromised or malicious CDNs from modifying GitLab's assets. The hash provided by Rails is compared to the hash of the asset the browser has downloaded. The browser will refuse to execute/parse the assets if the hashes don't match. SRI is currently implemented in Firefox, Chrome, and Opera.
This doesn't apply to the dynamically-generated per-page JavaScript due to [a bug in sprockets-rails](https://github.com/rails/sprockets-rails/issues/359). Unfortunately until there's a fix available we won't benefit fully from a security perspective.
It's more secure. More information is available in #18230 and on MDN:
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
Fixes #18230
See merge request !4808
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/views/layouts/_head.html.haml | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index 7179cd13e11..76d9712ce9f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. v 8.10.0 (unreleased) - Wrap code blocks on Activies and Todos page. !4783 (winniehell) - Fix MR-auto-close text added to description. !4836 + - Implement Subresource Integrity for CSS and JavaScript assets. This prevents malicious assets from loading in the case of a CDN compromise. v 8.9.0 - Fix builds API response not including commit data diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index e0ed657919e..d5965a6ec99 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -25,11 +25,14 @@ = favicon_link_tag 'favicon.ico' - = stylesheet_link_tag "application", media: "all" - = stylesheet_link_tag "print", media: "print" + = stylesheet_link_tag "application", media: "all", integrity: true + = stylesheet_link_tag "print", media: "print", integrity: true - = javascript_include_tag "application" + = javascript_include_tag "application", integrity: true + -# FIXME: SRI doesn't apply to the dynamically-generated per-page + -# JavaScript due to a bug in sprockets-rails. + -# See https://github.com/rails/sprockets-rails/issues/359 - if page_specific_javascripts = javascript_include_tag page_specific_javascripts, {"data-turbolinks-track" => true} |