Skip to content

Commit 07d009a

Browse files
committed
fixup! fix(@angular/ssr): validate host headers to prevent header-based SSRF
1 parent 0a4fcef commit 07d009a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/angular/ssr/src/utils/headers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const VALID_PROTO_REGEX = /^https?$/i;
2121
*/
2222
const WWW_HOST_REGEX = /^www\./i;
2323

24+
/**
25+
* Regular expression to match path separators.
26+
*/
27+
const PATH_SEPARATOR_REGEX = /[/\\]/;
28+
2429
/**
2530
* Set of hostnames that are always allowed.
2631
*/
@@ -98,7 +103,7 @@ function validateHost(
98103
}
99104

100105
// Reject any hostname containing path separators - they're invalid.
101-
if (value.includes('/')) {
106+
if (PATH_SEPARATOR_REGEX.test(value)) {
102107
throw new Error(`Header "${headerName}" contains path separators which is not allowed.`);
103108
}
104109

0 commit comments

Comments
 (0)