aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/CHANGELOG.md
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2014-07-25 12:00:14 -0400
committerPrem Sichanugrist <s@sikac.hu>2014-08-18 20:42:45 -0400
commit5109740c6be67047df56feb164012c3a1a3c619b (patch)
treec0cf051b99bc489055c747d7d143fd53cac7e9d3 /actionpack/CHANGELOG.md
parentdfeeecd2f3bde70f22174843ccfc594610b4eebc (diff)
downloadrails-5109740c6be67047df56feb164012c3a1a3c619b.tar.gz
rails-5109740c6be67047df56feb164012c3a1a3c619b.tar.bz2
rails-5109740c6be67047df56feb164012c3a1a3c619b.zip
Make `AC::Params#to_h` return Hash with safe keys
`ActionController::Parameters#to_h` now returns a `Hash` with unpermitted keys removed. This change is to reflect on a security concern where some method performed on an `ActionController::Parameters` may yield a `Hash` object which does not maintain `permitted?` status. If you would like to get a `Hash` with all the keys intact, duplicate and mark it as permitted before calling `#to_h`. params = ActionController::Parameters.new(name: 'Senjougahara Hitagi') params.to_h # => {} unsafe_params = params.dup.permit! unsafe_params.to_h # => {"name"=>"Senjougahara Hitagi"} safe_params = params.permit(:name) safe_params.to_h # => {"name"=>"Senjougahara Hitagi"} This change is consider a stopgap as we cannot chage the code to stop `ActionController::Parameters` to inherit from `HashWithIndifferentAccess` in the next minor release. Also, adding a CHANGELOG entry to mention that `ActionController::Parameters` will not inheriting from `HashWithIndifferentAccess` in the next major version.
Diffstat (limited to 'actionpack/CHANGELOG.md')
-rw-r--r--actionpack/CHANGELOG.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 1c84bac3ff..e2731d0ee5 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,38 @@
+* `ActionController::Parameters` will stop inheriting from `Hash` and
+ `HashWithIndifferentAccess` in the next major release. If you use any method
+ that is not available on `ActionController::Parameters` you should consider
+ calling `#to_h` to convert it to a `Hash` first before calling that method.
+
+ *Prem Sichanugrist*
+
+* `ActionController::Parameters#to_h` now returns a `Hash` with unpermitted
+ keys removed. This change is to reflect on a security concern where some
+ method performed on an `ActionController::Parameters` may yield a `Hash`
+ object which does not maintain `permitted?` status. If you would like to
+ get a `Hash` with all the keys intact, duplicate and mark it as permitted
+ before calling `#to_h`.
+
+ params = ActionController::Parameters.new({
+ name: 'Senjougahara Hitagi',
+ oddity: 'Heavy stone crab'
+ })
+ params.to_h
+ # => {}
+
+ unsafe_params = params.dup.permit!
+ unsafe_params.to_h
+ # => {"name"=>"Senjougahara Hitagi", "oddity"=>"Heavy stone crab"}
+
+ safe_params = params.permit(:name)
+ safe_params.to_h
+ # => {"name"=>"Senjougahara Hitagi"}
+
+ This change is consider a stopgap as we cannot change the code to stop
+ `ActionController::Parameters` to inherit from `HashWithIndifferentAccess`
+ in the next minor release.
+
+ *Prem Sichanugrist*
+
* Deprecated TagAssertions.
*Kasper Timm Hansen*