Project

General

Profile

Actions

Bug #89876

closed

.htaccess files missing from ZIP files downloaded in extension manager

Added by Matteo Bonaker over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
-
Start date:
2019-12-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The current default setting for $GLOBALS['TYPO3_CONF_VARS']['EXT']['excludeForPackaging'] is

'(?:\\..*(?!htaccess)|.*~|.*\\.swp|.*\\.bak|\\.sass-cache|node_modules|bower_components)'

which perfectly excludes files like Classes/UserFunction/Menu.php.bak or .idea from being exported if you hit the “Download as ZIP” button in the extension manager.

Sadly though (and clearly not intended by the author of this regex) it also excludes any .htaccess file. This can cause a security risk if you download a ZIP of an extension that kept secret information or even harmful scripts from users by using a restrictive .htaccess file (as is e.g. common practice when it comes to the Resources/Private/.htaccess). The restricting .htaccess file will be missing from the ZIP and if the unknowing backend user uploads the extension to another installation possibly some access is granted where it should not be!

The problem with the regex is the part \\..*(?!htaccess) which basically sais “match everything that starts with a dot and then has any number of characters of which at least one is not followed by the phrase ‘htaccess’.” Correct would have been \\.(?!htaccess$).* which would translate to “match everything that starts with a dot but where the next thing after the dot is not ‘htaccess’ + end of the string.”

The configuration is effectively applied inside GeneralUtility::getAllFilesAndFoldersInPath as preg_match('/^' . $excludePattern . '$/', $subdirs).

Long story short, my proposed solution is:

'(?:\\.(?!htaccess$).*|.*~|.*\\.swp|.*\\.bak|\\.sass-cache|node_modules|bower_components)'

as contained in the attached patch for 9.5.

Steps to reproduce:

  1. Make or take any extension in any TYPO3 environment
  2. create a .htaccess file in any directory inside the extension on the server
  3. use the extension manager to download said extension as ZIP
  4. open the ZIP file and verify that the .htaccess file is missing

Files

excludeForPackaging.patch (780 Bytes) excludeForPackaging.patch Matteo Bonaker, 2019-12-06 13:15
Actions #1

Updated by Matteo Bonaker over 4 years ago

Oh, right, I forgot to mention that this regex has not changed between versions 7, 8 and 9. So I think the issue has long existed and was not brought to attention for some reason.

Actions #2

Updated by Gerrit Code Review over 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62582

Actions #3

Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62582

Actions #4

Updated by Susanne Moog over 4 years ago

Matteo Bonaker wrote:

Oh, right, I forgot to mention that this regex has not changed between versions 7, 8 and 9. So I think the issue has long existed and was not brought to attention for some reason.

The original issue is https://review.typo3.org/c/Packages/TYPO3.CMS/+/43556 (it was already introduced like that).

Actions #5

Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62658

Actions #6

Updated by Georg Ringer over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Gerrit Code Review over 4 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62666

Actions #8

Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62666

Actions #9

Updated by Georg Ringer over 4 years ago

  • Status changed from Under Review to Resolved
Actions #10

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF