Skip to content

Commit 9370eae

Browse files
author
Reini Urban
committed
Storable: document, reformat and fix for DEBUGGING
fix t/blessed.t: we do try to auto-load modules for bless, and avoid regressions. One security flag BLESS_OK is enough to disable this. fix all DEBUGGING 64bit warnings, with TRACEME. add asserts from blead perl 5.24. update hints/linux.pl for the known gcc -O3 bug. Not repro with gcc 4 nor clang. fix documentation: SECURITY WARNING, Large data on 64-bit platforms
1 parent 790f6bf commit 9370eae

File tree

4 files changed

+483
-415
lines changed

4 files changed

+483
-415
lines changed

Storable.pm

+54-22
Original file line numberDiff line numberDiff line change
@@ -1056,31 +1056,33 @@ compartment:
10561056
B<Do not accept Storable documents from untrusted sources!>
10571057
10581058
Some features of Storable can lead to security vulnerabilities if you
1059-
accept Storable documents from untrusted sources. Most obviously, the
1060-
optional (off by default) CODE reference serialization feature allows
1061-
transfer of code to the deserializing process. Furthermore, any
1062-
serialized object will cause Storable to helpfully load the module
1063-
corresponding to the class of the object in the deserializing module.
1064-
For manipulated module names, this can load almost arbitrary code.
1065-
Finally, the deserialized object's destructors will be invoked when
1066-
the objects get destroyed in the deserializing process. Maliciously
1067-
crafted Storable documents may put such objects in the value of
1068-
a hash key that is overridden by another key/value pair in the
1069-
same hash, thus causing immediate destructor execution.
1070-
1071-
In a future version of Storable, we intend to provide options to disable
1072-
loading modules for classes and to disable deserializing objects
1073-
altogether. I<Nonetheless, Storable deserializing documents from
1074-
untrusted sources is expected to have other, yet undiscovered,
1075-
security concerns such as allowing an attacker to cause the deserializer
1076-
to crash hard.>
1077-
1078-
B<Therefore, let me repeat: Do not accept Storable documents from
1079-
untrusted sources!>
1059+
accept Storable documents from untrusted sources with the default
1060+
flags. Most obviously, the optional (off by default) CODE reference
1061+
serialization feature allows transfer of code to the deserializing
1062+
process. Furthermore, any serialized object will cause Storable to
1063+
helpfully load the module corresponding to the class of the object in
1064+
the deserializing module. For manipulated module names, this can load
1065+
almost arbitrary code. Finally, the deserialized object's destructors
1066+
will be invoked when the objects get destroyed in the deserializing
1067+
process. Maliciously crafted Storable documents may put such objects
1068+
in the value of a hash key that is overridden by another key/value
1069+
pair in the same hash, thus causing immediate destructor execution.
1070+
1071+
To disable blessing objects while thawing/retrieving remove the flag
1072+
BLESS_OK = 2 from C<$Storable::flags> or set the 2nd argument for
1073+
thaw/retrieve to 0.
1074+
1075+
To disable tieing data while thawing/retrieving remove the flag TIE_OK
1076+
= 4 from C<$Storable::flags> or set the 2nd argument for thaw/retrieve
1077+
to 0.
1078+
1079+
With the default setting of $Storable::flags = 6, creating or destroying
1080+
random objects, even renamed objects can be controlled by an attacker.
1081+
See CVE-2015-1592 and its metasploit module.
10801082
10811083
If your application requires accepting data from untrusted sources, you
10821084
are best off with a less powerful and more-likely safe serialization format
1083-
and implementation. If your data is sufficiently simple, JSON is a good
1085+
and implementation. If your data is sufficiently simple, JSON is the best
10841086
choice and offers maximum interoperability.
10851087
10861088
=head1 WARNING
@@ -1152,6 +1154,34 @@ to string or floating point. In other words values that had been generated
11521154
by integer operations such as logic ops and then not used in any string or
11531155
arithmetic context before storing.
11541156
1157+
=head2 Large data on 64-bit platforms
1158+
1159+
Storable's current data format is incapable of representing lengths greater
1160+
than fit into a signed 32-bit integer, or about 2 GB. In practice, this
1161+
means that, even with the latest Perl and a 64-bit machine with plenty of
1162+
memory, you cannot store, retrieve, or clone any of the following:
1163+
1164+
=over 4
1165+
1166+
=item *
1167+
1168+
A string containing 2**31 or more bytes (including as an element of an array, or
1169+
a key or value in a hash)
1170+
1171+
=item *
1172+
1173+
An array with 2**31 or more elements
1174+
1175+
=item *
1176+
1177+
A hash with 2**31 or more keys
1178+
1179+
=back
1180+
1181+
Attempting to do so will result in unpredicatable overflow results.
1182+
1183+
This may be fixed in the future.
1184+
11551185
=head2 64 bit data in perl 5.6.0 and 5.6.1
11561186
11571187
This section only applies to you if you have existing data written out
@@ -1226,6 +1256,8 @@ Thank you to (in chronological order):
12261256
Erik Haugan <[email protected]>
12271257
Benjamin A. Holzman <[email protected]>
12281258
Reini Urban <[email protected]>
1259+
Todd Rinaldo <[email protected]>
1260+
Aaron Crane <[email protected]>
12291261
12301262
for their bug reports, suggestions and contributions.
12311263

0 commit comments

Comments
 (0)