Skip to content

Commit

Permalink
Use non-predictable filename for downloaded patch file
Browse files Browse the repository at this point in the history
Since the /tmp directory is readable by everybody on Unix, and since
the patch name could be public or easy to guess, a attacker could create a symlink
to a file writable by the user running hub, which would be replaced by the patch.

This has been assigned CVE-2014-0177
  • Loading branch information
mscherer authored and mislav committed Apr 15, 2014
1 parent 8150ddb commit 016ec99
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion lib/hub/commands.rb
Expand Up @@ -519,7 +519,7 @@ def am(args)
end
end

patch_file = File.join(tmp_dir, patch_name)
patch_file = Tempfile.new('patch_name')
File.open(patch_file, 'w') { |file| file.write(patch) }
args[idx] = patch_file
end
Expand Down
4 changes: 0 additions & 4 deletions lib/hub/context.rb
Expand Up @@ -556,10 +556,6 @@ def command?(name)
!which(name).nil?
end

def tmp_dir
ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
end

def terminal_width
if unix?
width = %x{stty size 2>#{NULL}}.split[1].to_i
Expand Down

0 comments on commit 016ec99

Please sign in to comment.