@@ -13,52 +13,99 @@ advisory:
13
13
date : 2016-01-25
14
14
url : https://groups.google.com/forum/#!topic/rubyonrails-security/cawsWcQ6c8g
15
15
title : Nested attributes rejection proc bypass in Active Record
16
- description : " There is a vulnerability in how the nested attributes feature in Active
17
- Record \n handles updates in combination with destroy flags when destroying records
18
- is \n disabled. This vulnerability has been assigned the CVE identifier CVE-2015-7577.
19
- \n\n Versions Affected: 3.1.0 and newer \n Not affected: 3.0.x and older
20
- \n Fixed Versions: 5.0.0.beta1.1, 4.2.5.1, 4.1.14.1, 3.2.22.1 \n\n Impact \n ------
21
- \n When using the nested attributes feature in Active Record you can prevent the
22
- \n destruction of associated records by passing the `allow_destroy: false` option
23
- \n to the `accepts_nested_attributes_for` method. However due to a change in the
24
- \n commit [a9b4b5d][1] the `_destroy` flag prevents the `:reject_if` proc from
25
- \n being called because it assumes that the record will be destroyed anyway. \n\n However
26
- this isn't true if `:allow_destroy` is false so this leads to changes \n that would
27
- have been rejected being applied to the record. Attackers could use \n this do
28
- things like set attributes to invalid values and to clear all of the \n attributes
29
- amongst other things. The severity will be dependent on how the \n application
30
- has used this feature. \n\n All users running an affected release should either
31
- upgrade or use one of \n the workarounds immediately. \n\n Releases \n -------- \n The
32
- FIXED releases are available at the normal locations. \n\n Workarounds \n -----------
33
- \n If you can't upgrade, please use the following monkey patch in an initializer
34
- \n that is loaded before your application: \n\n ``` \n $ cat config/initializers/nested_attributes_bypass_fix.rb
35
- \n module ActiveRecord \n module NestedAttributes \n private \n\n def reject_new_record?(association_name,
36
- attributes) \n will_be_destroyed?(association_name, attributes) || call_reject_if(association_name,
37
- attributes) \n end \n\n def call_reject_if(association_name, attributes)
38
- \n return false if will_be_destroyed?(association_name, attributes) \n\n
39
- \ case callback = self.nested_attributes_options[association_name][:reject_if]
40
- \n when Symbol \n method(callback).arity == 0 ? send(callback) : send(callback,
41
- attributes) \n when Proc \n callback.call(attributes) \n end
42
- \n end \n\n def will_be_destroyed?(association_name, attributes) \n allow_destroy?(association_name)
43
- && has_destroy_flag?(attributes) \n end \n\n def allow_destroy?(association_name)
44
- \n self.nested_attributes_options[association_name][:allow_destroy] \n end
45
- \n end \n end \n ``` \n\n Patches \n ------- \n To aid users who aren't able to upgrade
46
- immediately we have provided patches for \n the two supported release series. They
47
- are in git-am format and consist of a \n single changeset. \n\n * 3-2-nested-attributes-reject-if-bypass.patch
48
- - Patch for 3.2 series \n * 4-1-nested-attributes-reject-if-bypass.patch - Patch
49
- for 4.1 series \n * 4-2-nested-attributes-reject-if-bypass.patch - Patch for 4.2
50
- series \n * 5-0-nested-attributes-reject-if-bypass.patch - Patch for 5.0 series
51
- \n\n Please note that only the 4.1.x and 4.2.x series are supported at present.
52
- Users \n of earlier unsupported releases are advised to upgrade as soon as possible
53
- as we \n cannot guarantee the continued availability of security fixes for unsupported
54
- \n releases. \n\n Credits \n ------- \n Thank you to Justin Coyne for reporting the
55
- problem and working with us to fix it. \n\n [1]: https://github.com/rails/rails/commit/a9b4b5da7c216e4464eeb9dbd0a39ea258d64325
56
- \n "
16
+ description : |
17
+ There is a vulnerability in how the nested attributes feature in Active Record
18
+ handles updates in combination with destroy flags when destroying records is
19
+ disabled. This vulnerability has been assigned the CVE identifier CVE-2015-7577.
20
+
21
+ Versions Affected: 3.1.0 and newer
22
+ Not affected: 3.0.x and older
23
+ Fixed Versions: 5.0.0.beta1.1, 4.2.5.1, 4.1.14.1, 3.2.22.1
24
+
25
+ Impact
26
+ ------
27
+ When using the nested attributes feature in Active Record you can prevent the
28
+ destruction of associated records by passing the `allow_destroy: false` option
29
+ to the `accepts_nested_attributes_for` method. However due to a change in the
30
+ commit [a9b4b5d][1] the `_destroy` flag prevents the `:reject_if` proc from
31
+ being called because it assumes that the record will be destroyed anyway.
32
+
33
+ However this isn't true if `:allow_destroy` is false so this leads to changes
34
+ that would have been rejected being applied to the record. Attackers could use
35
+ this do things like set attributes to invalid values and to clear all of the
36
+ attributes amongst other things. The severity will be dependent on how the
37
+ application has used this feature.
38
+
39
+ All users running an affected release should either upgrade or use one of
40
+ the workarounds immediately.
41
+
42
+ Releases
43
+ --------
44
+ The FIXED releases are available at the normal locations.
45
+
46
+ Workarounds
47
+ -----------
48
+ If you can't upgrade, please use the following monkey patch in an initializer
49
+ that is loaded before your application:
50
+
51
+ ```
52
+ $ cat config/initializers/nested_attributes_bypass_fix.rb
53
+ module ActiveRecord
54
+ module NestedAttributes
55
+ private
56
+
57
+ def reject_new_record?(association_name, attributes)
58
+ will_be_destroyed?(association_name, attributes) || call_reject_if(association_name, attributes)
59
+ end
60
+
61
+ def call_reject_if(association_name, attributes)
62
+ return false if will_be_destroyed?(association_name, attributes)
63
+
64
+ case callback = self.nested_attributes_options[association_name][:reject_if]
65
+ when Symbol
66
+ method(callback).arity == 0 ? send(callback) : send(callback, attributes)
67
+ when Proc
68
+ callback.call(attributes)
69
+ end
70
+ end
71
+
72
+ def will_be_destroyed?(association_name, attributes)
73
+ allow_destroy?(association_name) && has_destroy_flag?(attributes)
74
+ end
75
+
76
+ def allow_destroy?(association_name)
77
+ self.nested_attributes_options[association_name][:allow_destroy]
78
+ end
79
+ end
80
+ end
81
+ ```
82
+
83
+ Patches
84
+ -------
85
+ To aid users who aren't able to upgrade immediately we have provided patches for
86
+ the two supported release series. They are in git-am format and consist of a
87
+ single changeset.
88
+
89
+ * 3-2-nested-attributes-reject-if-bypass.patch - Patch for 3.2 series
90
+ * 4-1-nested-attributes-reject-if-bypass.patch - Patch for 4.1 series
91
+ * 4-2-nested-attributes-reject-if-bypass.patch - Patch for 4.2 series
92
+ * 5-0-nested-attributes-reject-if-bypass.patch - Patch for 5.0 series
93
+
94
+ Please note that only the 4.1.x and 4.2.x series are supported at present. Users
95
+ of earlier unsupported releases are advised to upgrade as soon as possible as we
96
+ cannot guarantee the continued availability of security fixes for unsupported
97
+ releases.
98
+
99
+ Credits
100
+ -------
101
+ Thank you to Justin Coyne for reporting the problem and working with us to fix it.
102
+
103
+ [1]: https://github.com/rails/rails/commit/a9b4b5da7c216e4464eeb9dbd0a39ea258d64325
57
104
unaffected_versions :
58
105
- " ~> 3.0.0"
59
106
- " < 3.0.0"
60
107
patched_versions :
61
- - " ~> 5.0.0.beta1.1"
108
+ - " >= 5.0.0.beta1.1"
62
109
- " ~> 4.2.5, >= 4.2.5.1"
63
110
- " ~> 4.1.14, >= 4.1.14.1"
64
111
- " ~> 3.2.22.1"
0 commit comments