Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoIP "geoip2.phar" don't work with Joomla 3.9.3 #23907

Closed
jurihahn opened this issue Feb 14, 2019 · 11 comments
Closed

GeoIP "geoip2.phar" don't work with Joomla 3.9.3 #23907

jurihahn opened this issue Feb 14, 2019 · 11 comments

Comments

@jurihahn
Copy link
Contributor

jurihahn commented Feb 14, 2019

Steps to reproduce the issue

Create library for Joomla with files
geoip2.phar from https://github.com/maxmind/GeoIP2-php
"geoip.php":
include_once('geoip2.phar');

use
jimport('libraryname.geoip');

Expected result

No exceptions, all works as with Joomla 3.9.2

Actual result

Exception:
Failed opening required 'phar://geoip2.phar/vendor/autoload.php

System information (as much as possible)

Joomla 3.9.3
PHP 7.2

Additional comments

i think it is after this fix:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-7743

@jurihahn
Copy link
Contributor Author

i found this https://www.drupal.org/project/drupal/issues/3028265
i think Drupal have same problem

@jurihahn
Copy link
Contributor Author

jurihahn commented Feb 14, 2019

This is quick path:

diff --git a/libraries/vendor/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php b/libraries/vendor/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php
index db500af..e53c141 100644
--- a/libraries/vendor/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php
+++ b/libraries/vendor/typo3/phar-stream-wrapper/src/Interceptor/PharExtensionInterceptor.php
@@ -27,6 +27,10 @@
      */
     public function assert($path, $command)
     {
+        if (preg_match('/^phar:\/\/[a-zA-Z0-9_]+\.phar\/.+\.php$/', $path) === 1) {
+            // Lightweight way to whitelist phar aliases, if they contain ".phar" extension
+            return TRUE;
+        }
         if ($this->baseFileContainsPharExtension($path)) {
             return true;
         }

@mbabker
Copy link
Contributor

mbabker commented Feb 14, 2019

See TYPO3/phar-stream-wrapper#15 for upstream fix

Patching third party files is only a solution for a temporary fix, this type of change cannot be allowed in the CMS.

@mbabker
Copy link
Contributor

mbabker commented Feb 14, 2019

Also as pointed out in https://www.drupal.org/project/drupal/issues/3026443 and related conversation, that patch is actually pretty likely to re-introduce security issues.

@jurihahn
Copy link
Contributor Author

yes, this is just quick solution that work for me. Without this solution my service dont work... Gets Joomla update with fix in version 3.9.4?

@mbabker
Copy link
Contributor

mbabker commented Feb 15, 2019

It depends on when the upstream fix is released. The quick fix that you suggested though should not be included in a release because it re-introduces a similar issue that adding that library tries to solve (basically if you're rolling with that patch you're suggesting on a production site you need to be pretty darn certain that no other PHAR files are able to get into your environment, or you should roll a temporary patch that explicitly whitelists only that PHAR).

@HLeithner
Copy link
Member

@jurihahn maybe you can help test TYPO3/phar-stream-wrapper#15 and give the typo3 devs feedback if it works.

3.9.4 release is planned for 12. March so it should be ready a week before.

@HLeithner
Copy link
Member

@mbabker can you give @jurihahn some advice how to test the typo3 PR please?

@mbabker
Copy link
Contributor

mbabker commented Feb 19, 2019

Quickest thing I can come up with is apply the changes from that repo's src directory to the files in libraries/vendor/typo3/phar-stream-wrapper/src in a Joomla install. There isn't a quick and simple diff to apply and unless you really want to mess with Composer stuff that's probably the easiest choice. You could try mangling the diff from https://patch-diff.githubusercontent.com/raw/TYPO3/phar-stream-wrapper/pull/15.diff to apply to a Joomla install (remove the README and tests directory changes), but no guarantees on that working.

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/23907

@Quy
Copy link
Contributor

Quy commented Feb 20, 2019

Please test PR #23956


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23907.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants