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. cache returns a cached fragment with the escaping it was stored with, on a hit as on the first render (#2580).
  • SafeBuffer keeps escaping. Padrino::SafeBuffer escapes text given to insert, []= and replace, and is no longer HTML-safe after setbyte, bytesplice or append_as_bytes (#2580).
  • js_escape_html escapes 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_to and form_tag. 'href' in link_to and mail_to, and 'action', 'method' and 'multipart' in form_tag and button_to, work like Symbol keys (#2580).
  • host: routes load again. A route given host: no longer raises NoMethodError when the app loads, and agent: with a String works (#2546).

Upgrading from 0.18.5

  1. In your Gemfile, change gem 'padrino', '~> 0.18.5' (or '0.18.5') to gem 'padrino', '~> 0.18.6', then run bundle update padrino (or, if it lists the padrino-* gems, set each to ~> 0.18.6 and update them by name).
  2. Clear your fragment caches if they may hold text that visitors wrote.
  3. 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_prefix and delete_suffix return plain strings, which views escape when output.
    • A String 'href' or 'action' key passed to link_to or form_tag now 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.

comments powered by Disqus

Type to search the guides.