Padrino 0.18.6 release
Padrino 0.18.6 is a security release for 0.18.x. Fragment caching marked every cached fragment as HTML-safe on a cache hit, so a block that returns plain text, such as <%= cache("bio_#{user.id}") { user.bio } %>, was escaped the first time it rendered and written into the page unescaped from then on. Everyone on 0.18.x who caches fragments containing text that visitors can influence should upgrade. The advisory, GHSA-265j-4jw4-q597 (padrino-cache), has the details.
Changes
- Fragment caching keeps escaping.
cachereturns a cached fragment with the escaping it was stored with, on a hit as on the first render (#2580). - SafeBuffer keeps escaping.
Padrino::SafeBufferescapes text given toinsert,[]=andreplace, and is no longer HTML-safe aftersetbyte,bytespliceorappend_as_bytes(#2580). js_escape_htmlescapes more. It also escapes backticks and dollar signs, and line and paragraph separators in UTF-8 strings, so its output is safe inside JavaScript template literals too (#2580).- String option keys in
link_toandform_tag.'href'inlink_toandmail_to, and'action','method'and'multipart'inform_tagandbutton_to, work like Symbol keys (#2580). host:routes load again. A route givenhost:no longer raisesNoMethodErrorwhen the app loads, andagent:with a String works (#2546).
Upgrading from 0.18.5
- In your Gemfile, change
gem 'padrino', '~> 0.18.5'(or'0.18.5') togem 'padrino', '~> 0.18.6', then runbundle update padrino(or, if it lists thepadrino-*gems, set each to~> 0.18.6and update them by name). - Clear your fragment caches if they may hold text that visitors wrote.
- Check these, as listed in the changelog:
- A cache store that doesn't keep the string's class (a YAML or JSON serializer) now escapes cached HTML on a hit. The default stores use Marshal and are unaffected; with another store, use one that serializes with Marshal.
Padrino::SafeBuffer#encode,scrub,unicode_normalize,delete_prefixanddelete_suffixreturn plain strings, which views escape when output.- A String
'href'or'action'key passed tolink_toorform_tagnow replaces the URL argument, as a Symbol key does.
Nothing else changes: Ruby 2.7.8 or later, Sinatra 4 and Rack 3 are still required.