Skip to content

Commit a901730

Browse files
Oleksii Korshenkoisitnikov
authored andcommitted
MAGETWO-51376: Application Information disclosure on Update
1 parent f1f8285 commit a901730

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/code/Magento/Backend/App/BackendAppList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function getCurrentApp()
4444
if ($appName && isset($this->backendApps[$appName])) {
4545
return $this->backendApps[$appName];
4646
}
47+
return null;
4748
}
4849

4950
/**

setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,20 @@ public function authPreDispatch($event)
123123
/** @var \Magento\Framework\App\State $adminAppState */
124124
$adminAppState = $objectManager->get('Magento\Framework\App\State');
125125
$adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN);
126+
/** @var \Magento\Backend\Model\Session\AdminConfig $sessionConfig */
127+
$sessionConfig = $objectManager->get(\Magento\Backend\Model\Session\AdminConfig::class);
128+
$cookiePath = $this->getSetupCookiePath($objectManager);
129+
$sessionConfig->setCookiePath($cookiePath);
126130
/** @var \Magento\Backend\Model\Auth\Session $adminSession */
127131
$adminSession = $objectManager->create(
128132
\Magento\Backend\Model\Auth\Session::class,
129133
[
130-
'sessionConfig' => $objectManager->get(\Magento\Backend\Model\Session\AdminConfig::class),
134+
'sessionConfig' => $sessionConfig,
131135
'appState' => $adminAppState
132136
]
133137
);
134138
if (!$objectManager->get(\Magento\Backend\Model\Auth::class)->isLoggedIn()) {
135-
$adminSession->expireSessionCookie();
139+
$adminSession->destroy();
136140
$response = $event->getResponse();
137141
$response->getHeaders()->addHeaderLine('Location', 'index.php/session/unlogin');
138142
$response->setStatusCode(302);
@@ -145,6 +149,25 @@ public function authPreDispatch($event)
145149
return false;
146150
}
147151

152+
/**
153+
* Get cookie path
154+
*
155+
* @param \Magento\Framework\ObjectManagerInterface $objectManager
156+
* @return string
157+
*/
158+
private function getSetupCookiePath(\Magento\Framework\ObjectManagerInterface $objectManager)
159+
{
160+
/** @var \Magento\Backend\App\BackendAppList $backendAppList */
161+
$backendAppList = $objectManager->get(\Magento\Backend\App\BackendAppList::class);
162+
$backendApp = $backendAppList->getBackendApp('setup');
163+
/** @var \Magento\Backend\Model\UrlFactory $backendUrlFactory */
164+
$backendUrlFactory = $objectManager->get(\Magento\Backend\Model\UrlFactory::class);
165+
$baseUrl = parse_url($backendUrlFactory->create()->getBaseUrl(), PHP_URL_PATH);
166+
$baseUrl = \Magento\Framework\App\Request\Http::getUrlNoScript($baseUrl);
167+
$cookiePath = $baseUrl . $backendApp->getCookiePath();
168+
return $cookiePath;
169+
}
170+
148171
/**
149172
* {@inheritdoc}
150173
*/

0 commit comments

Comments
 (0)