TYPO3 CMS  TYPO3_7-6
SecurityStatus.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
26 {
32  public function getStatus()
33  {
34  $statuses = [
35  'trustedHostsPattern' => $this->getTrustedHostsPatternStatus(),
36  'recordRegistration' => $this->getRecordRegistrationStatus(),
37  'adminUserAccount' => $this->getAdminAccountStatus(),
38  'fileDenyPattern' => $this->getFileDenyPatternStatus(),
39  'htaccessUpload' => $this->getHtaccessUploadStatus(),
40  'saltedpasswords' => $this->getSaltedPasswordsStatus(),
41  'cacheFloodingProtection' => $this->getCacheFloodingProtectionStatus()
42  ];
43  return $statuses;
44  }
45 
49  protected function getCacheFloodingProtectionStatus()
50  {
51  $value = $GLOBALS['LANG']->getLL('status_ok');
52  $message = '';
54  if (empty($GLOBALS['TYPO3_CONF_VARS']['FE']['cHashIncludePageId'])) {
55  $value = $GLOBALS['LANG']->getLL('status_insecure');
57  $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_cache_flooding');
58  }
59  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_cacheFloodingProtection'), $value, $message, $severity);
60  }
61 
67  protected function getTrustedHostsPatternStatus()
68  {
69  $value = $GLOBALS['LANG']->getLL('status_ok');
70  $message = '';
72  if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] === GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL) {
73  $value = $GLOBALS['LANG']->getLL('status_insecure');
75  $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_trustedhosts');
76  }
77  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
78  $GLOBALS['LANG']->getLL('status_trustedHostsPattern'), $value, $message, $severity);
79  }
80 
86  protected function getRecordRegistrationStatus()
87  {
88  $value = $GLOBALS['LANG']->getLL('status_ok');
89  $message = '';
91  if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['enableRecordRegistration'])) {
92  $value = $GLOBALS['LANG']->getLL('status_insecure');
94  $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.install_recordregistration');
95  }
96  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class, $GLOBALS['LANG']->getLL('status_recordRegistration'), $value, $message, $severity);
97  }
98 
104  protected function getAdminAccountStatus()
105  {
106  $value = $GLOBALS['LANG']->getLL('status_ok');
107  $message = '';
108  $severity = \TYPO3\CMS\Reports\Status::OK;
109  $whereClause = 'username = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('admin', 'be_users') .
110  BackendUtility::deleteClause('be_users');
111  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, username, password', 'be_users', $whereClause);
112  $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
113  if (!empty($row)) {
114  $secure = true;
116  $saltingObject = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($row['password']);
117  if (is_object($saltingObject)) {
118  if ($saltingObject->checkPassword('password', $row['password'])) {
119  $secure = false;
120  }
121  }
122  // Check against plain MD5
123  if ($row['password'] === '5f4dcc3b5aa765d61d8327deb882cf99') {
124  $secure = false;
125  }
126  if (!$secure) {
127  $value = $GLOBALS['LANG']->getLL('status_insecure');
129  $editUserAccountUrl = BackendUtility::getModuleUrl(
130  'record_edit',
131  [
132  'edit[be_users][' . $row['uid'] . ']' => 'edit',
133  'returnUrl' => BackendUtility::getModuleUrl('system_ReportsTxreportsm1')
134  ]
135  );
136  $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_admin'),
137  '<a href="' . htmlspecialchars($editUserAccountUrl) . '">', '</a>');
138  }
139  }
140  $GLOBALS['TYPO3_DB']->sql_free_result($res);
141  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
142  $GLOBALS['LANG']->getLL('status_adminUserAccount'), $value, $message, $severity);
143  }
144 
150  protected function getFileDenyPatternStatus()
151  {
152  $value = $GLOBALS['LANG']->getLL('status_ok');
153  $message = '';
154  $severity = \TYPO3\CMS\Reports\Status::OK;
155  $defaultParts = GeneralUtility::trimExplode('|', FILE_DENY_PATTERN_DEFAULT, true);
156  $givenParts = GeneralUtility::trimExplode('|', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'], true);
157  $result = array_intersect($defaultParts, $givenParts);
158  if ($defaultParts !== $result) {
159  $value = $GLOBALS['LANG']->getLL('status_insecure');
161  $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_pattern_partsNotPresent'),
162  '<br /><pre>' . htmlspecialchars(FILE_DENY_PATTERN_DEFAULT) . '</pre><br />');
163  }
164  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
165  $GLOBALS['LANG']->getLL('status_fileDenyPattern'), $value, $message, $severity);
166  }
167 
174  protected function getHtaccessUploadStatus()
175  {
176  $value = $GLOBALS['LANG']->getLL('status_ok');
177  $message = '';
178  $severity = \TYPO3\CMS\Reports\Status::OK;
179  if ($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] != FILE_DENY_PATTERN_DEFAULT
181  $value = $GLOBALS['LANG']->getLL('status_insecure');
183  $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_deny_htaccess');
184  }
185  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
186  $GLOBALS['LANG']->getLL('status_htaccessUploadProtection'), $value, $message, $severity);
187  }
188 
194  protected function isMemcachedUsed()
195  {
196  $memcachedUsed = false;
197  $memcachedServers = $this->getConfiguredMemcachedServers();
198  if (!empty($memcachedServers)) {
199  $memcachedUsed = true;
200  }
201  return $memcachedUsed;
202  }
203 
209  protected function getSaltedPasswordsStatus()
210  {
211  $value = $GLOBALS['LANG']->getLL('status_ok');
212  $severity = \TYPO3\CMS\Reports\Status::OK;
214  $configCheck = GeneralUtility::makeInstance(\TYPO3\CMS\Saltedpasswords\Utility\ExtensionManagerConfigurationUtility::class);
215  $message = '<p>' . $GLOBALS['LANG']->getLL('status_saltedPasswords_infoText') . '</p>';
216  $messageDetail = '';
217  $resultCheck = $configCheck->checkConfigurationBackend([], new \TYPO3\CMS\Core\TypoScript\ConfigurationForm());
218  switch ($resultCheck['errorType']) {
219  case FlashMessage::INFO:
220  $messageDetail .= $resultCheck['html'];
221  break;
224  $messageDetail .= $resultCheck['html'];
225  break;
226  case FlashMessage::ERROR:
227  $value = $GLOBALS['LANG']->getLL('status_insecure');
229  $messageDetail .= $resultCheck['html'];
230  break;
231  default:
232  }
234  if ($unsecureUserCount > 0) {
235  $value = $GLOBALS['LANG']->getLL('status_insecure');
237  $messageDetail .= '<div class="panel panel-warning">' .
238  '<div class="panel-body">' .
239  $GLOBALS['LANG']->getLL('status_saltedPasswords_notAllPasswordsHashed') .
240  '</div>' .
241  '</div>';
242  }
243  $message .= $messageDetail;
244  if (empty($messageDetail)) {
245  $message = '';
246  }
247  return GeneralUtility::makeInstance(\TYPO3\CMS\Reports\Status::class,
248  $GLOBALS['LANG']->getLL('status_saltedPasswords'), $value, $message, $severity);
249  }
250 }
static getSaltingInstance($saltedHash='', $mode=TYPO3_MODE)
Definition: SaltFactory.php:82
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static verifyFilenameAgainstDenyPattern($filename)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static deleteClause($table, $tableAlias='')