aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-01-18 13:51:02 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-01-22 15:02:46 -0800
commit4642d68d8021893c69bfd16ed6e926ae03a6d777 (patch)
treebe212b3810e264ca10cdf015d576773fa27f27ed /activemodel/lib
parentb7758b40fc035a47f6843158155606d455314c42 (diff)
downloadrails-4642d68d8021893c69bfd16ed6e926ae03a6d777.tar.gz
rails-4642d68d8021893c69bfd16ed6e926ae03a6d777.tar.bz2
rails-4642d68d8021893c69bfd16ed6e926ae03a6d777.zip
Eliminate instance level writers for class accessors
Instance level writers can have an impact on how the Active Model / Record objects are saved. Specifically, they can be used to bypass validations. This is a problem if mass assignment protection is disabled and specific attributes are passed to the constructor. CVE-2016-0753
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/serializers/json.rb2
-rw-r--r--activemodel/lib/active_model/validations.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/serializers/json.rb b/activemodel/lib/active_model/serializers/json.rb
index b66dbf1afe..b64a8299e6 100644
--- a/activemodel/lib/active_model/serializers/json.rb
+++ b/activemodel/lib/active_model/serializers/json.rb
@@ -10,7 +10,7 @@ module ActiveModel
included do
extend ActiveModel::Naming
- class_attribute :include_root_in_json
+ class_attribute :include_root_in_json, instance_writer: false
self.include_root_in_json = false
end
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index f23c920d87..8159b9b1d3 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -47,9 +47,10 @@ module ActiveModel
include HelperMethods
attr_accessor :validation_context
+ private :validation_context=
define_callbacks :validate, scope: :name
- class_attribute :_validators
+ class_attribute :_validators, instance_writer: false
self._validators = Hash.new { |h,k| h[k] = [] }
end