Bug 1110470 (CVE-2014-3496) - CVE-2014-3496 OpenShift Origin: Command execution as root via downloadable cartridge source-url
Summary: CVE-2014-3496 OpenShift Origin: Command execution as root via downloadable ca...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2014-3496
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: 1110283 1110472 1110473 1110474 1110507
Blocks: 1110862
TreeView+ depends on / blocked
 
Reported: 2014-06-17 18:36 UTC by Kurt Seifried
Modified: 2023-05-12 21:42 UTC (History)
16 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-06-18 20:53:41 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2014:0762 0 normal SHIPPED_LIVE Critical: rubygem-openshift-origin-node security update 2014-06-18 23:39:17 UTC
Red Hat Product Errata RHSA-2014:0763 0 normal SHIPPED_LIVE Critical: rubygem-openshift-origin-node security update 2014-06-18 23:59:59 UTC
Red Hat Product Errata RHSA-2014:0764 0 normal SHIPPED_LIVE Critical: rubygem-openshift-origin-node security update 2014-06-18 23:59:48 UTC

Description Kurt Seifried 2014-06-17 18:36:30 UTC
Jeremy Choi of Red Hat reports:

OpenShift Origin does not properly validated 'Source-Url' of cartridge manifest files to create applications and so commands injected like below in it will be executed in the node. 

  Source-Url: http://name-app.example.com/test/test;reboot;.tar.gz 

Attacks can also succeed when the source-URL ends with .zip, .tgz and .tar. The file specified in Source-Url must be available from the URL for the successful attack.

In cartridge_repository.rb:

498           temporary = PathUtils.join(File.dirname(target), File.basename(cartridge.source_url))
(deleted for brevity)
519             when uri.scheme =~ /^https*/ && cartridge.source_url =~ /(\.tar\.gz|\.tgz)$/
520               begin
521                 uri_copy(URI(cartridge.source_url), temporary, cartridge.source_md5)
522                 extract(:tgz, temporary, target)
523               ensure
524                 FileUtils.rm(temporary)
525               end
(deleted for brevity)
617       def self.extract(method, source, target)
618         case method
622           when :tgz
623             Utils.oo_spawn("/bin/tar -C #{target} -zxpf #{source}",
624                            expected_exitstatus: 0)


The system command execution in line 623 will run #{source} which is comprised of cartridge.source_url. While the source url is validated in manifest.rb, still ';' can be injected.

370         if @manifest.has_key?('Source-Url')
371           raise InvalidElementError.new('Source-Url') unless @manifest['Source-Url'] =~ URI::ABS_URI
372           @source_url = @manifest['Source-Url']


The PoC below has been shown in Online devenv_4873

1. Create a devenv.
2. Place a malformed manifest file with Source-Url modified in a host the devenv can access. 
  
  Source-Url: http://<host>/test;reboot;.tar.gz 

3. Create "test;reboot;.tar.gz" at the path of Source-Url in the host.
4. Try to create a cartridge with the malformed manifest.
    $ rhc app create app1 http://<host>/manifest.yml --no-git

The devenv will reboot.

Comment 2 Mike McGrath 2014-06-17 18:47:02 UTC
While fixing this, lets stop doing this download as root.

Comment 3 Kurt Seifried 2014-06-17 19:30:16 UTC
This has now leaked publicly: https://github.com/openshift/origin-server/pull/5521

Comment 4 Clayton Coleman 2014-06-17 19:41:16 UTC
A single quoted argument around the source URL argument should also have been sufficient to prevent this (' and " are escaped in valid URLs)

Comment 5 Kurt Seifried 2014-06-17 23:38:39 UTC
Upgraded to critical due to authentication requirements, although auth is required a common use case is to give out free testing accounts or other easily created accounts.

Comment 6 Martin Prpič 2014-06-18 07:57:49 UTC
Acknowledgements:

This issue was discovered by Jeremy Choi of the Red Hat HSS Pen-test Team.

Comment 7 errata-xmlrpc 2014-06-18 19:41:32 UTC
This issue has been addressed in following products:

  RHEL 6 Version of OpenShift Enterprise 1.2

Via RHSA-2014:0762 https://rhn.redhat.com/errata/RHSA-2014-0762.html

Comment 8 errata-xmlrpc 2014-06-18 20:00:28 UTC
This issue has been addressed in following products:

  RHEL 6 Version of OpenShift Enterprise 2.1

Via RHSA-2014:0764 https://rhn.redhat.com/errata/RHSA-2014-0764.html

Comment 9 errata-xmlrpc 2014-06-18 20:00:41 UTC
This issue has been addressed in following products:

  RHEL 6 Version of OpenShift Enterprise 2.0

Via RHSA-2014:0763 https://rhn.redhat.com/errata/RHSA-2014-0763.html


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