Skip to content

Beautiful Open-Source Form Builder

Block Teredo destinations in public URL validation (#1388)

Julien Nahum84c253a8a63b
diff --git a/api/app/Service/Security/PublicWebhookUrl.php b/api/app/Service/Security/PublicWebhookUrl.php
index cd1bf1e6b..cca729a12 100644
--- a/api/app/Service/Security/PublicWebhookUrl.php
+++ b/api/app/Service/Security/PublicWebhookUrl.php
@@ -194,6 +194,7 @@ class PublicWebhookUrl
'::ffff:0:0/96',
'64:ff9b::/96',
'64:ff9b:1::/48',
+ '2001::/32',
'2002::/16',
]);
}
diff --git a/api/tests/Feature/Security/PublicWebhookUrlTest.php b/api/tests/Feature/Security/PublicWebhookUrlTest.php
index bdf108dbb..76a45b07b 100644
--- a/api/tests/Feature/Security/PublicWebhookUrlTest.php
+++ b/api/tests/Feature/Security/PublicWebhookUrlTest.php
@@ -17,6 +17,11 @@ dataset('non-public webhook destinations', [
'NAT64 end' => ['64:ff9b::ffff:ffff'],
'local NAT64 start' => ['64:ff9b:1::'],
'local NAT64 end' => ['64:ff9b:1:ffff:ffff:ffff:ffff:ffff'],
+ 'Teredo private 192.168.1.1' => ['2001:0:4136:e378:8000:63bf:3f57:fefe'],
+ 'Teredo private 10.0.0.1' => ['2001:0:4136:e378:8000:63bf:f5ff:fffe'],
+ 'Teredo public IPv4' => ['2001:0:4136:e378:8000:63bf:f7f7:f7f7'],
+ 'Teredo start' => ['2001::'],
+ 'Teredo end' => ['2001:0:ffff:ffff:ffff:ffff:ffff:ffff'],
'6to4 metadata' => ['2002:a9fe:a9fe::1'],
'6to4 start' => ['2002::'],
'6to4 end' => ['2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff'],
@@ -63,7 +68,7 @@ it('accepts public addresses outside the blocked ranges and pins them', function
'100.63.255.255', '100.128.0.0',
'191.255.255.255', '192.0.1.0',
'198.17.255.255', '198.20.0.0',
- '93.184.216.34', '2606:4700:4700::1111', '2003::1',
+ '93.184.216.34', '2606:4700:4700::1111', '2001:1::1', '2003::1',
]);
it('pins the validated destination ip for webhook requests', function () {
diff --git a/api/tests/Unit/Service/Pdf/PdfImageResolverTest.php b/api/tests/Unit/Service/Pdf/PdfImageResolverTest.php
index 8ad57c603..0c96c5334 100644
--- a/api/tests/Unit/Service/Pdf/PdfImageResolverTest.php
+++ b/api/tests/Unit/Service/Pdf/PdfImageResolverTest.php
@@ -298,6 +298,17 @@ describe('PdfSafeImageFetcher', function () {
Http::assertNothingSent();
});
+ it('rejects Teredo image urls before making a request', function (bool $allowPrivateWebhooks) {
+ config(['opnform.webhooks.allow_private_urls' => $allowPrivateWebhooks]);
+ Http::fake();
+
+ $fetcher = new PdfSafeImageFetcher();
+ $content = $fetcher->fetch('https://[2001:0:4136:e378:8000:63bf:3f57:fefe]/image.png');
+
+ expect($content)->toBeNull();
+ Http::assertNothingSent();
+ })->with([false, true]);
+
it('rejects responses whose content-length exceeds the download limit', function () {
Http::fake([
'https://images.unsplash.com/*' => Http::response(