Skip to content

Commit f5595d6

Browse files
author
tchapi
committed
chore
1 parent 13684be commit f5595d6

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/Controller/DAVController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ public function home(): Response
187187

188188
private function initServer(string $authMethod, string $authRealm = User::DEFAULT_AUTH_REALM)
189189
{
190+
// Don't advertise the exact sabre/dav version: it appears in the `X-Sabre-Version`
191+
// header, in the `<s:sabredav-version>` element of every error body and in the HTML
192+
// browser, which only helps someone matching an installation against known advisories.
193+
\Sabre\DAV\Server::$exposeVersion = false;
194+
190195
// Get the PDO Connection of type PDO
191196
$pdo = $this->em->getConnection()->getNativeConnection();
192197

src/Plugins/DavisIMipPlugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,13 @@ public function schedule(ITip\Message $itip)
230230
->replyTo(new Address($senderEmail, $mailSenderName))
231231
->subject($subject);
232232

233+
// Keep holiday auto-replies from bouncing back at invitations. This used to sit behind
234+
// the version check, so disabling that would have silently dropped it too.
235+
$message->getHeaders()->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
236+
233237
if (DAV\Server::$exposeVersion) {
234-
$message->getHeaders()
235-
->addTextHeader('X-Sabre-Version: ', DAV\Version::VERSION)
236-
->addTextHeader('X-Auto-Response-Suppress', 'OOF, DR, RN, NRN, AutoReply');
238+
// NB: the header name carried a trailing ": " here, which is not a valid name
239+
$message->getHeaders()->addTextHeader('X-Sabre-Version', DAV\Version::VERSION);
237240
}
238241

239242
// Now that we have everything, we can set the message body

tests/Functional/DavTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,18 @@ public function testOptionsOnAnUnresolvablePathStillAnswers(): void
233233
$this->assertResponseIsSuccessful();
234234
$this->assertStringContainsString('PROPFIND', (string) $client->getResponse()->headers->get('Allow'));
235235
}
236+
237+
/**
238+
* The exact sabre/dav version appeared in the `X-Sabre-Version` header, in every error
239+
* body and in the HTML browser, which only helps match an install against known advisories.
240+
*/
241+
public function testTheSabreVersionIsNotAdvertised(): void
242+
{
243+
$client = static::requestDavClient('GET', '/dav/');
244+
245+
$this->assertResponseStatusCodeSame(401);
246+
$this->assertStringNotContainsString('sabredav-version', $client->getResponse()->getContent());
247+
$this->assertFalse($client->getResponse()->headers->has('X-Sabre-Version'));
248+
$this->assertFalse(\Sabre\DAV\Server::$exposeVersion, 'The DAV server must be built with version exposure off');
249+
}
236250
}

0 commit comments

Comments
 (0)