mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Further mitigate BREACH by reducing reflectiveness
Summary: Ref T3684. The URI itself is reflected in a few places. It is generally not dangerous because we only let you add random stuff to the end of it for one or two controllers (e.g., the file download controller lets you add "/whatever.jpg"), but: - Remove it entirely in the main request, since it serves no purpose. - Remove query parameters in Ajax requests. These are available in DarkConsole proper. Also mask a few things in the "Request" tab; I've never used these fields when debugging or during support, and they leak quasi-sensitive information that could get screenshotted or over-the-shoulder'd. I didn't mitgate `__metablock__` because I think the threat is so close to 0 that it's not worthwhile. Test Plan: Used Darkconsole, examined Requests tab. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T3684 Differential Revision: https://secure.phabricator.com/D6699
This commit is contained in:
parent
7298589c86
commit
d3e700ce19
3 changed files with 27 additions and 6 deletions
|
@ -38,14 +38,25 @@ final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
|
||||||
|
|
||||||
$sections = array_merge($sections, $data);
|
$sections = array_merge($sections, $data);
|
||||||
|
|
||||||
|
$mask = array(
|
||||||
|
'HTTP_COOKIE' => true,
|
||||||
|
'HTTP_X_PHABRICATOR_CSRF' => true,
|
||||||
|
);
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
foreach ($sections as $header => $map) {
|
foreach ($sections as $header => $map) {
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($map as $key => $value) {
|
foreach ($map as $key => $value) {
|
||||||
$rows[] = array(
|
if (isset($mask[$key])) {
|
||||||
$key,
|
$rows[] = array(
|
||||||
(is_array($value) ? json_encode($value) : $value),
|
$key,
|
||||||
);
|
phutil_tag('em', array(), '(Masked)'));
|
||||||
|
} else {
|
||||||
|
$rows[] = array(
|
||||||
|
$key,
|
||||||
|
(is_array($value) ? json_encode($value) : $value),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = new AphrontTableView($rows);
|
$table = new AphrontTableView($rows);
|
||||||
|
|
|
@ -37,10 +37,17 @@ final class AphrontAjaxResponse extends AphrontResponse {
|
||||||
public function buildResponseString() {
|
public function buildResponseString() {
|
||||||
$console = $this->getConsole();
|
$console = $this->getConsole();
|
||||||
if ($console) {
|
if ($console) {
|
||||||
|
// NOTE: We're stripping query parameters here both for readability and
|
||||||
|
// to mitigate BREACH and similar attacks. The parameters are available
|
||||||
|
// in the "Request" tab, so this should not impact usability. See T3684.
|
||||||
|
$uri = $this->getRequest()->getRequestURI();
|
||||||
|
$uri = new PhutilURI($uri);
|
||||||
|
$uri->setQueryParams(array());
|
||||||
|
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'dark-console',
|
'dark-console',
|
||||||
array(
|
array(
|
||||||
'uri' => (string)$this->getRequest()->getRequestURI(),
|
'uri' => (string)$uri,
|
||||||
'key' => $console->getKey($this->getRequest()),
|
'key' => $console->getKey($this->getRequest()),
|
||||||
'color' => $console->getColor(),
|
'color' => $console->getColor(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -199,7 +199,10 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView {
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
'dark-console',
|
'dark-console',
|
||||||
array(
|
array(
|
||||||
'uri' => $request ? (string)$request->getRequestURI() : '?',
|
// NOTE: We use a generic label here to prevent input reflection
|
||||||
|
// and mitigate compression attacks like BREACH. See discussion in
|
||||||
|
// T3684.
|
||||||
|
'uri' => pht('Main Request'),
|
||||||
'selected' => $user ? $user->getConsoleTab() : null,
|
'selected' => $user ? $user->getConsoleTab() : null,
|
||||||
'visible' => $user ? (int)$user->getConsoleVisible() : true,
|
'visible' => $user ? (int)$user->getConsoleVisible() : true,
|
||||||
'headers' => $headers,
|
'headers' => $headers,
|
||||||
|
|
Loading…
Reference in a new issue