In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/664f237a84176c09b20b62dbfe64dd736a7ce05e?hp=569ba91fcdabdc53eb4284f860a25273bd7fe4e1>
- Log ----------------------------------------------------------------- commit 664f237a84176c09b20b62dbfe64dd736a7ce05e Author: Steffen Mueller <[email protected]> Date: Fri Nov 30 23:03:09 2012 -0500 add a note about security concerns in Storable Storable is not a great way to pass data back and forth across security boundaries. We have discussed the security implications of the auto-loading and auto-blessing behaviors in Storable in the past, both on the perl5-porters mailing list and at various conferences. Somehow, though, these "well-known" probably have never actually been put into the documentation. This patch corrects that. The original version of this patch included a recommendation to use Sereal in its most stringent configuration, but that text was removed for the time being by Ricardo Signes, who hopes to add it back once Sereal has been in public use for just a bit longer. M dist/Storable/ChangeLog M dist/Storable/Storable.pm commit 1735f6f53ca19f99c6e9e39496c486af323ba6a8 Author: Brian Carlson <[email protected]> Date: Wed Nov 28 08:54:33 2012 -0500 Fix misparsing of maketext strings. Case 61251: This commit fixes a misparse of maketext strings that could lead to arbitrary code execution. Basically, maketext was compiling bracket notation into functions, but neglected to escape backslashes inside the content or die on fully-qualified method names when generating the code. This change escapes all such backslashes and dies when a method name with a colon or apostrophe is specified. M AUTHORS M dist/Locale-Maketext/lib/Locale/Maketext.pm ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + dist/Locale-Maketext/lib/Locale/Maketext.pm | 24 ++++++------------ dist/Storable/ChangeLog | 5 ++++ dist/Storable/Storable.pm | 34 ++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/AUTHORS b/AUTHORS index 70734b0..009dea0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -154,6 +154,7 @@ Breno G. de Oliveira <[email protected]> Brent Dax <[email protected]> Brooks D Boyd Brian Callaghan <[email protected]> +Brian Carlson <[email protected]> Brian Clarke <[email protected]> brian d foy <[email protected]> Brian Fraser <[email protected]> diff --git a/dist/Locale-Maketext/lib/Locale/Maketext.pm b/dist/Locale-Maketext/lib/Locale/Maketext.pm index 4822027..63e5fba 100644 --- a/dist/Locale-Maketext/lib/Locale/Maketext.pm +++ b/dist/Locale-Maketext/lib/Locale/Maketext.pm @@ -625,21 +625,9 @@ sub _compile { # 0-length method name means to just interpolate: push @code, ' ('; } - elsif($m =~ /^\w+(?:\:\:\w+)*$/s - and $m !~ m/(?:^|\:)\d/s - # exclude starting a (sub)package or symbol with a digit + elsif($m =~ /^\w+$/s + # exclude anything fancy, especially fully-qualified module names ) { - # Yes, it even supports the demented (and undocumented?) - # $obj->Foo::bar(...) syntax. - $target->_die_pointing( - $string_to_compile, q{Can't use "SUPER::" in a bracket-group method}, - 2 + length($c[-1]) - ) - if $m =~ m/^SUPER::/s; - # Because for SUPER:: to work, we'd have to compile this into - # the right package, and that seems just not worth the bother, - # unless someone convinces me otherwise. - push @code, ' $_[0]->' . $m . '('; } else { @@ -693,7 +681,9 @@ sub _compile { elsif(substr($1,0,1) ne '~') { # it's stuff not containing "~" or "[" or "]" # i.e., a literal blob - $c[-1] .= $1; + my $text = $1; + $text =~ s/\\/\\\\/g; + $c[-1] .= $text; } elsif($1 eq '~~') { # "~~" @@ -731,7 +721,9 @@ sub _compile { else { # It's a "~X" where X is not a special character. # Consider it a literal ~ and X. - $c[-1] .= $1; + my $text = $1; + $text =~ s/\\/\\\\/g; + $c[-1] .= $text; } } } diff --git a/dist/Storable/ChangeLog b/dist/Storable/ChangeLog index 351159c..31e1b0c 100644 --- a/dist/Storable/ChangeLog +++ b/dist/Storable/ChangeLog @@ -1,3 +1,8 @@ +? + Version 2.40 + + Security warnings section added + Tue 11 Sep 06:51:11 IST 2012 Abhijit Menon-Sen <[email protected]> Version 2.39 diff --git a/dist/Storable/Storable.pm b/dist/Storable/Storable.pm index 668bf44..7d53454 100644 --- a/dist/Storable/Storable.pm +++ b/dist/Storable/Storable.pm @@ -21,7 +21,7 @@ package Storable; @ISA = qw(Exporter); use vars qw($canonical $forgive_me $VERSION); -$VERSION = '2.39'; +$VERSION = '2.40'; BEGIN { if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) { @@ -1019,6 +1019,38 @@ compartment: =for example_testing is( $code->(), 42 ); +=head1 SECURITY WARNING + +B<Do not accept Storable documents from untrusted sources!> + +Some features of Storable can lead to security vulnerabilities if you +accept Storable documents from untrusted sources. Most obviously, the +optional (off by default) CODE reference serialization feature allows +transfer of code to the deserializing process. Furthermore, any +serialized object will cause Storable to helpfully load the module +corresponding to the class of the object in the deserializing module. +For manipulated module names, this can load almost arbitrary code. +Finally, the deserialized object's destructors will be invoked when +the objects get destroyed in the deserializing process. Maliciously +crafted Storable documents may put such objects in the value of +a hash key that is overridden by another key/value pair in the +same hash, thus causing immediate destructor execution. + +In a future version of Storable, we intend to provide options to disable +loading modules for classes and to disable deserializing objects +altogether. I<Nonetheless, Storable deserializing documents from +untrusted sources is expected to have other, yet undiscovered, +security concerns such as allowing an attacker to cause the deserializer +to crash hard.> + +B<Therefore, let me repeat: Do not accept Storable documents from +untrusted sources!> + +If your application requires accepting data from untrusted sources, you +are best off with a less powerful and more-likely safe serialization format +and implementation. If your data is sufficently simple, JSON is a good +choice and offers maximum interoperability. + =head1 WARNING If you're using references as keys within your hash tables, you're bound -- Perl5 Master Repository
