Ruby2Shell: nothing to hit, but update Ruby
Ruby has shipped fixes for a critical flaw known as Ruby2Shell: a heap buffer overflow of a single byte, triggered when a program changes the case of a string in one of the old single-byte encodings, ISO-8859-1 or Windows-1252. UTF-8 strings are not affected. An application is in danger only if it runs a vulnerable Ruby and changes the case of untrusted text in those encodings, which is why Rails and classic Sinatra apps were named first. The fixed releases are 3.3.14, 3.4.13 and 4.0.10; Ruby 3.2 and older get no fix. The researchers who found it, Veria Labs, plan to publish an exploit after 25 November.
A site built with ./blog.sh has nothing for it to hit. Ruby is not running on the web: what goes out is static HTML the build wrote earlier. The preview server listens on 127.0.0.1 only. The phone and desktop apps reach the engine over SSH with a key and a forced command, so only somebody who is already logged in gets that far, and what they send is treated as UTF-8. The importers, the one place where the engine meets old encodings, convert them to UTF-8 before they do anything with the text. We read through those places; we did not audit every call that changes case in the code.
Update Ruby anyway, on every machine where the engine runs. It protects everything else Ruby does there, and it takes a few minutes:
- Run
ruby -v. If it says 3.3.13 or older 3.3, 3.4.12 or older 3.4, or anything older than 3.3, it needs the update. - Install 3.3.14, 3.4.13 or 4.0.10 or newer with whatever put Ruby there: Homebrew, your distribution, rbenv or asdf, or a rebuilt container image.
- On 3.2 or older, move to a supported line. There is no backport coming.
- Check again with
ruby -von each machine, the server included. The engine itself still needs only Ruby 2.7, so it will not complain about an old one; that is on you for now.
And if you run a Rails application anywhere, Mastodon for one, update that one first.
Comments