sinatra 0.9.1 → 0.9.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.9.1.1 / 2009-03-09
2
+
3
+ * Fix directory traversal vulnerability in default static files
4
+ route. See [#177] for more info.
5
+
1
6
  = 0.9.1 / 2009-03-01
2
7
 
3
8
  * Sinatra now runs under Ruby 1.9.1 [#61]
@@ -5,7 +5,7 @@ require 'rack'
5
5
  require 'rack/builder'
6
6
 
7
7
  module Sinatra
8
- VERSION = '0.9.1'
8
+ VERSION = '0.9.1.1'
9
9
 
10
10
  # The request object. See Rack::Request for more info:
11
11
  # http://rack.rubyforge.org/doc/classes/Rack/Request.html
@@ -884,7 +884,9 @@ module Sinatra
884
884
  # static files route
885
885
  get(/.*[^\/]$/) do
886
886
  pass unless options.static? && options.public?
887
- path = options.public + unescape(request.path_info)
887
+ public_dir = File.expand_path(options.public)
888
+ path = File.expand_path(public_dir + unescape(request.path_info))
889
+ pass if path[0, public_dir.length] != public_dir
888
890
  pass unless File.file?(path)
889
891
  send_file path, :disposition => nil
890
892
  end
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'sinatra'
6
- s.version = '0.9.1'
7
- s.date = '2009-03-02'
6
+ s.version = '0.9.1.1'
7
+ s.date = '2009-03-09'
8
8
 
9
9
  s.description = "Classy web-development dressed in a DSL"
10
10
  s.summary = "Classy web-development dressed in a DSL"
@@ -62,4 +62,19 @@ describe 'Static' do
62
62
  get "/foobarbaz.txt"
63
63
  assert not_found?
64
64
  end
65
+
66
+ it 'serves files when .. path traverses within public directory' do
67
+ get "/data/../#{File.basename(__FILE__)}"
68
+ assert ok?
69
+ assert_equal File.read(__FILE__), body
70
+ end
71
+
72
+ it '404s when .. path traverses outside of public directory' do
73
+ mock_app {
74
+ set :static, true
75
+ set :public, File.dirname(__FILE__) + '/data'
76
+ }
77
+ get "/../#{File.basename(__FILE__)}"
78
+ assert not_found?
79
+ end
65
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-02 00:00:00 -08:00
12
+ date: 2009-03-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency