path: root/doc
diff options
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-04 16:24:16 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-04 16:24:16 +0000
commit229bfa7bb18ab420f3fd24960330a0caec821008 (patch)
tree502e98fb7a96ff214174a62dd1ad94653cab2e99 /doc
parent99eaebcea3ae30f14da659cfd2d5b3b00ff9d351 (diff)
* doc/security.rdoc: [DOC] update symbols section [ci-skip]
git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'doc')
1 files changed, 16 insertions, 6 deletions
diff --git a/doc/security.rdoc b/doc/security.rdoc
index ff2da46..5257aba 100644
--- a/doc/security.rdoc
+++ b/doc/security.rdoc
@@ -66,16 +66,26 @@ method, variable and constant names. The reason for this is that symbols are
simply integers with names attached to them, so they are faster to look up in
-Be careful with passing user input to methods such as +send+,
-+instance_variable_get+ or +_set+, +const_get+ or +_set+, etc.
-as these methods will convert string parameters to immortal symbols internally.
-This means that the memory used by the symbols are never freed. This could
+Starting in version 2.2, most symbols can be garbage collected; these are
+called <i>mortal</i> symbols. Most symbols you create (e.g. by calling
++to_sym+) are mortal.
+<i>Immortal</i> symbols on the other hand will never be garbage collected.
+They are created when modifying code:
+* defining a method (e.g. with +define_method+),
+* setting an instance variable (e.g. with +instance_variable_set+),
+* creating a variable or constant (e.g. with +const_set+)
+Also, C extensions that have not been updated and are still calling `ID2SYM`
+will create immortal symbols.
+Don't create immortal symbols from user inputs. Otherwise, this would
allow a user to mount a denial of service attack against your application by
flooding it with unique strings, which will cause memory to grow indefinitely
until the Ruby process is killed or causes the system to slow to a halt.
-The workaround to this is simple - don't call reflection/metaprogramming
-methods with user input.
+While it might not be a good idea to call these with user inputs, methods that
+used to be vulnerable such as +to_sym+, +send+, +respond_to?+,
++method+, +instance_variable_get+, +const_get+, etc. are no longer a threat.
== Regular expressions