[前][次][番号順一覧][スレッド一覧]

ruby-changes:26953

From: charliesome <ko1@a...>
Date: Sat, 2 Feb 2013 00:46:20 +0900 (JST)
Subject: [ruby-changes:26953] charliesome:r39005 (trunk): * marshal.c: add security considerations to marshal overview, refer to

charliesome	2013-02-02 00:46:10 +0900 (Sat, 02 Feb 2013)

  New Revision: 39005

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39005

  Log:
    * marshal.c: add security considerations to marshal overview, refer to
      overview from Marshal.load documentation [#7759]

  Modified files:
    trunk/ChangeLog
    trunk/marshal.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 39004)
+++ ChangeLog	(revision 39005)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Feb  2 00:46:00 2013  Charlie Somerville  <charlie@c...>
+
+	* marshal.c: add security considerations to marshal overview, refer to
+	  overview from Marshal.load documentation [#7759]
+
 Fri Feb  1 23:04:00 2013  Charlie Somerville  <charlie@c...>
 
 	* array.c (rb_ary_dup): make returned array the same class as the original
Index: marshal.c
===================================================================
--- marshal.c	(revision 39004)
+++ marshal.c	(revision 39005)
@@ -1895,10 +1895,8 @@ clear_load_arg(struct load_arg *arg) https://github.com/ruby/ruby/blob/trunk/marshal.c#L1895
  * to_str. If proc is specified, it will be passed each object as it
  * is deserialized.
  *
- * Never pass untrusted data (including user input) to this method. Doing
- * so is highly dangerous and can lead to remote code execution. If you
- * need to deserialize untrusted data, use JSON and only rely on simple
- * 'primitive' types, such as String, Array, Hash, etc.
+ * Never pass untrusted data (including user supplied input) to this method.
+ * Please see the overview for further details.
  */
 static VALUE
 marshal_load(int argc, VALUE *argv)
@@ -1993,6 +1991,21 @@ marshal_load(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/marshal.c#L1991
  * precedence over _dump if both are defined.  marshal_dump may result in
  * smaller Marshal strings.
  *
+ * == Security considerations
+ *
+ * By design, Marshal.load can deserialize almost any class loaded into the
+ * Ruby process. In many cases this can lead to remote code execution if the
+ * Marshal data is loaded from an untrusted source.
+ *
+ * As a result, Marshal.load is not suitable as a general purpose serialization
+ * format and you should never unmarshal user supplied input or other untrusted
+ * data.
+ *
+ * If you need to deserialize untrusted data, use JSON or another serialization
+ * format that is only able to load simple, 'primitive' types such as String,
+ * Array, Hash, etc. Never allow user input to specify arbitrary types to
+ * deserialize into.
+ *
  * == marshal_dump and marshal_load
  *
  * When dumping an object the method marshal_dump will be called.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]