There is a possible escalation to RCE when using YAML serialized columns in
Active Record. This vulnerability has been assigned the CVE identifier
Versions Affected: All.
Not affected: None
Fixed Versions: 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11
When serialized columns that use YAML (the default) are deserialized, Rails
uses `YAML.unsafe_load` to convert the YAML data in to Ruby objects. If an
attacker can manipulate data in the database (via means like SQL injection),
then it may be possible for the attacker to escalate to an RCE.
Impacted Active Record models will look something like this:
class User < ApplicationRecord
serialize :options # Vulnerable: Uses YAML for serialization
serialize :values, Array # Vulnerable: Uses YAML for serialization
serialize :values, JSON # Not vulnerable
All users running an affected release should either upgrade or use one of the
The FIXED releases are available at the normal locations.
The released versions change the default YAML deserializer to use
`YAML.safe_load`, which prevents deserialization of possibly dangerous
objects. This may introduce backwards compatibility issues with existing
In order to cope with that situation, the released version also contains two
new Active Record configuration options. The configuration options are as
When set to true, this configuration option tells Rails to use the old
"unsafe" YAML loading strategy, maintaining the existing behavior but leaving
the possible escalation vulnerability in place. Setting this option to true
is *not* recommended, but can aid in upgrading.
The "safe YAML" loading method does not allow all classes to be deserialized
by default. This option allows you to specify classes deemed "safe" in your
application. For example, if your application uses Symbol and Time in
serialized data, you can add Symbol and Time to the allowed list as follows:
config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
There are no feasible workarounds for this issue, but other coders (such as
JSON) are not impacted.
To aid users who aren't able to upgrade immediately we have provided patches for
the two supported release series. They are in git-am format and consist of a
* 7-0-yaml_safe_load.patch - Patch for 7.0 series
* 6-1-yaml_safe_load.patch - Patch for 6.1 series
* 6-0-yaml_safe_load.patch - Patch for 6.0 series
* 5-2-yaml_safe_load.patch - Patch for 5.2 series
Please note that only the 7.0.Z and 6.1.Z are supported at present. 6.0.Z is
supported only for severe security issues. Users of earlier unsupported
releases are advised to upgrade as soon as possible as we cannot guarantee the
continued availability of security fixes for unsupported releases.
A patch and release are available for 5.2.Z, though it is no longer supported.
Thanks to @elebow for reporting this! https://hackerone.com/elebow