Skip to content

Commit ed1e46f

Browse files
IchHabRechtohader
authored andcommitted
[SECURITY] Prevent information disclosure in tests bootstrap
Both, the UnitTestsBootstrap and FunctionalTestsBootstrap set display_errors to 1 which shows errors and warnings by default. If you call those scripts within web context the files can't be loaded and the error message shows the website root path. The patch adds proper checks before files are loaded and exits if an error occurs. Resolves: #67900 Releases: 6.2 Security-Bulletin: TYPO3-CORE-SA-2015-008 Change-Id: I1e294bcd2f6cd7c2a32f54a890ca2d4a869c9fda Reviewed-on: http://review.typo3.org/43120 Reviewed-by: Oliver Hader <[email protected]> Tested-by: Oliver Hader <[email protected]>
1 parent 045b4ea commit ed1e46f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

typo3/sysext/core/Build/FunctionalTestsBootstrap.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ protected function enableDisplayErrors() {
5151
*/
5252
protected function loadClassFiles() {
5353
$testsDirectory = __DIR__ . '/../Tests/';
54+
if (!class_exists('PHPUnit_Framework_TestCase')) {
55+
die('PHPUnit wasn\'t found. Please check your settings and command.');
56+
}
5457
require_once($testsDirectory . 'BaseTestCase.php');
5558
require_once($testsDirectory . 'FunctionalTestCase.php');
5659
require_once($testsDirectory . 'FunctionalTestCaseBootstrapUtility.php');
@@ -122,6 +125,10 @@ protected function getWebRoot() {
122125
}
123126
}
124127

128+
if (PHP_SAPI !== 'cli') {
129+
die('This script supports command line usage only. Please check your command.');
130+
}
131+
125132
$bootstrap = new FunctionalTestsBootstrap();
126133
$bootstrap->bootstrapSystem();
127134
unset($bootstrap);

typo3/sysext/core/Build/UnitTestsBootstrap.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ protected function createDirectory($directory) {
171171
* @return UnitTestsBootstrap fluent interface
172172
*/
173173
protected function includeAndStartCoreBootstrap() {
174-
require_once PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
174+
$bootstrapPath = PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
175+
if (!file_exists($bootstrapPath)) {
176+
die('Bootstrap can\'t be loaded. Please check your path or set an environment variable \'TYPO3_PATH_WEB\' to your root path.');
177+
}
178+
require_once $bootstrapPath;
175179

176180
Bootstrap::getInstance()
177181
->baseSetup()
@@ -211,6 +215,10 @@ protected function finishCoreBootstrap() {
211215
}
212216
}
213217

218+
if (PHP_SAPI !== 'cli') {
219+
die('This script supports command line usage only. Please check your command.');
220+
}
221+
214222
$bootstrap = new UnitTestsBootstrap();
215223
$bootstrap->bootstrapSystem();
216224
unset($bootstrap);

0 commit comments

Comments
 (0)