Skip to content

Commit 46238dc

Browse files
committed
Block special-use webhook IPv4 ranges
1 parent 4bc5364 commit 46238dc

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/url-guard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export function isInternalUrl(raw: string): boolean {
4545
if (a === 127 || a === 10 || a === 0) return true;
4646
if (a === 172 && b >= 16 && b <= 31) return true;
4747
if (a === 192 && b === 168) return true;
48+
if (a === 100 && b >= 64 && b <= 127) return true;
4849
if (a === 169 && b === 254) return true;
50+
if (a === 198 && (b === 18 || b === 19)) return true;
4951
}
5052
return false;
5153
}

tests/url-guard.test.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ test("SSRF guard blocks private IPv6 webhook targets", () => {
1111
assert.equal(isInternalUrl("http://[::ffff:192.168.1.10]/hook"), true);
1212
});
1313

14+
test("SSRF guard blocks internal IPv4 special-use ranges", () => {
15+
assert.equal(isInternalUrl("http://100.64.0.1/hook"), true);
16+
assert.equal(isInternalUrl("http://100.127.255.254/hook"), true);
17+
assert.equal(isInternalUrl("http://198.18.0.1/hook"), true);
18+
assert.equal(isInternalUrl("http://198.19.255.254/hook"), true);
19+
});
20+
1421
test("SSRF guard allows public IPv6 webhook targets", () => {
1522
assert.equal(isInternalUrl("https://[2606:4700:4700::1111]/hook"), false);
1623
assert.equal(isInternalUrl("https://[::ffff:8.8.8.8]/hook"), false);

0 commit comments

Comments
 (0)