CVE-2011-1589 (published 2011-04-29T22:55Z)

Directory traversal vulnerability in Path.pm in Mojolicious before 1.16 allows remote attackers to read arbitrary files via a %2f..%2f (encoded slash dot dot slash) in a URI.

Severity: MEDIUM
CVSS v2 base score: 5.0 (AV:N/AC:L/Au:N/C:P/I:N/A:N)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/kraih/mojo
commit_details: repo_url: https://github.com/kraih/mojo
author: Sebastian Riedel
author_date: 2011-04-15 10:45:23+02:00
msg: fixed critical security issue that can expose files on your system and prepared emergency release
repository: repo_url: https://github.com/kraih/mojo
repo_name: mojolicious/mojo
description: :sparkles: Mojolicious - Perl real-time web framework
repo_language: Perl
owner: kraih
file_changes: filename: Changes
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,6 @@
 This file documents the revision history for Perl extension Mojolicious.
 
-1.16 2011-03-19 00:00:00
+1.17 2011-04-15 00:00:00
         - Deprecated Mojolicious process method in favor of the on_process
           attribute.
         - Added Failraptor.
@@ -29,6 +29,10 @@ This file documents the revision history for Perl extension Mojolicious.
         - Fixed small perldoc browser bug. (kberov)
         - Fixed cookbook recipe. (moritz)
 
+1.16 2011-04-15 00:00:00
+        - Emergency release for a critical security issue that can expose
+          files on your system, everybody should update!
+
 1.15 2011-03-18 00:00:00
         - Changed default log level in "production" mode from "error" to
           "info".

programming_language: Markdown
filename: Path.pm
change_type: ModificationType.MODIFY
diff: @@ -80,6 +80,9 @@ sub parse {
   $path =~ /^\// ? $self->leading_slash(1)  : $self->leading_slash(0);
   $path =~ /\/$/ ? $self->trailing_slash(1) : $self->trailing_slash(0);
 
+  # Unescape
+  url_unescape $path;
+
   # Parse
   my @parts;
   for my $part (split '/', $path) {
@@ -91,7 +94,6 @@ sub parse {
     $part = '' unless defined $part;
 
     # Store
-    url_unescape $part;
     push @parts, $part;
   }
 

programming_language: Perl
filename: Mojolicious.pm
change_type: ModificationType.MODIFY
diff: @@ -42,7 +42,7 @@ has static   => sub { Mojolicious::Static->new };
 has types    => sub { Mojolicious::Types->new };
 
 our $CODENAME = 'Smiling Cat Face With Heart-Shaped Eyes';
-our $VERSION  = '1.16';
+our $VERSION  = '1.17';
 
 # "These old doomsday devices are dangerously unstable.
 #  I'll rest easier not knowing where they are."

programming_language: Perl
filename: path.t
change_type: ModificationType.MODIFY
diff: @@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 11;
 
 # "This is the greatest case of false advertising I’ve seen since I sued the
 #  movie 'The Never Ending Story.'"
@@ -12,3 +12,18 @@ use_ok 'Mojo::Path';
 my $path = Mojo::Path->new;
 is $path->parse('/path')->to_string,   '/path',   'right path';
 is $path->parse('/path/0')->to_string, '/path/0', 'right path';
+
+# Canonicalizing
+$path = Mojo::Path->new(
+  '/%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd');
+is "$path", '/../../../../../../../../../../etc/passwd', 'rigth result';
+is $path->parts->[0], '..', 'right part';
+is $path->canonicalize, '/../../../../../../../../../../etc/passwd',
+  'rigth result';
+is $path->parts->[0], '..', 'right part';
+$path = Mojo::Path->new(
+  '/%2ftest%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd');
+is "$path", '/test/../../../../../../../../../etc/passwd', 'rigth result';
+is $path->parts->[0], 'test', 'right part';
+is $path->canonicalize, '/../../../../../../../../etc/passwd', 'rigth result';
+is $path->parts->[0], '..', 'right part';

programming_language: Perl