Skip to content

Commit 5ec132b

Browse files
committedMay 25, 2023
Bug 1834124 - Stored XSS via file sharer
1 parent 8358b43 commit 5ec132b

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed
 

‎src/applications/files/config/PhabricatorFilesConfigOptions.php

+13-9
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,23 @@ public function getOptions() {
3434
'image/x-icon' => 'image/x-icon',
3535
'image/vnd.microsoft.icon' => 'image/x-icon',
3636

37+
// Commented out the below mimetypes for security/privacy concerns.
38+
// It just means these will need to be downloaded instead of viewable
39+
// in the page.
40+
3741
// This is a generic type for both OGG video and OGG audio.
38-
'application/ogg' => 'application/ogg',
42+
// 'application/ogg' => 'application/ogg',
3943

40-
'audio/x-wav' => 'audio/x-wav',
41-
'audio/mpeg' => 'audio/mpeg',
42-
'audio/ogg' => 'audio/ogg',
44+
// 'audio/x-wav' => 'audio/x-wav',
45+
// 'audio/mpeg' => 'audio/mpeg',
46+
// 'audio/ogg' => 'audio/ogg',
4347

44-
'video/mp4' => 'video/mp4',
45-
'video/ogg' => 'video/ogg',
46-
'video/webm' => 'video/webm',
47-
'video/quicktime' => 'video/quicktime',
48+
// 'video/mp4' => 'video/mp4',
49+
// 'video/ogg' => 'video/ogg',
50+
// 'video/webm' => 'video/webm',
51+
// 'video/quicktime' => 'video/quicktime',
4852

49-
'application/pdf' => 'application/pdf',
53+
// 'application/pdf' => 'application/pdf',
5054
);
5155

5256
$image_default = array(

‎src/applications/files/document/PhabricatorDocumentEngine.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ final public function getHighlightedLines() {
3030
final public function canRenderDocument(PhabricatorDocumentRef $ref) {
3131
return $this->canRenderDocumentType($ref);
3232
}
33+
34+
protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
35+
$viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types');
36+
$viewable_types = array_keys($viewable_types);
37+
return $ref->hasAnyMimeType($viewable_types);
38+
}
3339

3440
public function canDiffDocuments(
3541
PhabricatorDocumentRef $uref = null,
@@ -114,9 +120,6 @@ public function shouldRenderAsync(PhabricatorDocumentRef $ref) {
114120
return false;
115121
}
116122

117-
abstract protected function canRenderDocumentType(
118-
PhabricatorDocumentRef $ref);
119-
120123
final public function newDocument(PhabricatorDocumentRef $ref) {
121124
$can_complete = $this->canRenderCompleteDocument($ref);
122125
$can_partial = $this->canRenderPartialDocument($ref);

‎src/applications/files/document/PhabricatorPDFDocumentEngine.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
1313
return 'fa-file-pdf-o';
1414
}
1515

16-
protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
17-
// Since we just render a link to the document anyway, we don't need to
18-
// check anything fancy in config to see if the MIME type is actually
19-
// viewable.
20-
21-
return $ref->hasAnyMimeType(
22-
array(
23-
'application/pdf',
24-
));
25-
}
16+
/* MOZILLA: Instead of always allowing PDFs to be viewable in the web UI,
17+
we use the base canRenderDocumentType() from PhabricatorDocumentEngine.
18+
This checks that the PDF mimetype is viewable according to the system
19+
configuration. */
20+
21+
// protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
22+
// // Since we just render a link to the document anyway, we don't need to
23+
// // check anything fancy in config to see if the MIME type is actually
24+
// // viewable.
25+
26+
// return $ref->hasAnyMimeType(
27+
// array(
28+
// 'application/pdf',
29+
// ));
30+
// }
2631

2732
protected function newDocumentContent(PhabricatorDocumentRef $ref) {
2833
$viewer = $this->getViewer();

0 commit comments

Comments
 (0)
Failed to load comments.