Skip to content

Commit

Permalink
Fix security issue allowing directory traversal for any request serve…
Browse files Browse the repository at this point in the history
…d from the public directory
  • Loading branch information
chris.boulton committed Oct 20, 2010
1 parent 7dcbdf4 commit c35751e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/clarity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
module Clarity
VERSION = '0.9.8'

Templates = File.dirname(__FILE__) + '/../views'
Public = File.dirname(__FILE__) + '/../public'
Templates = File.expand_path(File.dirname(__FILE__) + '/../views')
Public = File.expand_path(File.dirname(__FILE__) + '/../public')
end
7 changes: 4 additions & 3 deletions lib/clarity/server/chunk_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ def template(filename)
end

def public_file(filename)
File.read( File.join(Clarity::Public, filename) )
rescue Errno::ENOENT
raise NotFoundError
path = File.expand_path(File.join(Clarity::Public, filename))
raise NotFoundError unless path[0, Clarity::Public.length] == Clarity::Public
raise NotFoundError unless File.file?(path)
File.read(path)
end

def logfiles
Expand Down

0 comments on commit c35751e

Please sign in to comment.