Skip to content

Commit 7e01089

Browse files
chupaohongchupaohong
authored andcommitted
fix: reject port in host header to prevent SSR SSRF bypass
1 parent 9f99724 commit 7e01089

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,12 @@ function verifyHostAllowed(
224224
throw new Error(`Header "${headerName}" contains an invalid value and cannot be parsed.`);
225225
}
226226

227-
const { hostname } = new URL(url);
227+
const { hostname, port } = new URL(url);
228+
if (port) {
229+
throw new Error(
230+
`Header "${headerName}" with value "${value}" contains a port and is not allowed.`,
231+
);
232+
}
228233
if (!isHostAllowed(hostname, allowedHosts)) {
229234
throw new Error(`Header "${headerName}" with value "${value}" is not allowed.`);
230235
}

0 commit comments

Comments
 (0)