Skip to content

Commit da8bb31

Browse files
authored
fix(webapp): block benchmarking IP range for alert webhooks (#84)
1 parent 0eca444 commit da8bb31

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Reject alert webhook destinations in reserved benchmarking IP ranges.

apps/webapp/app/v3/services/alerts/safeWebhookUrl.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function isUnsafeIPv4(host: string): boolean {
4242
if (a === 169 && b === 254) return true;
4343
// 100.64/10 carrier-grade NAT
4444
if (a === 100 && b >= 64 && b <= 127) return true;
45+
// 198.18/15 benchmarking
46+
if (a === 198 && b >= 18 && b <= 19) return true;
4547
// 224/4 multicast
4648
if (a >= 224 && a <= 239) return true;
4749
// 240/4 reserved

apps/webapp/test/safeWebhookUrl.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ describe("assertSafeWebhookUrl", () => {
4848
).rejects.toBeInstanceOf(UnsafeWebhookUrlError);
4949
});
5050

51-
it("rejects CGNAT, multicast and reserved ranges", async () => {
52-
for (const host of ["100.64.0.1", "224.0.0.1", "239.1.1.1", "240.0.0.1"]) {
51+
it("rejects CGNAT, benchmarking, multicast and reserved ranges", async () => {
52+
for (const host of [
53+
"100.64.0.1",
54+
"198.18.0.0",
55+
"198.19.255.255",
56+
"224.0.0.1",
57+
"239.1.1.1",
58+
"240.0.0.1",
59+
]) {
5360
await expect(assertSafeWebhookUrl(`http://${host}/hook`)).rejects.toBeInstanceOf(
5461
UnsafeWebhookUrlError
5562
);
@@ -92,6 +99,8 @@ describe("assertSafeWebhookUrl", () => {
9299
describe("assertAddressAllowed", () => {
93100
it("allows public IPv4 / IPv6 addresses", () => {
94101
expect(() => assertAddressAllowed("93.184.216.34", 4)).not.toThrow();
102+
expect(() => assertAddressAllowed("198.17.255.255", 4)).not.toThrow();
103+
expect(() => assertAddressAllowed("198.20.0.0", 4)).not.toThrow();
95104
expect(() => assertAddressAllowed("2606:2800:220:1:248:1893:25c8:1946", 6)).not.toThrow();
96105
});
97106

@@ -104,6 +113,8 @@ describe("assertAddressAllowed", () => {
104113
"192.168.1.1",
105114
"169.254.169.254",
106115
"100.64.0.1",
116+
"198.18.0.0",
117+
"198.19.255.255",
107118
]) {
108119
expect(() => assertAddressAllowed(addr, 4)).toThrow(UnsafeWebhookUrlError);
109120
}

0 commit comments

Comments
 (0)