You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 89ac37b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(platform-server): support ports in allowedHosts
Currently `allowedHosts` allows requests on any port as long as the host matches. These changes expand the check so consumers can also set the ports they want to allow within `allowedHosts`.
(cherry picked from commit 46ea814)
Copy file name to clipboardExpand all lines: adev/src/content/guide/security.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -432,7 +432,7 @@ NOTE: Most cloud providers and CDN providers perform automatic validation of the
432
432
433
433
### Configuring allowed hosts
434
434
435
-
To allow specific hostnames, you need to add them to the allowlist. This is critical for ensuring your application works correctly and securely when deployed. The patterns support wildcards for flexible hostname matching.
435
+
To allow specific hostnames, you need to add them to the allowlist. This is critical for ensuring your application works correctly and securely when deployed. The patterns support wildcards and optional ports for flexible host matching.
436
436
437
437
You can configure the `allowedHosts` option in your `angular.json`:
438
438
@@ -479,6 +479,16 @@ For the Node.js variant `AngularNodeAppEngine`, you can also provide `NG_ALLOWED
Omitting a port from an `allowedHosts` entry allows requests on any port for that host. To restrict requests to specific ports, append `:port` to an entry:
485
+
486
+
-`example.com:443`: Allows `example.com` only on port `443` (including default `https://example.com` requests).
487
+
-`*.example.com:8443`: Allows any subdomain of `example.com` only on port `8443`.
488
+
-`[::1]:4200`: Allows the IPv6 loopback address only on port `4200`.
489
+
-`localhost:*`: Allows `localhost` on any port.
490
+
-`*:8443`: Allows any host on port `8443`.
491
+
482
492
IMPORTANT: You can use `*` as a value in `allowedHosts` to allow all hostnames, though this is generally discouraged and presents a security risk. Accepting any host header can expose your application to host header injection and [Server-Side Request Forgery (SSRF)](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/SSRF) attacks. This configuration should only be used when validation for `Host` and `X-Forwarded-Host` headers is performed in another layer, such as a load balancer or reverse proxy. For better security, we recommend using an explicit list of allowed hosts whenever possible. See [GHSA-x288-3778-4hhx](https://github.com/angular/angular-cli/security/advisories/GHSA-x288-3778-4hhx) for more details.
|`autoCsp`| Generates a hash-based Content Security Policy when set to `true`, or to `{"unsafeEval": true}` to also allow `eval`. See [Hash inline scripts with `autoCsp`](best-practices/security#hash-inline-scripts-with-autocsp). |
574
-
|`allowedHosts`| The hostnames allowed to access the server-side application. See [Preventing Server-Side Request Forgery (SSRF)](best-practices/security#preventing-server-side-request-forgery-ssrf).|
|`autoCsp`| Generates a hash-based Content Security Policy when set to `true`, or to `{"unsafeEval": true}` to also allow `eval`. See [Hash inline scripts with `autoCsp`](best-practices/security#hash-inline-scripts-with-autocsp). |
574
+
|`allowedHosts`| The hostnames (and optional ports, such as `example.com:443` or `*.example.com:8443`) allowed to access the server-side application. Omitting a port allows any port for that host. See [Preventing Server-Side Request Forgery (SSRF)](best-practices/security#preventing-server-side-request-forgery-ssrf). |
0 commit comments