diff --git a/CHANGELOG.md b/CHANGELOG.md index 5923feb..37cbeb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Remove the no longer needed escape_once helper call in node.haml, relying on HAML's global escape_html instead (@robertcheramy) - Update web libraries to the latest versions (@robertcheramy) - Encode JSON output with the standard library instead of Sinatra's json helper (@robertcheramy) +- Set HAML's `attr_quote` explicitly to `"` for stable output across HAML versions (@robertcheramy) ### Fixed - Fix XSS vulnerability (CWE-79) by enabling HAML's escape_html globally; user-controlled values in node names, group names, model names, and URL parameters are now HTML-escaped in all templates (@mattimustang) diff --git a/lib/oxidized/web/webapp.rb b/lib/oxidized/web/webapp.rb index edaa77f..c3bc1e0 100644 --- a/lib/oxidized/web/webapp.rb +++ b/lib/oxidized/web/webapp.rb @@ -10,7 +10,10 @@ module API class WebApp < Sinatra::Base helpers Sinatra::UrlForHelper set :public_folder, proc { File.join(root, 'public') } - set :haml, { escape_html: true } + # attr_quote: use double quotes for HTML attributes. Set explicitly so the + # output is stable across Haml versions. Haml 7.3.0 changed the default + # from "'" to '"' (haml/haml#1188); older versions still default to "'". + set :haml, { escape_html: true, attr_quote: '"' } get '/' do redirect url_for('/nodes') diff --git a/oxidized-web.gemspec b/oxidized-web.gemspec index 20d2652..ce3e1f9 100644 --- a/oxidized-web.gemspec +++ b/oxidized-web.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |s| s.add_dependency 'emk-sinatra-url-for', '~> 0.2' # HAML 7.0.0 changed default attr_quote from ' to ". # Updating needs the unit tests to be fixed. - s.add_dependency 'haml', '>= 6', '<7' + s.add_dependency 'haml', '>= 6', '< 8' s.add_dependency 'htmlentities', '~> 4.3' s.add_dependency 'json', '~> 2.3' # Only depend on a minimal version of Oxidized so we don't need to diff --git a/spec/web/node/version_spec.rb b/spec/web/node/version_spec.rb index 87b1852..9dcc24b 100644 --- a/spec/web/node/version_spec.rb +++ b/spec/web/node/version_spec.rb @@ -27,26 +27,26 @@ def app get '/node/version?node_full=sw5' _(last_response.ok?).must_equal true _(last_response.body.include?( - "